How to align two objects

:sweat_smile: I want to apologize, it is a script and still in WIP, I started because sometimes I have parts in space and need to be orientated, so I’m trying to assembly as usually in other softwares, but I’m starting to learn python so I can tell you that my script is not professional.
I can share a part of it, at least it could serve to orient face of a part against face of other part. Hope it helps

Update2: clearer messages for target and reference, continuos option.

carrot_WIP2.py (3.9 KB)

3 Likes

It works wonderfully! :slight_smile: I see that the WIP version you shared has only 3 of the several options for orienting that you showed in your videos, but it’s still quite usable. Thanks! :slight_smile:

PS: I would just suggest to update the command prompts to each step so that they mention the words “reference” and “target”, in a similar fashion as the “Align objects” tool (I actually added your script as a RMB function to the latter). Currently, the command prompt says “Select a flat surface to orient” for both, the reference and target faces. It would be easier to me to understand these if they were: “Select a flat reference surface to orient” and “Select a flat target face”, respectively. :slight_smile:

Thanks for your advice, as I understand how it works I forgot to give clear instructions, I will update it to make it easier to understand and I just found that the script can not be used 2 times the same option, so I’ll fix it too and update it.

Question, wich is the correct way to update it? Editing the comment where I uploaded it or a new comment with a new file.
(Already updated in the same last comment)

Yes, I have other options but I’m trying to figure it out how these should work. And I consider these 3 are used more often.

1 Like

Also, I noticed that when using the “Concentric” option to orient cylinders and pipes, for example, the command prompt still asks to pick a flat surface. It could be replaced with context-based prompts such like “Select a flat surface to orient” (or “Select a cylindrical surface to orient”) and “Select a flat target face” (or “Select a cylindrical target face”) depending on whether the geometry to pick must be flat or cylindrical.
I tried it several more times with different kind of geometry and it works really nice every time. :slight_smile:

You can upload a new WIP version in a newer post, because that will notify more people to come and check the topic, as well as will allow them to try the older version if they are curious to compare the changes. :slight_smile:

1 Like

I’ve changed the name from " concentric" to "point coincident " and this is the WIP3 correcting a message in orienting and mating options

carrot_WIP3.py (3.9 KB)

5 Likes

The good thing about the “Mating” option is that it could also align the tangent of two cylinders. This is a very valuable option for engineering projects. :slight_smile: Is there a way to be able to pick a specific point on both (with Osnap turned on), the reference surface and target surface?
Example: If I want to orient cylinder A next to cylinder B so that they share the picked points? Also, an option to pick the tangent seams of cylinders, in order to orient two cylinders with their seams touching together?

PS: I figured out that the orient will not work 100% of the time as expected. For example, if one cylinder is higher than another one and they both share the same orientation (like parallel top and bottom faces), the script can’t align them along their concentric body by picking their flat faces in a similar fashion like in Solidworks (1:30 minute of my video below). Of course, I don’t expect from a script to be as advanced as the mating engine of SW, though it’s good enough for many applications even in its current WIP state. :slight_smile:

Carrot orient.3dm (71.7 KB)

I recorded a short video showing what I mean:

1 Like

I think that is possible, the 3 options current available in the script weren’t done aiming to cilindrical faces, that’s the reason I changed “concentric” to “point coincident”

I have an option that can align the axis of both cilinders, but trying to figure it out how should it work, your video helps me to understand, thanks.

4 Likes

this is so cool man! i do appreciate you posting this tool as well as you being open to ideas from others.

just don’t forget to keep some functionality out of our hands so you can release a full version for some cash. :wink:

3 Likes

Hello again,

Forgive me for my absence but my license ended and I had no way to check your script.
Although I did not test it on the normal project, my tests make me believe that this is the solution to my (and not only mine) problem. Now, I totally understand the joy of @kleerkoat @Rhino_Bulgaria and others. :slight_smile:

I noticed that your tool gives more precision than the one from Revit. Looks like the program matches not only surfaces but the pick points as well.

I have two questions:

  1. What is the difference between mating and orienting? I noticed that the latter places the object at some distance from the chosen plane.

  2. Is it possible to create “lite version” with only mating? I tried to edit the script myself but it didn’t work.
    It would be good to skip two steps:
    a. click on the script button
    b. choose command ← can we skip this?
    c. pick two planes
    d. choose command again ← can we skip this?

Orienting. Is designed to orient a part almost in its own site.
Mating. Will orient and translate the part to make coincident the picked points, fast way, but without snapping.
Point coincident. This is orienting part and snapping position point to point.

1 Like

:yum: at some point ,I will continue with carrot, to make it work better, by the moment, meet “Barley”, “Corn”, “Rice” , “Oats”, “Rye” etc…that are other scripts. These help me when, hole making, assign material, getting weight of parts and assemblies, Bill of materials etc… These are oriented to tool and die and mold design.

1 Like