You could try running the attached script (but don't look at it, it's rather
old).
Just select the instances you want to replace, run the script, and pick the new
master model. Doesn't work if you have animations on your instances though.

cheers,
Thomas

> David Saber <davidsa...@sfr.fr> hat am 17. Oktober 2013 um 13:45 geschrieben:
>
>
> Thank you Nono
> After a search in the mailing list archive, I have already tried this,
> but it didn't work... I'm sure I did something wrong.
> I guess both master models must have the same name? If that's possible.
> I'll test this again.
> Greetings,
> David
>
import win32com.client
from win32com.client import constants as c
null = None
false = 0
true = 1
TRUE = True
FALSE = False
xsi = Application
log = xsi.LogMessage


def 
doIt(mode,move2p,type,matchAll,matchTrans,matchRot,matchScale,move2part,makeChild,matchGrp):
    #Target Objects
    liste = xsi.Selection
    sel = []
    for i in liste:
        sel.append(i)
    pick = xsi.PickElement('','Pick Object')
    #Object to be copied
    pickedObj = pick.Value("PickedElement")
    pickParent = pickedObj.Parent
    
    for target in sel:
        parent = target.Parent

        #Copy, Clone or Instance
        if type.Value == 1:
            source = xsi.Duplicate(pickedObj, "", 2, 1, 1, 0, 0, 1, 0, 1, "", 
"", "", "", "", "", "", "", "", "", 0)
        elif type.Value == 2:
            source = xsi.Clone(pickedObj, "", 1, 1, 0, 0, 1, 0, 1, "", "", "", 
"", "", "", "", "", "", "")
        elif type.Value == 3:
            source = xsi.Instantiate(pickedObj, "", 1, 1, 0, 1, "", "", "", "", 
"", "", "", "", "", "")
        
        #Move to parent
        if move2p.Value == True:
            if str(pickParent) != str(parent):
                xsi.CopyPaste(str(source), "", str(parent), 1)

        #Make Child
        if makeChild.Value == True:
            xsi.CopyPaste(str(source), "", str(target), 1)
        
        #Match Transforms
        if matchAll.Value == True or (matchTrans.Value==True and 
matchRot.Value==True and matchScale.Value==True):
            xsi.MatchTransform(source, target, "siSRT", "")
        else:
            if matchTrans.Value == True:
                xsi.MatchTransform(source, target, "siTrn", "")
            if matchRot.Value == True:
                xsi.MatchTransform(source, target, "siRot", "")
            if matchScale.Value == True:
                xsi.MatchTransform(source, target, "siScl", "")
                
        #Match Partitions
        if move2part.Value == True:
            owners = target.Owners
            for owner in owners:
                if str(owner.Parent.Type) == "Pass":
                    xsi.MoveToPartition(owner, source)

        #Match Groups
        if matchGrp.Value == True:
            owners = target.Owners
            for owner in owners:
                if str(owner.Type) == "#Group":
                    xsi.SIAddToGroup(owner, source)
                
        
        #Hide or Delete
        if mode.Value == 2:
            xsi.ToggleVisibility(target, "", "")
        elif mode.Value == 3:
            xsi.DeleteObj(target)



def gui():
    oPSet = 
xsi.ActiveSceneRoot.AddProperty("CustomProperty",False,"tv_Replace") 
    oLayout = oPSet.PPGLayout
    


    #Hide Delete None
    mode = oPSet.AddParameter3("Target", c.siInt4)
    modus = ["no change",1,"hide",2,"delete",3]
    oLayout.AddEnumControl("Target", modus,"Target", c.siControlRadio)
    xsi.SetValue(mode, 3)

    #Move to Parent
    move2p = oPSet.AddParameter3("Move_to_parent",c.siBool)
    merge = ["",1]
    oLayout.AddEnumControl("Move_to_parent", merge,"", c.siControlBoolean)
    xsi.SetValue(move2p, FALSE)

    #Make Child
    makeChild = oPSet.AddParameter3("Make_Child",c.siBool)
    merge = ["",1]
    oLayout.AddEnumControl("Make_Child", merge,"", c.siControlBoolean)
    xsi.SetValue(makeChild, FALSE)
    
    #Match Partition
    move2part = oPSet.AddParameter3("Match_partitions",c.siBool)
    oLayout.AddEnumControl("Match_partitions", merge,"", c.siControlBoolean)
    xsi.SetValue(move2part, FALSE)

    #Match Groups
    matchGrp = oPSet.AddParameter3("Match_Groups",c.siBool)
    oLayout.AddEnumControl("Match_Groups", merge,"", c.siControlBoolean)
    xsi.SetValue(matchGrp, FALSE)

    #Type select
    type = oPSet.AddParameter3("Type", c.siInt4)
    xyz = ["copy",1,"clone",2,"instanciate (Models only)",3]
    oLayout.AddEnumControl("Type", xyz,"Type", c.siControlRadio)
    xsi.SetValue(type,3)
    
    #Match
    matchAll = oPSet.AddParameter3("MatchAll",c.siBool)
    tmp = ["",1]
    oLayout.AddEnumControl("MatchAll", tmp,"", c.siControlBoolean)
    xsi.SetValue(matchAll, TRUE)
    
    matchTrans = oPSet.AddParameter3("MatchTranslation",c.siBool)
    tmp = ["",1]
    oLayout.AddEnumControl("MatchTranslation", tmp,"", c.siControlBoolean)
    xsi.SetValue(matchTrans, False)
    
    matchRot = oPSet.AddParameter3("MatchRotation",c.siBool)
    tmp = ["",1]
    oLayout.AddEnumControl("MatchRotation", tmp,"", c.siControlBoolean)
    xsi.SetValue(matchRot, False)
    
    matchScale = oPSet.AddParameter3("MatchScale",c.siBool)
    tmp = ["",1]
    oLayout.AddEnumControl("MatchScale", tmp,"", c.siControlBoolean)
    xsi.SetValue(matchScale, False)
    
    buttonPressed = xsi.InspectObj(oPSet, "", "Check it out", c.siModal,FALSE)
    
    return 
oPSet,buttonPressed,mode,move2p,type,matchAll,matchTrans,matchRot,matchScale,move2part,makeChild,matchGrp

def main():
    
oPSet,buttonPressed,mode,move2p,type,matchAll,matchTrans,matchRot,matchScale,move2part,makeChild,matchGrp
 = gui() 
    
    if buttonPressed == FALSE:
        xsi.LogMessage("OK")
        
doIt(mode,move2p,type,matchAll,matchTrans,matchRot,matchScale,move2part,makeChild,matchGrp)
    else:
        xsi.LogMessage("Cancel") 
    
    xsi.DeleteObj(oPSet)


main()

Reply via email to