How to attach a plane to an object


#1

How to attach a plane to an object
How to attach a plane to an object, and the plane can be changed with the movement, rotation and other operations
That is, I want to add a coordinate for the object


#2

I think the Mplane is what you can use for this:

http://docs.mcneel.com/rhino/5/help/en-us/index.htm#commands/mplane.htm?Highlight=Mplane

HTH
-Willem


#3

Oh, yes, MPlane is very similar to this requirement. But I want to use code to write Plane into the object, when needed, use the code to get out, this should be how to do


#4

I did not see/realize this was a developer question.
How about adding the plane to the user dictionary?

http://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Runtime_CommonObject_UserDictionary.htm

It has the option to directly set planes:
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Collections_ArchivableDictionary_Set_7.htm

The plane will not be transformed along with the object though.
It’s beyond my knowledge but it must be possible to have an eventwatcher transform the plane when the object is transformed.

HTH
-Willem


#5

I am sorry, this is because I have not described clearly, I am from China, poor English ability (:slight_smile:) .

Using events is a way to solve this problem. In addition, as far as I know, each object has its own coordinate plane, just as we use the Gumball, we can align the Gumball to the object. I want to read the plane of the object, what function can be achieved?

Thank you very much for your kind help.


#6

Hi everybody,

Sorry for resurrecting this topic… :slight_smile:

Is there any way to read the coordinates from a MPlane back in RhinoCommon (or maybe Grasshopper)?
I just checked the documentation but I find nearly nothing about MPlanes. This feature seams to be pretty mysterious…

Otherwise, could everyone explain the way to set an eventwatcher (as Willem suggests)?

Many thanks for your help!


(Dale Fugier) #7

Seems like quite a bit here:

http://docs.mcneel.com/rhino/5/help/en-us/commands/mplane.htm

Sorry, no. The MPlane stores custom data on objects and this data is not SDK available. Why do you need it?

– Dale


#8

Hi Dale,

Thank you for your feedback and sorry for my late response…

I’m currently modelling pieces which need to have an local coordiate system (timber members, where wood fiber direction has to be defined for example).
With such a geometry-attached plane , it would be easier to automate the process of creating oriented 2D-drawings of each piece, create BoudingBoxes, or whether display the main directions of each piece (length, width and height) with a gumball-like arrows-triplet (something similar to the “MPlane>Show” command).

MPlane as the big advantage to stay attached with the geometry and update itself by translating or rotating it.

Currently, the turn-arround I use, is to construct a rectangle curve grouped with the intended object. This rectangle is oriented and have a seam point: it acts then as a reference plane.

I was just wondering, if there were any other possibilities to do something similar as MPlane, but tougher than the “rectangle-trick”…


(Dale Fugier) #9

The idea behind MPlane is pretty simple. Simply attach user data, that contains a plane, to some object. When the object is transformed, it’s user data can be transformed too. In the case of MPlane, the plane data is transformed.

I’ve worked up a sample - somewhat of a clone of MPlane - that hopefully will give you an idea how this can work for you.

https://github.com/mcneel/rhino-developer-samples/tree/master/rhinocommon/cs/SampleCsMobilePlane

Let me know if you have any questions.

– Dale


#10

Hi Dale,

Many thanks for your help!
I’ll try to have a look on your sample in the next few days.


#11

Hi @dale,

i am wondering if something as in above example can be set up using python ? Basically i am trying to attach eg. a 3d point to a rhino object and make it update the point when the rhino object is transformed.

c.


(Dale Fugier) #12

Sorry, no. This type of user data must be implemented in a plug-in.

– Dale


#13

@dale, thanks.

I’ll keep my custom events to update on transform / undo / duplicate then, but its ugly since i have to start these events manually and if the events do not run, the transform of the archived geometry gets outdated.

I hope that something as above will be possible in the future if the python script is to be compiled to a plugin.

c.