sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Group.volume

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 420 Views 5 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.
    • M Offline
      morci429
      last edited by

      Guys did anyone try using group.volume function?? i've been trying to use it but it doesn't seem to work. any body came across the same thing before??

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @unknownuser said:

        ](http://code.google.com/apis/sketchup/docs/ourdoc/group.html#volume)":3osf11lz]

        Sketchup 8.0+

        The volume method is used to compute the volume of this group if and only if this group is manifold.

        ... If the group represents a manifold volume, volume will be a positive value. If volume is negative, the group is not manifold.

        See Also: Group.manifold?

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Mike, are you using Free or Pro edition ?

          Can you provide an example of when it "doesn't work" ?

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            Hi,

            If you're in trouble with group.volume, try this: (assumed g parameter is a group entity)

            def vol(g)
            	v=0.0
            	for face in g.entities
            		next unless face.kind_of? Sketchup;;Face
            		v +=(2*face.area*face.vertices[rand(2).to_i].position.to_a.dot(face.normal))/6
            	end
            	# if needed, convert cubic Inches to m3
            	return (v * 0.000016387064)
            end
            

            DB

            1 Reply Last reply Reply Quote 0
            • M Offline
              morci429
              last edited by

              Hi Didier, Great code thank u very much it did the job for me but its always worth to learn another way so Dan here's what i was trying to do with group.volume

              
              pt = []
              pt[0] = [0,0,0];pt[1] = [100,0,0];pt[2] = [100,100,0];pt[3] = [0,100,0]
              face = Sketchup.active_model.entities.add_face pt
              face.pushpull -100
              
              

              then i had to find out how many entities i had in the model and which of them is faces so i can add them to the group using selection.clear and selection.add

              and then i add all the faces to a group and i made a few copies of it.
              and i tried to use the function but it never worked.
              could you demonstrate a good practice of the function?
              thanks you ๐Ÿ˜„

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

                Why not add the face directly into the group in the first place?

                model=Sketchup.active_model
                group=model.active_entities.add_group()
                face=group.entities.add_face(pt)
                face.pushpull(-100)
                faces=[]
                group.entities.each{|e|faces << e if e.class==Sketchup;;Face}
                

                now faces is an array of all of the new faces inside group ?
                You can use new_group=group.copy etc...
                Then

                new_faces=[]
                new_group.entities.each{|e|new_faces << e if e.class==Sketchup;;Face}
                

                etc etc...

                TIG

                1 Reply Last reply Reply Quote 0
                • M Offline
                  morci429
                  last edited by

                  that is certainly a better way thank you.
                  but still group.volume still not working.
                  did you use it before? what would be the way to use it?
                  thanks

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

                    The group.volume in v8 [ http://code.google.com/apis/sketchup/docs/ourdoc/group.html#volume ] and Didier's way otherwise should both work... for 'manifold' / 'solid' forms...
                    What is the output/error in the Ruby Console ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @morci429 said:

                      but still group.volume still not working.

                      Exactly what isn't working?
                      Unexpected result?
                      Errors?

                      Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        morci429
                        last edited by

                        Didier's way is working with no proplems.
                        and this is the error message when i try to use group.volume
                        group.volume
                        Error: #<NoMethodError: (eval):41: undefined method `volume' for #Sketchup::Group:0x4d28ba0>
                        (eval):41

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          morci429
                          last edited by

                          i think i know where the problem is.. it only works in SketchUp 8. i just tried it
                          really sorry about that.
                          i was using 7 before that

                          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