Notifications
Clear all

[Closed] already created object to instance

I’ve tried to bump the thread in the general max forum, but I’ve got no replies… maybe i’ll have better luck here. I was wondering if there’s a code that coverts existing object into instances… I already have that script; however when applying the objects being turned into instances all move to the master object… so basically the objects would just pile on top of each other when running the script… is there a way to avoid this?

10 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Buy my DVD

Seriously, you should be able to instance the base object of all your objects using any other base object without affecting the position, as instancing means that the node is still independent, only the base object and modifier stack are the same (in the case of References, the base object and 0 or more modifiers are instanced)

The simplest syntax should be

for o in objectsToInstance do o.baseobject = theSource.baseobject

where objectsToInstance is an array of objects to be reinstanced, and theSource is the object you want to instance from.
If there are non-instanced modifiers on your objects, you will get referenced objects instead.

haha thanks bobo… i’m going to try this out… these objects are killing me. And for your dvd… It is in my plans my man… I JUST started with scripts couple days ago and realized it’s pretty fun to work with. Just matter of time finishing this darn internship… then I’ll have time to fiddle with scripts more extensively with your dvd! Thanks again!

hmm i’m getting that no map function for undefined, and I think i’m inputing the source objects in the right places with

for o in objectsToInstance do o.master_flip = theSource.master_flip

what else must i plug in?

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

what is master_flip?

It appears that you are trying to instance MODIFIERS on the stack. I was talking about the BASEOBJECT of the objects. Instancing modifiers can be tricky, depending on their class, their gizmo and center settings, some might not even work at all…

eh that was just a name of the baseobject… i though i was supposed to plug it in? >.<
i’m not sure what the whole script should look like

should it have been?

theSel = Selection as array
for o in objectsToInstance do o.baseobject = theSource.baseobject

???

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

.baseobject is the property that gives you access to (nomen est omen) the base object of a node. If the scene node does not have modifiers on the stack, the resulting nodes will be instances of each other. If the nodes do have modifiers and these modifiers are already instances (because the same modifier was added at the same time to all of them), the resulting nodes will still be instances. If the nodes do have modifiers and some of them are unique, the result will be referenced nodes with the point of reference exactly at the position of the unique modifier.

Note that in my example, I explained what objectsToInstance and theSource are, because they are supposed to be user variables containing the participating objects. The reason I did not explain what .baseobject is is because it is supposed to be a property written as is. Sorry for the confusion.

[color=white]

This is what I think it would be with the referring source object ‘Object02’

theSel = Selection as array
for o in theSel do (
o.Object02=theSource.Object02
)

unfortunately I’m getting “unknown property: “object02” in undefined…”[/color]

Ok cool thanks bobo… so I t hink the script should be something like this?

theSel = Selection as array
for o in theSel do (
o.baseobject = Object02.baseobject
)

Buit I still get the error of ‘unknown property: “baseObject” in undefined.
Man… I suck at this

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

have you defined Object02 ?
Is this a variable or an object name?

I said twice explicitly in my posts that I am using user variables that contain objects and it is up to you to define them.

If the object you are using is really CALLED Object02, you would say

 theSel = Selection as array
   for o in theSel do o.baseobject = $Object02.baseobject --use $ to denote object path

instead.

Otherwise you would say

 theSel = Selection as array
Object02 = $Teapot01 --ASSIGN some object to the variable Object02
   for o in theSel do o.baseobject = Object02.baseobject

Or you could let the user pick an object interactively

 theSel = Selection as array
 Object02 = pickObject()
if isValidNode Object02 do (
    for o in theSel do 
     o.baseobject = Object02.baseobject
)--end if

My bad. I assumed you had basic knowledge of MAXScript.
Hope this helps.

[left]Many thanks Bobo, yes, I lack even the basic scripting knowledge and just trying to piece it together for my current project… I will pick up on the basics as soon as my project is over. Thanks again Bobo, you’re the best[/left]