Notifications
Clear all

[Closed] Pivot transfer between objects

Hi,

I stepped recently into MAXScript which I find very exciting.
I have good knowledge about C programming, so MAXScript doesn’t look too complex.

By simplifying my need let’s say:
I have 2 identical objects on a scene, with different position/angle orientation, but with both having the pivot in the exact same orientation (centered to the object and the axis in the same orientation). My goal is to copy the pivot position from the 1st object and paste it to the 2nd object, so that at the end despite the different position/angle they have the same relative pivot placement.

Does it sounds something easy to achieve? What would be the main commands to be used?

My current idea is:

  1. select first object
  2. copy the angle position of its pivot and store it into variables
  3. select second object
  4. paste (absolute value) the stored values into the 2nd object.

I tried to look for a comprehensive list of MAXScript commands but I was unsuccessful so far, but I think to understand that the “Node Transform Properties” should help me.

Thank you so much in advance for your input!

10 Replies

a very good discussion of aligning pivots is in this thread

a very good discussion of aligning pivots is in this thread

In the future the best way will probably be to use an Xform modifier instead. That will keep the pivot, but all transforms will happen at the sub-object level.

Moving pivots after the fact can be dangerous depending on what you are trying to do and how your scene is setup.

-Eric

2 Replies
(@gazybara)
Joined: 11 months ago

Posts: 0

I saw suggested thread by Mambo4 but still not 100% working solution.
Can you show your method if you are not busy?

(@pixel_monkey)
Joined: 11 months ago

Posts: 0

My solution doesn’t address the issue at hand, but can possibly prevent the need in the future. Xform is like moving something in Edit/Editable Poly/Mesh, however because it is a modifier you have access to a gizmo that can be moved, animated, etc.

-Eric

what is the task? align pivot of one object (source) to pivot of another (target) without changing the source’s object transformation?

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Yep.Similar as Affect Pivot

Thank you for your preliminary replies. Sounds like my task is harder than anticipated.

My specific need comes from a tedious process that I am currently doing manually, and therefore trying to automate.
I am importing 3D models into Max which originated from a CAD software that does not have the pivot concept. These models are composed by hundreds of objects, a bunch of which are identical, but with different location/orientation.
When I import them into Max they all get a new pivot assigned which is centered in the object with the 3 pivot axis set as the world axis.
My end goal is to replace all these parts with more accurate objects remodeled by me in Max. An automatic replacement process could be easily done with existing scripts (Soulburnscripts) if the pivots were properly set.
But since, despite their different orientation they all have the same pivot orientation I need first to fix that.
That’s why my idea was, using “master objects” which have correctly positioned pivots, to copy their pivot to all the identical objects, in order to allow me later to start the replacement process.

Now that I am thinking more about it I realize that my task is in fact more complex, since what I really need is to copy not the absolute pivot position, but its relative position compared to the object itself 😮 😮

Anybody still following me? I guess I really need inputs because at the moment I’m quite lost :banghead: and not even sure it is doable or easily doable.

Folks, any input is welcome, thanks a lot !

hopefully i didn’t forget anything:

fn alignPivots source target pos:on rot:on = if isvalidnode source and isvalidnode target do
(
	if pos do source.pivot = target.pivot
	if rot do
	(
		worldAlignPivot source
		rotation = inverse target.objecttransform.rotation
		in coordsys local source.rotation *= rotation
		source.objectoffsetrot *= rotation
		source.objectoffsetpos *= rotation		
	)
)

delete objects
s = dummy name:"source" pos:[20,0,0] rotation:(eulerangles 45 60 80) isselected:on
t = dummy name:"target" pos:[0,0,20] rotation:(eulerangles -78 45 60)
alignPivots s t --pos:off rot:off

Denis,

thanks a lot for your input: I tested it and does exactly what it is meant to do.
Even thought it turns out it is not exactly what I need, it is very helpful for me to learn how to work on pivot transformations.

As mentioned before my task turns out to be quite challenging.
I basically need to reconstruct the pivot for an object that gets imported into Max (without a pivot) in any possible position.

Since in the scene I do have a identical sample object with correct pivot my current idea is to move the object in the same spot and rotate it until its vertices are matching 100%(corresponding vertices have unfortunately different #). At that point the pivot can be copied and its original position restored. Easier to say than to do, though. :curious:

Ideas are of course welcome…