[Plugin] Face(s) to group(s)

[Plugin] Face(s) to group(s)

Postby bentleykfrog » Fri Oct 22, 2010 11:18 am

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)
1
Last edited by bentleykfrog on Thu Jan 13, 2011 12:43 am, edited 1 time in total.

bentleykfrog 
 

Re: [Plugin] each face to one group

Postby thomthom » Fri Oct 22, 2010 11:41 am

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.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Face(s) to group(s)

Postby Gaieus » Fri Oct 22, 2010 12:18 pm

Topic split.
0
User avatar
Gaieus 
 

Re: [Plugin] Face(s) to group(s)

Postby wg19861110 » Sat Oct 23, 2010 4:57 pm

Think U!I learn more
0

wg19861110 
 

Re: [Plugin] Face(s) to group(s)

Postby daarboven » Wed Jan 12, 2011 3:15 pm

I noticed this doesn't work with SU 6 because of this line:
Code: Select all
model.start_operation("Face(s) to Group(s)",true)

if you edit it to
Code: Select all
model.start_operation("Face(s) to Group(s)")

leaving out the second parameter it works in SU 6.

Thanks for the plug, anyway.

regards
0

daarboven 
 

Re: [Plugin] Face(s) to group(s)

Postby Edson » Wed Jan 12, 2011 3:22 pm

what is a hard edge in sketchup?
0
edson mahfuz, architect | porto alegre • brasil
http://www.mahfuz.arq.br
User avatar
Edson 
Global Moderator
 

Re: [Plugin] Face(s) to group(s)

Postby Jim » Wed Jan 12, 2011 3:41 pm

daarboven wrote:I noticed this doesn't work with SU 6 because of this line:
Code: Select all
model.start_operation("Face(s) to Group(s)",true)

if you edit it to
Code: Select all
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:
Code: Select all
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.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Face(s) to group(s)

Postby bentleykfrog » Thu Jan 13, 2011 12:44 am

Jim wrote:
daarboven wrote:I noticed this doesn't work with SU 6 because of this line:
Code: Select all
model.start_operation("Face(s) to Group(s)",true)

if you edit it to
Code: Select all
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:
Code: Select all
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.
0

bentleykfrog 
 

Re: [Plugin] Face(s) to group(s)

Postby bentleykfrog » Thu Jan 13, 2011 12:48 am

Edson wrote:what is a hard edge in sketchup?


I presumed it was the opposite of a hidden, soft or smooth edge

bentleykfrog wrote: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.
0

bentleykfrog 
 

Re: [Plugin] Face(s) to group(s)

Postby daarboven » Mon Jan 17, 2011 11:35 am

bentleykfrog wrote:
Jim wrote:
daarboven wrote:I noticed this doesn't work with SU 6 because of this line:
Code: Select all
model.start_operation("Face(s) to Group(s)",true)

if you edit it to
Code: Select all
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:
Code: Select all
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 ;)
0

daarboven 
 

Re: [Plugin] Face(s) to group(s)

Postby thomthom » Mon Jan 17, 2011 11:56 am

The second argument is optional. It just didn't exist in older versions.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: Debora Macedo, Geoff, Google Bot, ljus, ngoctung0211, userid7 and 12 guests

Visit our sponsors: