A small "entity to group" problem
-
hi,
i wopuld be greatful for a small tip:i have a @main_element,
which contains some faceswhen i iterate thru the entities, i can check the normal, see the top face and push pull
i also can create a new group within the @main_element-container and put an edge in it.
buit when i want to put one of the @ main_element's entities (here it is a face) into this new group,
i get a "parent" problem, which i don't understand:@selection.each { |entity| if entity.is_a?(Sketchup;;Face) check_normal_for_horizontal(entity) #my own method puts @bgf_count_normal # 1 is face top if @bgf_count_normal == 1 puts "---FACE UP ... IN MAIN-ELEMENT" # entities = @main_element.entities # group = entities.add_group entities2 = group.entities point1 = Geom;;Point3d.new(0,0,0) point2 = Geom;;Point3d.new(2000,200,200) #works edges = entities2.add_edges point1, point2 # # loop = entity.outer_loop # does not work edgearray = loop.edges floor = entities2.add_face(edgearray) end end }
why does the new face from edgearray not appear in the group?
info from console:
###############
---FACE UP ... IN MAIN-ELEMENT
Error: #<ArgumentError: Edge has different parent>
C:/Program Files (x86)/SketchUp/SketchUp 2014/Tools/02.rb:959:in `add_face'
################thanx
stan -
Tip:
Don't iterate a selection,
Its referring changes as you remove items!
Iterate a snapshot array of it
@selection.to_a.
Next...
You can't reassign entities from one context to another.
Although you CAN 'add entities' in the active_entities context into a group.entities in the same context.
BUT you can't do it the way you want - because you are attempting to make a face in one context using the edges in another...Try something like:
varray = entity.outer_loop.vertices floor = entities2.add_face(varray)
You can use an array of vertices as well as points... -
hi tig,
that's fantastic,
point 2 : solved ( i already though of retrieving the points , but vertices work perfectly!
for point 1:
got it working, super. thanx.
by the way, is there a code for deliting an array of edges directly ? or do i have to iterate thru the array and erase one after another?
in my case i create a copy of a face in the new group (>> vertices)
and wantto delete the original entity incl. edges.thanx a lot
stan -
@artmusicstudio said:
..., is there a code for deliting an array of edges directly ? or do i have to iterate thru the array and erase one after another?
The argument can be a single entity, or an array of entities.
ALSO... Ruby has an "accordian operator" the
*
that can be used to expand an array into a argument list, or compress arguments in an array.
IFerase_entities
also takes a list of multiple entities, you could convert the aray to a list like:
my_ents.erase_entities( *my_edge_array )
Advertisement