How to find a group?
-
Hi all,
This is such a simple question that I feel silly asking it, but I simply can't figure it out. I'm writing a plugin, and I want to calculate the volume of an object, and I know sketchup can do that if the object is a group.
Basically, the user right-clicks a selection to run my plugin, and I want to make that selection a group, calculate the volume, and then output it. I know how to get their selection, and I know how to get the volume of a group, but I don't know how to tell if their selection is a group or how to turn it into one if it isn't.
Any help would be appreciated!
-
Because it's working on a user's selection then all of the selected entities are in the active_entities context and you won't run the risk of a BugSplat by making a group from them directly [this is advised against usually but try it].
model=Sketchup.active_model ents=model.active_entities ss=model.selection group=ents.add_group(ss.to_a) volume=group.volume group.explode'volume' is the volume of the selected objects in cu" if the objects don't form a solid then it'll be a negative value...
Assuming that the user should have selected one group to get the volume...if ss[0] and ss[0].class==Sketchup;;Group volume=ss[0].volume if volume==0 UI.messagebox("Warning! The selected group has no volume") elsif volume<0 UI.messagebox("Warning! The select is not a 'solid' group.") end#if else UI.messagebox("Select ONE group!") return nil end#ifthere are many ways to achieve what you want

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement