Grasshopper

algorithmic modeling for Rhino

I´m new in python and was wondering how to get the Volume Centroid and then draw this point. 

Normaly you can findsomething like that on rhinosyntax, but i haven´t found anything that works, and if i make rhino.geometry.volumemassproperties.centroid, there comes an error :S.

I hope u can help me :)

Greetings

Ricardo

Views: 2426

Replies to This Discussion

I dont know how it is named in python, but with vb you have to first compute areaamassproperties. 

Private Sub RunScript(ByVal x As Brep, ByVal y As Object, ByRef A As Object)
A = rhino.Geometry.AreaMassProperties.Compute(x).Centroid

Hi Richard,

That can be the same using RhinoCommon (module/namespace Rhino, as Mateus does):

import Rhino

if x:
    a = Rhino.Geometry.AreaMassProperties.Compute(x).Centroid

For more information on RhinoCommon, see here.

---

Using RhinoScript (make sure you right-click the component and choose 'RhinoScript usage'):

import rhinoscriptsyntax as rs
if x:
     a = rs.SurfaceAreaCentroid(x)[0] #the 0 value is the point, the other is precision

For more information about RhinoScript, see the _EditPythonScript command help file. Geometry functions in Python RhinoScript also work in GhPython (grips and some interface selection will not). RhinoScriptSyntax ends up calling RhinoCommon functions that you can read on you computer.

I hope this helps,

- Giulio
________________
giulio@mcneel.com

many thanks :)

it worked so:

if rs.IsPolysurfaceClosed(sv):
massprop = rs.SurfaceVolumeCentroid(sv)
if massprop: rs.AddPoint( massprop[0] )

 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service