Is there some way to query an object for its location?


Is there someway to get the location of, say, a circle’s centerpoint in world coordinates? Or is it up to me to keep track of where everything is? If it IS up to me, how can I determine the location of an object I’ve inserted from another file?

(Pascal Golay) #2

Hi Ed- for many types of geometry, info is available through RhinoScript functions - e.g.

Rhino.CircleCenterPoint (strCircle)

and in Python


if you are using RhinoScript syntax,

import rhinoscriptsyntax as rs
X = rs.GetObject()
Y = rs.CircleCenterPoint(X)
print Y

Otherwise you can get at it through RhinoCommon.

Also Rhino.ArcCenterPoint(), Rhino.CurveStartPoint(), Rhino.CurveEndPoint(), etc.

For an arbitrary surface you can for example evaluate the surface at the mid parameter in both directions ( Rhino.EvaluateSurface (strSrf, arrParam) or possibly find the middle of the bounding box.



Thanks! (Sorry to trouble you with such a simple question; I forgot about the curve functions)

And so, if I also wanted to fully determine the circle’s orientation, would I use rs.CurveNormal() combined with rs.CurveEndpoint()? (even though a circle has no visual beginning or end, I believe I need to know where it begins in order to completely control lofting using a circle, but perhaps I’m wrong about that.)

I’m afraid I don’t know what you mean by “through RhinoCommon”. Is that another set of functions? (I probably knew this at one point, but after a week of trying to digest and work with all of this, my aging memory banks are rather overloaded)

(Pascal Golay) #4

rs.CurvePlane() will get you the plane of the circle, but, it is an example, since you asked, of where you could use Rhino Common since Rhino Common gives access to various properties of a circle, only some of which are exposed in RhinoScript or RSSyntax as far as I can see. ( , if you want to open that can of worms… it is powerful but not as handy as rsSyntax by a long shot)

For example, a circle’s plane

import Rhino
import scriptcontext as sc
X = rs.GetObject()

if rs.IsCircle(X):
circle = sc.doc.Objects.Find(X)
circle_plane = circle.Geometry.Arc.Plane

You see there we got out of the rs syntax and are accessing the objects through Rhino.Geometry etc. (which is what rs Syntax does under the hood). You just get more stuff that you can do… but sorting out how it all goes together is a challenge. In the above example, the result so far is a plane object, which you can send back through to rs: rs.AddCircle (circle_plane, 12) will add a circle in the same plane as the one you select, but with radius 12.

My guess is rsSyntax will get you pretty much all of what you need and more quickly than delving into Rhino Common before you feel like that is necessary - I probably muddied the waters by mentioning it at all…