How to delete two circles at one time?

image
image
I first draw two round faces and then I want to delete them all at once. I know I can delete it similar to this, but I don’t know how many circles there will be? Should I be able to create an array to store this data? Or use some other method?

image
For example, I first draw a circular surface
image
image

image
Then I delete this data
image

image
Only the most recent ones can be deleted, and the data of the first circle drawing is not saved

Please edit your posts and post code snippets, not images.
(From time to time the Amazon servers lose forum images.)

See: [How to] Post correctly formatted and colorized code on the forum?

1 Like

Because you are reusing the same references and you are setting b back to an empty array before creating the 2nd face.

Yes you can store object references in an array. But you should do this within the module of your extension, inside your namespace module.

Also, even though Entities#add_circle returns an array of edges, you can get a single reference to the circle’s ArcCurve object.

# within your class or extension submodule
@circles = []

circle_edges_1 = aface( 50, [0,0,1] )
@circles << circle_edges_1.first.curve

circle_edges_2 = aface( 50, [0,0,10] )
@circles << circle_edges_2.first.curve

The call to first on the edges array returns the 1st edge in the array, …
then the call to curve on the edge, returns it’s Curve object, or ArcCurve if it’s a uniform curve with a single center and radius. (In the case of a circular curve, it will be closed, indicated by the start and end angles.)

def aface(rids,pts)
  mod = Sketchup.active_model # Open model
  ent = mod.entities # All entities in model
  sel = mod.selection # Current selection
  circle = ent.add_circle pts,[0,0,1],rids
  circle_face = ent.add_face circle
  return circle
end


rids = 10
pts = [10,0,0]
a = []
b = aface(rids,pts)
a = a+b

If I change a random input, for example pts = [0,10,0], and store it; I get two round faces.
image

def aface(rids,pts)
  mod = Sketchup.active_model # Open model
  ent = mod.entities # All entities in model
  sel = mod.selection # Current selection
  circle = ent.add_circle pts,[0,0,1],rids
  circle_face = ent.add_face circle
  return circle
end


rids = 10
pts = [0,10,0]
#a = []
#b = aface(rids,pts)
#a = a+b
ent.erase_entities(a)

When I try to delete this array, I can only delete one face.
image

Thanks,But I just tried your method and the computer crashed…

Thanks, i know my problems!!!

You got a BugSplat? Did you submit it? And what version did you use?

Care to share it with the rest of us? Would help other that might have similar issue.

I’m using the 2018 version and I found out it was a problem with my stored data.