Naming Rule

This rule enables you to define the name of the input list of Manufactured Items.

This page discusses:

General Information

This rule is invoked during the Applying Naming rule command.

Input Objects

Inputs for the rule must be of the following type:

Parameters corresponds to the context object.

The Parameter input object has one input registered in it:

ListOfSelections
This stores a list of Manufactured Items.

Sample

The following example explains how to define the name of the input Manufactured Item based on the assigned product or scope of the product.

/* Naming Rule */
let ProcOcc(MfgProcessOccurrence)
let RootProcOcc(MfgProcessOccurrence)
let ProcRef(DELFmiFunctionReference)
let ProcInst(DELFmiFunctionInstance)
let ProductOcc(ProductOccurrence)
let ListOfAssignedProducts(List)
let PartReference(VPMReference)
let PartInstance(VPMInstance)
let ListOfIPMInst(List)
let IPMRef(VPMReference)
let IPMInst(VPMInstance)
let RootMARef(PLMCoreReference)
let nbOfIPMInst(Integer)
let iListOfSelection(List)
let NewProcessName(String)
let UniqueKey(String)
let PartName(String)
let i(Integer)
let j(Integer)
let NameSize(integer)
let nbOfSelections(Integer)
let nbOfObjects(Integer)

set iListOfSelection = Parameters.GetAttributeObject("ListOfSelections")
set i=1
set j=1
set nbOfSelections=iListOfSelection.Size()

/* Apply naming rule on selections */
for i while i<=nbOfSelections
{
	ProcOcc=iListOfSelection[i]	
	if(ProcOcc <> NULL)
	{
		set ProcRef = ProcOcc.Reference
		set ProcInst = ProcOcc.Instance
		/* If selected process is children of root process, get assigned product according to process occurrence*/
		if(ProcInst <> NULL)
		{
			set ListOfAssignedProducts = ProcOcc.AssignedProduct
set nbOfObjects = ListOfAssignedProducts.Size()
			if(nbOfObjects > 0)
			{
				set ProductOcc = ListOfAssignedProducts.GetItem(1)
				if(ProductOcc <> NULL)
				{
					set PartReference = ProductOcc.Reference
				}
			}
		}
		/* If selected process is root, get product according to product scope*/
		else if(ProcRef <> NULL)		
			set PartReference =ProcRef.GetProductScope()
		/*If we can get product reference, change process name*/
		if(PartReference <> NULL)
		{
			UniqueKey = GetUniqueKey("DELFmiProcessInstanceSample")
			NewProcessName=PartReference.V_Name+UniqueKey
			NameSize=NewProcessName.Length()
			
			/*If New process name size is over 100, extract name*/
			if (NameSize>100)
			{
				NewProcessName=NewProcessName.Extract(0,96)+ "..."
			}
			
			if(ProcRef <> NULL)
				ProcRef.V_Name=NewProcessName
			if(ProcInst <> NULL)
				ProcInst.PLM_ExternalID = NewProcessName
		}
		
		/*Try to Change IPM Name*/
		set IPMRef = ProcOcc.ProcessOutput
		if(IPMRef <> NULL)
		{
			// Try to Get Root MA once
			if(RootProcOcc == NULL)
			{
				set j =1
				set RootProcOcc = ProcOcc.Owner
				for j while j > 0
				{
					if(RootProcOcc.Owner <> NULL)
					{
						set RootProcOcc = RootProcOcc.Owner
					}
					else
						break
				}
			}
			
			//Try to get IPM Instances
			if(RootProcOcc <> NULL)
			{
				set RootMARef = RootProcOcc.ProcessOutput
				set ListOfIPMInst = IPMRef.ListInstances(RootMARef)
				set nbOfIPMInst = ListOfIPMInst.Size()
			}
set j =1
			for j while j<=nbOfIPMInst
			{
				set IPMInst = ListOfIPMInst[j]
				if(IPMInst <> NULL)
					IPMInst.PLM_ExternalID = NewProcessName
			}
			IPMRef.V_Name=NewProcessName
		}
	}
}