General InformationThis action rule is invoked when you click the Naming Rule command. Input Objects
In the attribute table, you can check the attributes type and their description.
SampleThe following example shows how to get the attributes. You can use this example to make another script in the action rule. /* PrdOcc = ProductOccurrence iSddPlate = SddPlate */ //the reference of input product occurrence let iPrdRef(VPMReference) //the output of string attribute let sMaterial(String) let sMaterialName(String) let sMaterialGrade(String) let sSection(String) let sThickness(String) let sSupportName(String) let sProjectID(String) let sWeight(String) // the output of real attribute let rThickness(Real) let rWeight(Real) //the length of string let iSize(Integer) //the index to know devide point let idx(Integer) //Get Reference from input product occurrence iPrdRef=PrdOcc.Reference //Check reference is exist if(iPrdRef <> NULL) { /////////////////////////////////////// //1.1.1.1 Material Name, Material Grade /////////////////////////////////////// //Check reference has attribute "V_StrMaterial" //User can see this "V_StrMaterial" as "Material" in attribute tab if(iPrdRef.HasAttribute("V_StrMaterial") == TRUE) { //If "Material" attribute is exist, get attribute sMaterial=iPrdRef.GetAttributeString("V_StrMaterial") } //Get the length of material string iSize=sMaterial.Length() // Search material string have " " and get index of devide point idx=sMaterial.Search(" ") //If there's no " " pattern in string, idx value is -1. So, get material name and grade //in case of success if(idx <> -1) { //Extract starting 0 point to devide point of string sMaterialName=sMaterial.Extract(0,idx) //Extract devide point to last point of string sMaterialGrade=sMaterial.Extract(idx,iSize) //Message pops up with the result of Material Name and Material Grade Message("Material Name: ", sMaterialName) Message("Material Grade: ", sMaterialGrade) } else { //If there's no devide point, it need to handle xception handling //Message pops up with Material string Message("Material: ", sMaterial) } /////////////////////////////////////// //1.1.1.2 Section /////////////////////////////////////// //Check reference has attribute "V_StrSection" //User can see this "V_StrSection" as "Section" in attribute tab if(iPrdRef.HasAttribute("V_StrSection") == TRUE) { //If "Material" attribute is exist, get attribute sMaterial=iPrdRef.GetAttributeString("V_StrSection") } //Then, user can use “Section” attribute as he wants /////////////////////////////////////// //1.1.1.3 Thickness /////////////////////////////////////// //Check reference has attribute "V_StrThickness" //User can see this "V_StrThickness" as "Thickness" in attribute tab if(iPrdRef.HasAttribute("V_StrThickness") == TRUE) { //If "Thickness" attribute is exist, get attribute rThickness=iPrdRef.GetAttributeReal("V_StrThickness") //Convert real value rThickness to string value sThickness sThickness=ToString(rThickness) } //Then, user can use “Thickness” attribute as he wants /////////////////////////////////////// //1.1.1.4 SupportName /////////////////////////////////////// // If selected element is exist if(iSddPlate <> NULL) { // Get SupportName attribute from selected SddPlate feature sSupportName=iSddPlate.SupportName } //Then, user can use “SupportName” attribute as he wants /////////////////////////////////////// //1.1.1.5 Project ID /////////////////////////////////////// //Check reference has attribute "Project ID" //User can see "Project ID" in attribute tab if(iPrdRef.HasAttribute("Project ID") == TRUE) { //If "Project ID" attribute is exist, get attribute sProjectID=iPrdRef.GetAttributeString("Project ID") } //Then, user can use “Project ID” attribute as he wants /////////////////////////////////////// //1.1.1.6 Block, Unit, PositionNumber, PartSequence, Location /////////////////////////////////////// //User can get these attribute like Project ID example. Just change “Project ID” element to customer extension /////////////////////////////////////// //1.1.1.7 Weight /////////////////////////////////////// // If selected element is exist if(iSddPlate <> NULL) { // Get Weight attribute from selected SddPlate feature rWeight=iSddPlate.Weight //Convert real value rThickness to string value sThickness sWeight=ToString(rWeight) } } |