Command Macro Help

Hello,

I’m having a problem setting up a button macro, and I’m not sure if Rhino can do what I want.

I am trying to orient an object with named/labeled reference points. My goal was to SelMesh I wanted to orient, -Orient, and then -SelName (example: pointA) instead of having to click on the actual point. When the orient command gets to the point where it asks for the reference point, it’s looking for a new command. Typing in the point name doesn’t work, and typing in -SelName and then pointA doesnt assign it as reference point 1 (It adds it to the selection that is to be oriented, and not the reference point.) Is there a way to orient based on the reference point’s object names?

Thanks!

@mcmucher, no but you could reference by putting the point coordinates into your macro. Use the _EvaluatePt command then click on your named point to get the coordinate. Then copy from the command line and paste it into your macro.

c.

1 Like

Hi Clement,

Thanks for the reply. I don’t think that will work in my case, because I want to do this for many files. PointA will have a different coordinate in each file.

@mcmucher,

if you post an example file with a short description, i could show how to write a script which gets the points by name and then extract its coordinates to be used in the Orient command. This should not be too hard if the points are already named in different files.

c.

1 Like

@clement

sample_orientation_names.3dm (293.2 KB)

Thanks so much for the help. I’ll attach a sample file.

Basically what I’m doing is trying to reorient a bunch of head models that I have. I have three landmarks on the mesh I use for this, A_Tragion_R, D_Tragion_L, and B_Infraorbitale_R. I’m using two points on the y axis as targets: Align Right Tragion (A_Tragion_R -> Align Right Tragion) and Align Left Tragion ( (D_Tragion_L -> Align Left Tragion). Ideally the midpoint of A_Tragion_R and D_Tragion_L would be at the origin, but for some reason its based on Align Right Tragion (not a huge deal since I could translate everything afterwards so that the midpoint is at the origin). I then rotate the scan+landmarks so that B_Infraorbitale_R is in line with the x-axis line. I made 4 layers: sample (which contains the mesh), Landmarks (contains the 3 points), FP_Align (contains 2 points and a line), and Aligned (which contains the mesh and landmarks oriented to give you an idea of what I’m getting at.) (Side note: I can rename the 2 align target points if spaces in the names are a problem)

I have many more points on my project meshes, so picking these specific points out away from a highlighted mesh can be hard to see. Since my naming of the points is consistent, i was hoping to use that to my advantage.

Thank you so much! Would be open to suggestions if this process seems backwards.

@mcmucher,

try below script. Type the command _EditPythonScript then open the script. to run it, click on the play button (green triangle) in the script editor. The mesh gets selected automatically.

Note: you have to first delete your layer “Aligned” as it contains the aligned mesh and named reference points. Otherwise the script will not continue since there are multiple points with the same name. In my script, i´ve oriented the reference points too, to avoid this, just uncomment line 51 in the script. There are different comments to make it easier to understand.

mcmucher.py (1.9 KB)

c.

1 Like

@clement

Thank you for making this. It does everything I want to do, but it doesn’t orient other points (that I didn’t mention by name). If I want the other points to move, do I just need to add them to names, or would that mess with the orientation?

@mcmucher,

the easiest change would be to delete this (line number 9) in the script:

rs.UnselectAllObjects()

then just pre-select everything which should be oriented with the mesh, then run the script.

If you want to orient other named objects with the script, you would have to post the names here so i could add them to the script.

c.

1 Like

@Clement

Ok, I think I found something that works for me. I commented out the UnselectAllObjects, but instead added a selNone to start a button/macro. I then did a selName for each point, and then ran the script. Seems to work. Thank you so much for the help!

1 Like