General InformationThis rule is invoked during the Automatic Resource Assignment command. Input ObjectsInputs for the rule must be of the following type: Object of type: MfgProcessOccurrence Parameters correspond to the context object. The Parameter input object has two Inputs registered in it: ListOfResourcesWho, which is of type List and stores list of Resource of category, Who, ListOfResoucesWith, which is of type List stores list of Resource of category, With It also has three outputs registered in it: ResourceWho, which is of type List and stores list of Resource of category, Who ResourceWith, which is of type List and stores list of Resource of category, With ResourceWhere, which is of type ResouceOccurrence and stores resource object of category, Where. SampleThe following example explains how to assign resources based on entries in the Description attribute of the input Operation object. /* Resource Rule */ let hOperationRef(PLMOperation) let nbOfItems(Integer) let ii(Integer) let ListOfResources(List) let ListOfResourceNames(List) let nbOfResources(Integer) Let hResourceOcc(ResourceOccurrence) Let hResourceInst(VPMInstance) Let hResourceWhere(ResourceOccurrence) let ListOfResourceWho(List) let Description(String) let SplitDescription(String) let lengthOfDescription(Integer) let ListOfDescriptions(List) let ContinueWhile(Integer) let oIndex(Integer) if(ihOperationOcc <> NULL) { set hOperationRef = ihOperationOcc.Reference if(hOperationRef <> NULL) { set Description = hOperationRef->GetAttributeString("V_description") if(Description.Length() > 0) { /* Worker_V249524_InStation50.1;forklift-small_InStation50.1; */ set ContinueWhile = 0 for ContinueWhile while ContinueWhile <> -1 { set oIndex = Description.Search(";", 0, true) if(oIndex == -1) { set ContinueWhile = oIndex ListOfDescriptions.Append(Description) } else { set SplitDescription = Description.Extract(0, oIndex) set lengthOfDescription = Description.Length() set Description = Description.Extract(oIndex+1, lengthOfDescription-oIndex-1) ListOfDescriptions.Append(SplitDescription) } } } } } /* Resource Rule */ /* Retrive working resources using PLM_ExternalID */ set nbOfItems = ListOfDescriptions.Size() if(nbOfItems > 0) { /* Get working resource list and then appned PLM_ExternalID from it */ set ListOfResources = Parameters->GetAttributeObject("ListOfResourcesWho") set nbOfResources = ListOfResources.Size() set ii=1 for ii while ii<=nbOfResources { set hResourceOcc = ListOfResources.GetItem(ii) if(hResourceOcc <> NULL) { set hResourceInst = hResourceOcc.Instance if(hResourceInst <> NULL) { ListOfResourceNames.Append(hResourceInst.PLM_ExternalID) } } } /* Compare with PLM_ExternalID. If it is same, append to the list */ set ii=1 for ii while ii<=nbOfItems { set Description = ListOfDescriptions.GetItem(ii) set oIndex = ListOfResourceNames.IndexOf(Description, 1) if(oIndex > 0) { ListOfResourceWho.Append(ListOfResources.GetItem(oIndex)) } } if(ListOfResourceWho.Size() > 0) { Parameters->SetAttributeObject("ResourceWho", ListOfResourceWho) } } /* Retrieve Where resource from Who resource*/ if(ListOfResourceWho.Size() > 0) { set hResourceOcc = ListOfResourceWho.GetItem(1) if(hResourceOcc <> NULL) { set hResourceWhere = hResourceOcc.Owner if(hResourceWhere <> NULL) { Parameters->SetAttributeObject("ResourceWhere", hResourceWhere) } } } |