Home Technical Talk

maxscript - copy vars from referencetarget

polycounter
Offline / Send Message
rollin polycounter
heyho,

my problem is I have a custom referencetarget object (tool provided by someone else)

this reference target has a bunch of vars .. like .name .color .allowexport and so on..


not how can I copy all the values of these vars from one instance of such an referencetarget to another.

let's say I have the vars a and b .. I can say b.name = a.name
that works.. but can I iterate through all vars in some way?

just saying b = a doesn't work.. it makes b = a but the connection to the original "object" is lost.. making b to b* and b != b*
a and b are connected to nodes somehow

talking about ogremax btw and its ogremax object settings

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    I don't have Ogremax, but there's a couple of things you can try.

    b = copy a

    This may prevent the problem you have with b = a.

    showproperties a

    This might show you all the properties so you can copy them manually.
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    You can also use the result (array) of showProperties (there's also showPropNames or something) to hack up an execute() loop so you wouldn't need to manually copy everything.
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    showproperties has some partner functions too - getproperty, setproperty, isproperty and hasproperty.

    So you can say, theprops = getpropnames obj, then iterate over that array of names for your source object, store the properties and their values in arrays - then do the same for the target and check if isproperty obj #theropertyname then reapply the value to it, bada-bing.

    Hope that mini wall of text helps. :)
Sign In or Register to comment.