Maxscript: Make referenced objects unique

Maxscript: Make referenced objects unique

KasperFilipsen
Enthusiast Enthusiast
1,962 Views
9 Replies
Message 1 of 10

Maxscript: Make referenced objects unique

KasperFilipsen
Enthusiast
Enthusiast

I’m having trouble with something I figured would be trivial to achieve with the built-in functions.

I have a bunch of reference objects, which I would like to turn unique, without affecting the modifiers on top.

But for some reason I can’t get InstanceMgr.MakeObjectsUnique function to work. It works fine on instances, but not on references.
The InstanceMgr.CanMakeObjectsUnique also returns false, whenever I try it on a reference.

I’ve also tried to use the MakeControllersUnique and the MakeModifiersUnique just to see if that made a difference. The modifiers can be turned unique just fine.

How would I go about turning all my reference unique?

0 Likes
1,963 Views
9 Replies
Replies (9)
Message 2 of 10

denisT.MaxDoctor
Advisor
Advisor

This task is fraught with certain difficulties, since the "reference" node is technically already unique due to the state of the node object. But part of its object reference is "shared" by other nodes (objects). So... let's use the simplest solution first (but in some cases it may not be quite right):

fn makeNodeUnique node =
(
	temp = copy node
	instancereplace node temp
	delete temp
	ok
)
-- makeNodeUnique $
Message 3 of 10

KasperFilipsen
Enthusiast
Enthusiast
Sadly, that won't solve my issue. I need to make the baseObject unique and keep the modifiers intact, since I have objects with skinning and different links to dummies etc.
For my current project, I think I could probably get away with simply making a copy of each object to break the instance link, but I would very much prefer to find a more permanent solution.

It's a bit frustrating that making an object unique by right clicking the baseObject in the Modify panel doesn't show up in the listener and if you do it in the TrackView it's an ActionMan script that gets recorded, which I don't know of any way to see the content of.
0 Likes
Message 4 of 10

denisT.MaxDoctor
Advisor
Advisor

@KasperFilipsen wrote:
Sadly, that won't solve my issue. I need to make the baseObject unique and keep the modifiers intact, since I have objects with skinning and different links to dummies etc.
For my current project, I think I could probably get away with simply making a copy of each object to break the instance link, but I would very much prefer to find a more permanent solution.

do you mean that only BaseObject is referred in your case?

 

0 Likes
Message 5 of 10

KasperFilipsen
Enthusiast
Enthusiast
Yes, only the BaseObject is a reference. All modifiers are applied on top of the reference.
0 Likes
Message 6 of 10

denisT.MaxDoctor
Advisor
Advisor

 

 

fn makeNodeUnique node =
(
	temp = copy node
	keep = #()
	while node.modifiers.count do 
	(
		append keep node.modifiers[1]
		deletemodifier node 1
	)
	InstanceMgr.MakeObjectsUnique node #individual
	collapsestack node
	for k = keep.count to 1 by -1 do addModifierWithLocalData node keep[k] temp temp.modifiers[k]
		
	delete temp
	ok
)

(
	suspendEditing()
	makeNodeUnique $
	resumeEditing()
)

 

 

may work in your case, but this solution is also not universal

 

0 Likes
Message 7 of 10

KasperFilipsen
Enthusiast
Enthusiast

Just tested it. It seems to do exactly what I need. Thanks a bunch Denis!

 

As a small side question, I see you are using suspendEditing(). What is the difference between using that or using disableSceneRedraw() ?

I'm assuming, suspendEditing speeds up doing edits in the modify panel, without max having to show what is going on?

0 Likes
Message 8 of 10

denisT.MaxDoctor
Advisor
Advisor

suspendEditing() is more complex than just disabling redraw. It temporarily disables some of the messages and notifications associated with updating the command panel and call them all with resumeEditing().
On the other hand, the suspendEditing() function is less dramatic than the disableRefMsgs() function.

Calling suspendEditing/resumeEditing is not required unless an edited node is selected or the Modify panel is open.

0 Likes
Message 9 of 10

KasperFilipsen
Enthusiast
Enthusiast

I'm reopening this topic.

The more I think about it the more interested I am in having a more universal solution.

 

The only method I can think of, would be to do it via the interface and simulate clicking on the Make Unique button in the modify panel. Which is honestly a terrible solution, but I'm a bit lost on alternatives.

Is there a more fool proof method to do this?

0 Likes
Message 10 of 10

denisT.MaxDoctor
Advisor
Advisor

That's not fair. I have not yet received a "solution" to my previous answers, and you are already asking new questions. 😉

0 Likes