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

Is there a way for mating of an entire group rather than a single object? When I run your script and try to mate a group of object to a target surface, only the surface I click first is being affected, whereas the remaining objects of the group stay unchanged.