CATPackageGenerativeKnowledgeTypes Methods:TemplateInstance.SetReplacingComponent()

This method lets you indicate the replacing components of an engineering template having "To Replace" components. Make sure the replacing component fits in its new context before using the method. No failure message is provided in case of error. Use this method before setting the template inputs.

This page discusses:

Signature

TemplateInstance.SetReplacingComponent(iToReplace : Feature, iReplacing : Feature)

Arguments

NameInput/OutputRequired?TypeComment
iToReplaceInYesFeatureOriginal object pointed by the template.
iReplacingInYesFeatureObject 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)