Group only edges from a face yet selectcted ?
-
Hello
I post here a question from a French guy
He wants to group the edges of a face created with a tool like Rectangle for example (this face of rectangle yet selected)He arrives to recover (with face.outer_loop) edgesUse, edges, vertices from edges, each vertex from each edge, and also the points 3D of each extremities of an edge.
But he don't arrive to make a group with only the edges!
How to create the necessary collection of entities?
Entities.add_group (optional = an entities collection to add to the group)
He don't find anything in edge, line, drawingelement, entity.
He can delete and redraw but it's not elegant!
Thanks for him by advance!
-
If we are working in the 'active_entities' it is relatively easy.
BUT if it involves crossing entities-collections boundaries it's more difficult as bugsplat is likely with ..add_group(list) where list is not in the active_entities !
So let us assume we have a current Selection that includes the Faces/Edges that are needed for the Group.
First we collect the Faces' Edges and then add add other 'loose' Selected Edges that aren't otherwise included...
Then we simply use '..add_group(edges)'.
A Group is added to the 'active_entities' containing those edges, if the edges are needed by a face they are duplicated inside the Group rather than moved.
Here's the code [it's 'partial' - and needs adding into a def method inside a module/class etc]:model=Sketchup.active_model edges=[] ss=model.selection ss.grep(Sketchup;;Face).each{|face| edges << face.edges} ss.grep(Sketchup;;Edge).each{|edge| edges << edge} edges.flatten! edges.uniq! edges.compact! ### now we have a list of the edges ents=model.active_entities group=ents.add_group(edges) group.name="aretes_sans_faces" ### etc...
-
Thanks TIG for the code and the explanations!
I was confused because when grouping only edges, you can't edit the new group by clicking on an edge : sketchup makes a copy of the edges and makes the group with the copied edges.
I thought my code was wrong.
We can't see the group because the face hides the group !
Aerilius on the french forum gave me the trick: for manually edit the group i need to erase edge(s) of the face and the group becomes visible and editable.Sorry for my stupid question, i am a beginner...
NB: Please excuse my poor English
-
Your edges are duplicated in the group so they are 'overlaid' - making it difficult to pick them manually.
But if you name your group, as my code suggests you should be able to use the Outliner to select the group, double click it in the dialog and it opens for editing.
If you are happy to loose the selected faces [you speak of erasing an edge so you can select the group !], then you can adjust the code to erase each face after it adds the edges to the collection.
Then at the point where you make the group all edges that are not needed to support an existing face are moved into the new group, rather than being duplicated in it.
This version of the tool would 'collect edges from selected faces, erase the faces and group the edges...
More simply consider adding the group using the selected faces rather than their edges:
group=ents.add_group(ss.grep(Sketchup::Face))
the faces are moved into the group taking any edges with them [that are not needed by other non-selected faces]: then you use:
group.entities.erase_entities(group.entities.grep(Sketchup::Face))
which leaves the edges behind inside the group, unless some are needed to support non-selected faces, in which case they are left in the active_context and 'duplicated' inside the group.
This deletes the selected faces and groups their edges. -
Absolutely perfect!
Everything works fine now.
Thank you very much TIG.
-
I found this very useful for my work , can the Edges-Group collect in a layer " Pattern " and invisible
I don't know how to write a code
Thanks.
edge_layer = model.layers.add("Patterns") ss.each{|e| e.layer = edge_layer if e.is_a? Sketchup::Edge and group.name="Edges" } edge_layer.visible = false
-
@pingpink: ALL primitives (faces, edges, arcs, etc.) should be on Layer0
If you want them on a Layer, then Group them, and put the group on another layer. -
Yes , Dan , I can group manually and put in a layer 0 , but I have to remodel a Unitized Curtain Wall to count Panels as a whole facade.
Therefore , when I receive a model from architect, at the beginning I have to store data of patterns in a Layer : Patterns and the visible is false to keep edges. There will be subdividing panels on a model which I can do tagging and extract the size and quantity of panels for entire facade. You can see from my idea's picture. The hiding edges of patterns cut faces to be many pieces in one panel. I want to store edges to be group and invisible , so I can toggle layers on-off in my project.
-
If the panels are divided up with coplanar edges [visible/hidden/smooth/soft etc] and you want to remove them there are already several relatively short 'erase/delete-coplanar-edges' scripts around.
If you want to move these edges to another OFF layer... them look at these scripts' code and rework it so that rather than erase! edges it changes their layer ?I still don't fully understand you requirements.
Can you state is short sentences the 'process'.
What you start off with.
What you want to end up with.
Why you need it be end up like that [e.g. what you then do with it]It could be we can offer alternative 'processing' rather than a full scripted solution...
-
Hi ,
The process :
-
Store Data - Components , Patterns , Panels of original data from Architect's Model
-
Tag Part Number - Select Panels ,and distinguish different panels type
-
Auto Open Patterns - To recheck the original design
-
Re-Tag Part Number - The users have to change after checking Patterns , Different patterns have different tag numbers even though they are the same sizes.
My expectation needs to " Store Data and Recheck Patterns later for a RE-TAG Number correctly " as a facade designer wants.
-
Advertisement