Object Axis in python

I’m working on a python script and I need access to the Y axis of an object selected by the user, but I’m not sure how to get that. By “Y axis of an object” I mean the same axis/vector you get from the gumball when you have it aligned with an object instead of the world axis.

It seems like a simple thing but I’m stuck :frowning:

Hi Roberto - at the Rhino object level, there is TryGetGumballFrame - if successful, this has a plane associated with it

image

-Pascal

Hmm - looking more closely that plane looks like everything is unset - I probably did not give you the right answer here.

-Pascal

Thanks Pascal, but I think I’m the one overcomplicating things here.

Essentially I need to rotate some objects around their own local Y axis, instead of the world axis. So, I just need to get that Y axis information somehow, it doesn’t have to be through the gumball necessarily.

Hi Pascal,
sorry, since for a few days I have been interested in doing exactly what you suggested in the photo:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

id = rs.GetObject("Sel", 0, True, True)
obj = rs.coercerhinoobject(id)

rc, x = obj.TryGetGumballFrame()
print x.Plane[0]

#rc, xx = obj.TryGetGumballObject() #error
#sc.doc.Objects.Add(xx.Frame)  #error

I can recover the coordinates, but I would like to have the Frame as an object, it would be possible?

If you mean an object in the document, geometry, you’ll need to build that yourself - but in any case at thst gumball frame thing needs investigation - it looks like the rigjht thing but I was probably using it wrong.

There is no such thing, apart from the gumball frame as far as I know. Some objects can provide a plane say with TryGetPplane() but there is no telling how that will be oriented about its Z axis, necessarily, so I don’t know how helpful that is, and in general arbitrary objects will not sucessfully provide a plane.

-Pascal

2 Likes

I believe the only consistent way to track a frame is through setting your own custom user data. When an object is added you’d set it to the CPlane, then apply each transform that happens to the object through the OnTransform method you’d implement, thus tracking the object frame throughout its life. I don’t think this is possible through Python but I could be mistaken.

In Rhino objects don’t really have an object frame nor object origin.

1 Like

ok therefore no possibility via script, of finding myself with a “geometric physics in Rhino” srf which
indicates the type of plan reported by Gumball. (as happens in Gh when Baking the Plane component)

I think it wouldn’t be a bad idea to click with the mouse on the Plane/Frame
of the Gumball, and find yourself creating an srf indicating this Plane