General InformationThis opening ID can be invoked in two cases:
Input ObjectsInput objects must be of the following types:
Context Object Parameters
Sample 1The following sample illustrates how to automatically prefix conductors with their parent's name when they are instantiated.
Let BranchOldName(String) Let EBG(Feature) Let EBGName(String) Let BranchNewName(String) Let ListBranches(List) Let itr(Integer) Let Sz(Integer) Let SameName(Integer) Let Branch(Feature) let bIsInstantiation(Boolean) Set BranchOldName = ThisObject.Name Set EBG = ThisObject.Owner Set EBGName = EBG.Name Set BranchNewName = EBGName + "\\" + BranchOldName set bIsInstantiation = Parameters.GetAttributeBoolean("IsFeatureBeingInstantiated") Notify("Branch old name = " + BranchOldName) Notify("EBG name = " + EBGName) Notify("Branch new name = " + BranchNewName) Set ListBranches = EBG.Query("Branch","") Set Sz = ListBranches.Size() Set itr =1 Set SameName = 0 for itr while itr<= Sz { Set Branch = ListBranches.GetItem(itr) if(NULL <> Branch) { if(BranchNewName == Branch.Name) SameName = SameName + 1 } } if(0 < SameName) { BranchNewName = BranchNewName + "." + SameName } if(bIsInstantiation == true) BranchNewName = BranchNewName + "_Instantiation" else BranchNewName = BranchNewName + "_Update" Parameters.SetAttributeString("oFeatureName",BranchNewName) Sample 2The following sample illustrates how to ensure name uniqueness. Branches are automatically prefix with their parent's name when they are instantiated. If a name already exists, a number is added to the branch name as postfix. For example, if EBG_10.1_Branch.2 already exists, the name of the new branch is EBG_10.1_Branch.2.1.
Let BranchOldName(String) Let EBG(Feature) Let EBGName(String) Let BranchNewName(String) Let ListBranches(List) Let itr(Integer) Let Sz(Integer) Let SameName(Integer) Let Branch(Feature) Set BranchOldName = ThisObject.Name Set EBG = ThisObject.Owner Set EBGName = EBG.Name Set BranchNewName = EBGName + "_" + BranchOldName Notify("Branch old name = " + BranchOldName) Notify("EBG name = " + EBGName) Notify("Branch new name = " + BranchNewName) Set ListBranches = EBG.Query("Branch","") Set Sz = ListBranches.Size() Set itr =1 Set SameName = 0 for itr while itr<= Sz { Set Branch = ListBranches.GetItem(itr) if(NULL <> Branch) { if(BranchNewName == Branch.Name) SameName = SameName + 1 } }if(0 < SameName) { BranchNewName = BranchNewName + "." + SameName } Parameters.SetAttributeString("oFeatureName",BranchNewName) Sample 3The following sample illustrates how to modify the name of the route of a cable (ElecRoute feature).
Let CableRouteOldName(String) Let CableRouteNewName(String) Let CableRoute(ElecRoute) Let ThisCableRoute(ElecRoute) Let EPSRef(Electrical3DSystem) Let EPSRefName(String) Let Prefix(String) Let bIsInstantiation(Boolean) Let CableOcc(Elec3DCableOccurrence) Let CableName(String) Set ThisCableRoute = ThisObject if (NULL == ThisCableRoute) Notify("Invalid ThisObject") Set CableRouteOldName = ThisCableRoute.Name ThisCableRoute.GetParentEPS(EPSRef) if (NULL == EPSRef) Notify("EPSRef is NULL ") ThisCableRoute.GetCable(CableOcc) if (NULL == CableOcc) Notify("CableOcc is NULL ") Set CableName = CableOcc.Name if (NULL == CableName) { CableName = "" Notify("Cable Name is NULL") } Notify("Cable Name : " + CableName) Set EPSRefName = EPSRef.Name Set Prefix = CableName + "\\" + EPSRefName Set CableRouteNewName = Prefix + "\\" + CableRouteOldName set bIsInstantiation = Parameters.GetAttributeBoolean("IsFeatureBeingInstantiated") Notify("Cable Route old name = " + CableRouteOldName) Notify("EPS name = " + EPSRefName) Notify("Cable Route new name = " + CableRouteNewName) if(bIsInstantiation == true) CableRouteNewName = CableRouteNewName + "_Instantiation" else CableRouteNewName = CableRouteNewName + "_Update" Parameters.SetAttributeString("oFeatureName",CableRouteNewName) |