Group.volume
-
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??
-
@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?
-
Mike, are you using Free or Pro edition ?
Can you provide an example of when it "doesn't work" ?
-
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 -
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 -100then 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
-
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 usenew_group=group.copyetc...
Thennew_faces=[] new_group.entities.each{|e|new_faces << e if e.class==Sketchup;;Face}etc etc...
-
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 -
The
group.volumein 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 ? -
@morci429 said:
but still group.volume still not working.
Exactly what isn't working?
Unexpected result?
Errors? -
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 -
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
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