Help with macro to streamline Orientate on surface command

I haven’t done that much work on automating things in Rhino,
so I could use some help as I try to eliminate some clicking as I use the orientate on surface command for repeated tasks.

I keep a palette of objects on my drawing off to the side and I have a surface that stays in the same location. I would like to be able to just click anywhere on an object to orientate and have it immediately be ready to drag over the surface.

So basically I want to eliminate having to:
hit enter after clicking on object,
select a base point for the object---------- (which remains constant for each object),
select a reference point for scaling -------(the objects are never scaled),
select the surface to orientate on --------- (its always the same one),
not have to go through the dialogue box-(scale is always uniform , rotation prompt always selected)

Any advice or pointers on how to achieve this would be greatly appreciated, Thanks.

Would this be of any help?

Thank you so much Jarek for sending me that link to Orientate on Objects plug in.
I did load it and tried it out briefly, but for me it was slower than doing all the clicking mentioned above, (probably because I don’t have the time/patience to really familiarize myself with it right now). that I was trying to eliminate when using the us Orientate on surface command, with a macro that I am not able to create yet. One big plus is that it works with meshes, I haven’t been able to use the Orientate on surface command wit meshes. What I use a lot in Zbrush is the insert mesh feature. But Zbrush has no snapping, and you cant drag an see the object you are orientating or inserting in real time, you drag the cursor along the surface and click to insert then you can scale and rotate. But whats nice about it is you can create a pallet of objects that’s accessible for any project, and just pop one on to the surface with one click.

Hi Flubber - if I understand what you’re after, I don’t think a macro will do it - you’ll need a script of some kind and a little setup overhead - I can imagine the workflow might be

  1. Setup: For each object in your catalog on the side, set a base point and reference point - this would be done once per object and the info would be stored on the object as user text.

  2. When you run the script or command, you’d select a target object and then basically select the objects to place, one after the other - click to select, click to place, click to set rotation, next.

  3. When you next run the command, it assumes the same target until you change it.

I believe all of the above is perfectly possible in a Python or RhinoScript; if I have some time, I’ll see if I can take a poke at it.

-Pascal

hi Flubber,

Here is a quick script idea how this may work - you may want to put them into a button with LMB for OrientB and RMB for OrientA.

“Orient A” you just need to run once in the file to define the base surface and all your objects and their respective base points. Once you do it these settings will be remembered. Or you can only use it to define new surface. Or add/change more object’s base points…

Then every time you run the OrientB script, you just pick the object to orient, and you can keep orienting/rotating until you cancel with RMB.

this could be tailored more but give it a shot.
OrientA.rvb (601 Bytes)
OrientB.rvb (875 Bytes)

Thanks for those replies.

Jarek, Thanks for those scripts! I tried them and yes they would help, but I wasn’t getting correct orientation, and I couldn’t seem to permanently load them into the script engine.

I used theLoad scirpt command and used the ADD button and added them to that list there in that command, then I clicked on the scripts Orient A first and then Orient B and used the Load button. This ran the script and they worked fine except there seems to be a problem in that even though I had the object with the construction plane with Z up as I wanted it and selected the correct base point the object did not orientate correctly as it does with the Orientate on surface command. After I clicked on the surface the object was shifted away from that selection point and not orientated with the surface normal?

Also when I wanted to run the scripts again and tried to use the Run Script command the scripts were not on the list that appears when using that command, so every time I wanted to use the scrips I had to use the load script command.?

Thanks

Hi Flubber,

If you had a custom CPlane in the document, the script might have worked incorrectly. I have fixed that. As for running the scripts, take a look at the attached toolbar with a button where RMB is the ‘define’ script and LMB is the orient one. May be the most convenient way to set this up.
Depending on how your objects to distribute are set up in the file, the script may need to be changed to also remember the reference point, not only base point. For now it assumes the objects ‘sit’ on WorldXY plane.

–jarek

Orient.rui (6.2 KB)

Thank you so much Jarek!

This is working beautifully.

Is there any way this could be made to orient a group of two objects?

The script doesn’t seem to be recognizing a group like the Orientate on surface command does (where you can have a group, pick a base point on one of the objects in the group and then both objects in the group will be orientated) . I am mostly orientating objects that are made out of two solid surfaces one around the other ,I guess I could try to join them into one solid, but just a grouping would be better.

Just to note for other users, the tool tip description of the left and right click for the tool bar button function are reversed.

Thanks again much appreciated.

Hi Flubber,

Yes, I have changed it to accept many objects as orient input. You need to define their base point similar way as before, I also added a second point to be pre-defined and remembered for the orientation direction. It should also pay attention to grouping while picking the objects to place.

Does not look like the functions are reversed in the button, but you can check/edit the toolbar (and also see the scripts sources between the -Runscript ( … ) if you Ctrl+Shift+Click the icon button.

hth,

–jarek

Orient.rui (6.6 KB)

Many thanks for this Jarek!

Yes you’re right tool tips are correct it was my interface color scheme that was throwing me off when looking at the little mouse icon that delineate right and left click.

This is very helpful to me and surely to many others. It will help make the Orientate on surface command more of an in the moment sort of real time “sketching” type tool for toes of us who like to work that way.

I can’t thank you enough!

Jarek, As I am using the Orient script, I am wondering about re-positioning objects that have been already positioned using the command after enter has been pressed and their position has been set.

Is there any way to click on an object that has been positioned on the surface and re-drag it over the surface in-order to make a slight adjustment to its position?

What I do now is after I have placed objects on a surface, and look at their position and I see one that needs to move on the surface slightly, I just run the command again and place a new copy of the object in the desired shifted location and delete the old object.

Thanks

Hi Flubber,

glad the main script works for you. About the re-positioning of placed objects - It should be possible but definitely not as straight-forward to do - since objects in Rhino are not self-aware by default (to some degree they are if using Blocks). Anyway, I may look into it at some point but that is not a quick fix for now.

–jarek

Flubber,

If you want to drift the objects around after positioning on the target surface, you may find it easier to use Flow Along Surface instead. Just make sure history is recording when you flow the objects, and then you can nudge them around in 2D on the source surface and they will updated in 3D on the target surface.

Add a flat surface to your file and name it “Source” and then name your target surface “Target” (without the quotes). Copy this to a button:

_-flowalongsrf Rigid=Yes
_-selname “Source”
_-selname “Target”

Now copy your objects from your palette to the source surface, select the objects (need to pre-select with this macro), and hit the button. Then you can nudge or rotate the source objects and watch the flowed ones update.

Note that in Rhino V5 when you flow grouped objects they position as if you flowed them individually, (IE, if you had six square panels grouped as a cube, they would not form a cube after flowing to a curved surface). In V6 WIP, grouped objects maintain their relationship to each other when flowed (the six panels would still form a cube). In V5 if you want separate objects to maintain their relationship during flow, you can make them a block first.

Very interesting, Thank you Mark. I will have to give that a try.