sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to find a group?

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 132 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      lothcat
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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#if
        

        there are many ways to achieve what you want πŸ€“

        TIG

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement