Signature
TemplateInstance.SetReplacingComponent(iToReplace : Feature, iReplacing : Feature)
Arguments
Name | Input/Output | Required? | Type | Comment |
iToReplace | In | Yes | Feature | Original object pointed by the template.
|
iReplacing | In | Yes | Feature | Object that is going to replace the original object.
|
Example
In the example below, an engineering template is instantiated under the current root, and the script replaces two references contained in the engineering template by new ones.
/*The following script replaces two references contained in the template by newly created ones:
In this sample you instantiate an Engineering Template under the current editor root
and replace some references within the template by newly created references */
let ref,ref1,ref2(Feature)
let templateInstantiatedRoot(Feature)
ref = GetEditorRoots("VPMReference")->GetItem(1)
let tmp(TemplateInstance)
let lToReplace(List)
tmp = InstantiateTemplate("Template",ref)
lToReplace = tmp.ComponentsToReplace
ref1=lToReplace[1]
ref2=lToReplace[2]
tmp->SetReplacingComponent(ref1,new("VPMReference","MaRef1",NULL))
tmp->SetReplacingComponent(ref2,new("VPMReference","MaRef2",NULL))
EndModifyTemplate(tmp)