[Plugin] Face(s) to group(s)
-
I thought I'd re-write this script to provide an edge-condition for the grouping. Thanks to Didier and Gavvy for permission to publish this.
This is my first attempt at a sketchup ruby script though i've had some previous experience with OOP, so any advice/suggestions would be greatly appreciated.
The script can be accessed through the menu 'Plugins' -> 'Face(s) to Group(s)' or 'Context Menu (With Face Selected)' -> 'Face(s) to Group(s)'
First select some ungrouped geometry containing faces and run one of three commands:
F2G: by Any Edge: Creates a single group for each face selected
F2G: by Hard Edge: Creates a single group for each collection of faces defined by a hard edged outer loop
F2G: by Hard + Hard Hidden: Creates a single group for collection of faces defined by either a hard edged outer loop or a hard hidden edged outer loop
The first option can create an incredible amount of groups if there is a large selection, and Sketchup tends to slow down at around 750 groups per context, so F2G: by Hard Edge and F2G: by Hard + Hard Hidden gives you some control of the division of each group. F2G: by Hard Edge combined with an intersect operation allows you to define the cutting planes for large geometry, ie.
1. Group the selection of faces you want to divide
2. Enter this group and change the face style to wireframe to select and hide all the edges inside the group
3. Switch the style to any style other than wireframe and in a seperate group define some cutting planes to divide up the faces
4. In the first group, select all geometry and run 'intersect faces' -> 'with model' from the context menu
5. In the first group, select all geometry and run 'Face(s) to Group(s)' -> 'F2G: by Hard Edge' from the context menu
This should create groups seperated by the 'hard' edge created by the cutting planes.
In this version there are also some extra settings to change the edge style during the operation. They can be accessed by the menu 'Plugins' -> 'Face(s) to Group(s)':
Preserve Edge Condition: Does exactly that, leaves the edges in the selection as they are
Restore Hidden Edges: Turns all hidden edges into unhidden edges
All Edges Hard: Turns all edges in the selection to unhidden, unsoft and unsmooth (ie a hard edge)
Changelog
-
13th January 2011 (v0.51)
-
General Maintenance: Added sketchup 6 check for start_operation (thanks to Jim and Daarboven)
-
-
Could you please post this as a separate thread? That way it's easier to locate the plugin when it's at the top of the thread. When they are further down in the post list it's very hard to find.
-
Topic split.
-
Think U!I learn more
-
I noticed this doesn't work with SU 6 because of this line:
model.start_operation("Face(s) to Group(s)",true)
if you edit it to
model.start_operation("Face(s) to Group(s)")
leaving out the second parameter it works in SU 6.
Thanks for the plug, anyway.
regards
-
what is a hard edge in sketchup?
-
@daarboven said:
I noticed this doesn't work with SU 6 because of this line:
model.start_operation("Face(s) to Group(s)",true)
if you edit it to
model.start_operation("Face(s) to Group(s)")
leaving out the second parameter it works in SU 6.
Thanks for the plug, anyway.
regards
Right. I have been using this:
if Sketchup.version.to_f < 7.0 Sketchup.active_model.start_operation("Operation") else Sketchup.active_model.start_operation("Operation", true) end
It ain't pretty, but it is clear and even explains a little about the reason.
-
@jim said:
@daarboven said:
I noticed this doesn't work with SU 6 because of this line:
model.start_operation("Face(s) to Group(s)",true)
if you edit it to
model.start_operation("Face(s) to Group(s)")
leaving out the second parameter it works in SU 6.
Thanks for the plug, anyway.
regards
Right. I have been using this:
> if Sketchup.version.to_f < 7.0 > Sketchup.active_model.start_operation("Operation") > else > Sketchup.active_model.start_operation("Operation", true) > end >
It ain't pretty, but it is clear and even explains a little about the reason.
Thanks for the tips Jim and Daarboven, I've updated the script to check for this.
-
@edson said:
what is a hard edge in sketchup?
I presumed it was the opposite of a hidden, soft or smooth edge
@bentleykfrog said:
All Edges Hard: Turns all edges in the selection to unhidden, unsoft and unsmooth (ie a hard edge)
If there's better terminology for this I'll update the code.
-
@bentleykfrog said:
@jim said:
@daarboven said:
I noticed this doesn't work with SU 6 because of this line:
model.start_operation("Face(s) to Group(s)",true)
if you edit it to
model.start_operation("Face(s) to Group(s)")
leaving out the second parameter it works in SU 6.
Thanks for the plug, anyway.
regards
Right. I have been using this:
> > if Sketchup.version.to_f < 7.0 > > Sketchup.active_model.start_operation("Operation") > > else > > Sketchup.active_model.start_operation("Operation", true) > > end > >
It ain't pretty, but it is clear and even explains a little about the reason.
Thanks for the tips Jim and Daarboven, I've updated the script to check for this.
Thanks for the update, and yes, the version conditional is much more readable!!! If the start_operation method would have default values for the parameters, older versions would have stayed out of trouble
-
The second argument is optional. It just didn't exist in older versions.
Advertisement