3DC 7.2 : Script to Snap 2 objects?

As I cannot with 7.1 select different objects, I started with a script which rotates an object to make the first selected face in the same plane as the current position of the second face.

[img:gqgt4hkd]http://img9.imageshack.us/my.php?image=image14u.jpg[/img:gqgt4hkd]
[img:gqgt4hkd]http://img9.imageshack.us/img9/1349/image14u.th.jpg[/img:gqgt4hkd]

I borrowed ArcCos from Paul’s ShiftGroupAndAnimations.

Hello,

With the new selection method in 7.2, it is possible to select 2 faces, each one from a different object.

I am considering writing a script which would snap a face of an object on the face of another object (Eventually the 2 objects will ‘stick’ together on the 2 faces).

Say I want to snap object B on object A.
I select face Fa from object A and face Fb from object B.
The purpose is to move object B so that Fb is facing and against Fa.

I guess the NormalID will easily give the normals of the 2 selected faces.
Then it becomes more complicated…

There is a need to rotate B computing a rotation from normal of B to opposite of normal of A (so that object are facing each other). Then a translation of object B so that Fa and Fb coincide.

To compute this rotation, is there a useful example / hint in an existing plug-in or in 3DC code?
I can compute the rotation axis of B and the angle using the 2 normals of A and B (vector product and scalar product).

And then, what is the best way to apply the rotation to the object? Apply the rotation to each point of B?

My rivets plugin does something like that, orienting the object to the face normal.

I’ll dig out the code some time soon.

You must be logged in to reply in this thread.