Introduction
Purpose : color 3D objects
Different actions :
- Color pipe
- Color insulations
Color pipe - post processing
Code Example1 : simple : Color pipe based on lineID Name (all hardcoded in the rule)
let iRefLineID(String) let iPipe(Piping_Rigid_Pipe) iRefLineID=iRef->GetLineIDName() iPipe=iRef.Reference if (iRefLineID == ("PL001")) { iPipe.SetColor(255,255,128) } else if (iRefLineID == ("PL002")) { iPipe.SetColor(255,128,68) } else if (iRefLineID == ("PL003")) { iPipe.SetColor(128,128,192) }
Code Example2 : advanced : Color Pipe based on LineId Fluid Name (from Techno table)
/* Prototype: (Void) : #Void */ /* Requirement: This code relies on an additional column in the fluid table (OutfittingColor) */ /* OutfittingColor column will contain the RGB color code for each fluid */ /* Comment: Mind switching ON action's property 'No dialog box when running an action without argument' */ let MessageCatalogName(String) let MessageContent(String) let RootOccurrence(ProductOccurrence) let RootReference(VPMReference) let RootOccurrenceList(List) let RootReferenceList(List) let CachedFuildTable(VolatileInstance) let FluidTable(Ens_FluidTable) let ColumnDescriptors(List) let ColumnDescriptor(EnsParameterDescriptor) let FluidColumnIndex(Integer) let ColorColumnIndex(Integer) let CellsList(List) let FluidCell(EnsTechnologicalTableCell) let ColorCell(EnsTechnologicalTableCell) let Fluid(String) let Color(String) let NbColumns(Integer) let NbRows(Integer) let DuctsList(List) let PartsList(List) let PipeOccurrence(Piping_Pipe_Occurrence) let PartOccurrence(Piping_Part_Occurrence) let GraphicManager(Visualizable) let LineID(Piping_Line) let Count(Integer) let I(Integer) MessageCatalogName = "CDVEKLMessageCatalog_Piping" Count = 0 set CachedFuildTable = new("VolatileInstance", "", NULL) set FluidTable = AccessResource("PipingSpecificationResource|Fluid", "Ens_FluidTable") if FluidTable <> NULL { I = 1 FluidColumnIndex = 0 ColorColumnIndex = 0 FluidTable->GetColumnDefinitions(ColumnDescriptors) for I while I <= ColumnDescriptors->Size() { set ColumnDescriptor = ColumnDescriptors->GetItem(I) if ColumnDescriptor == NULL continue /* XXX: Fluid table column names and types are hardcoded here... */ if ColumnDescriptor.Type <> "String" continue else if ColumnDescriptor.Name == "Fluid" FluidColumnIndex = I else if ColumnDescriptor.Name == "OutfittingColor" ColorColumnIndex = I } if FluidColumnIndex == 0 or ColorColumnIndex == 0 { MessageContent = BuildMessageNLS(MessageCatalogName,"PIP_0002_ERR_FluidTableMissingColors" , I - 1, Count) if MessageContent->Length() <= 0 Notify("Piping fluid table does not defined any colours for outfitting...") else Notify(MessageContent) exit } I = 1 FluidTable->GetSize(NbRows, NbColumns) for I while I <= NbRows { if FluidTable->GetRow(I, CellsList) == false continue set FluidCell = CellsList->GetItem(FluidColumnIndex) set ColorCell = CellsList->GetItem(ColorColumnIndex) if FluidCell == NULL or ColorCell == NULL continue Fluid = FluidCell->GetAttributeString("ValueAsString") Color = ColorCell->GetAttributeString("ValueAsString") CachedFuildTable->SetAttributeString(Fluid, Color) } } else { MessageContent = BuildMessageNLS(MessageCatalogName,"PIP_0001_ERR_FluidTableNotDefined") if MessageContent->Length() <= 0 Notify("No fluid table defined for Piping...") else Notify(MessageContent) } /* XXX: Improve this by retrieving active level's root parent? */ RootReferenceList = GetEditorRoots("VPMReference") if RootReferenceList->Size() == 1 set RootReference = RootReferenceList->GetItem(1) if RootReference <> NULL set RootOccurrenceList = RootReference->ListOccurrences(RootReference) if RootOccurrenceList <> NULL and RootOccurrenceList->Size() == 1 set RootOccurrence = RootOccurrenceList->GetItem(1) if RootOccurrence <> NULL { I = 1 set DuctsList = RootOccurrence->Query("Piping_Pipe_Occurrence", "") set PartsList = RootOccurrence->Query("Piping_Part_Occurrence", "") for I while I <= DuctsList->Size() + PartsList->Size() { set LineID = NULL set GraphicManager = NULL if I > 0 and I <= DuctsList->Size() { set PipeOccurrence = DuctsList->GetItem(I) if PipeOccurrence == NULL continue set LineID = PipeOccurrence->GetLineIDObject().Reference set GraphicManager = PipeOccurrence } else if I <= DuctsList->Size() + PartsList->Size() { set PartOccurrence = PartsList->GetItem(I - DuctsList->Size()) if PartOccurrence == NULL continue set LineID = PartOccurrence->GetLineIDObject().Reference set GraphicManager = PartOccurrence } if GraphicManager == NULL continue if LineID == NULL GraphicManager.Color = "#FFFFFF" else if CachedFuildTable->HasAttribute(LineID.V_Fluid) == false GraphicManager.Color = "#FFFFFF" else { GraphicManager.Color = CachedFuildTable->GetAttributeString(LineID.V_Fluid) Count = Count + 1 } } MessageContent = BuildMessageNLS(MessageCatalogName,"PIP_0003_INF_ElementsCountNotification" , I - 1, Count) if MessageContent->Length() <= 0 Notify(ToString(I - 1) + " Piping element(s) analysed, " + ToString(Count), " colorised.") else Notify(MessageContent) }
CATRules
Color insulations
Code Exemple : advanced : Color insulation based on "insulation Type" attribute (from Techno table)
/* Prototype: (Void) : #Void */ /* Requirement: This code relies on an additional column in the InsulationType table (OutfittingColor) */ /* OutfittingColor column will contain the RGB color code for each fluid */ /* Comment: Mind switching ON action's property 'No dialog box when running an action without argument' */ let MessageCatalogName(String) let MessageContent(String) let RootOccurrence(ProductOccurrence) let RootReference(VPMReference) let RootOccurrenceList(List) let RootReferenceList(List) let CachedFuildTable(VolatileInstance) let CachedInsulationTypeTable(VolatileInstance) /* Test Insulation */ let FluidTable(Ens_FluidTable) let InsulationTypeTable(Ens_InsulationTypeTable) /* Test Insulation */ let ColumnDescriptors(List) let ColumnDescriptor(EnsParameterDescriptor) let FluidColumnIndex(Integer) let InsulationTypeColumnIndex(Integer) let ColorColumnIndex(Integer) let CellsList(List) let FluidCell(EnsTechnologicalTableCell) let InsulationTypeCell(EnsTechnologicalTableCell) /* Test Insulation */ let ColorCell(EnsTechnologicalTableCell) let Fluid(String) let InsulationType (String) /* Test Insulation */ let Color(String) let NbColumns(Integer) let NbRows(Integer) let DuctsList(List) let PartsList(List) let InsulationList(List) /* Test Insulation */ let PipeOccurrence(Piping_Pipe_Occurrence) let PartOccurrence(Piping_Part_Occurrence) let InsOccurence(Piping_Insulation_Occurrence) /* Test Insulation */ let GraphicManager(Visualizable) let LineID(Piping_Line) let InsRef(Piping_Insulation) /* Test Insulation */ let Count(Integer) let I(Integer) Count = 0 set CachedInsulationTypeTable = new("VolatileInstance", "", NULL) /* Test Insulation */ // retreive InsulationType table from Datasetup set InsulationTypeTable = AccessResource("PipingSpecificationResource|InsulationType", "Ens_InsulationTypeTable") /* Test Insulation */ // Retreive Column index for InsulationType and Color in InsutlationTypeTable if InsulationTypeTable <> NULL { I = 1 InsulationTypeColumnIndex = 0 ColorColumnIndex = 0 InsulationTypeTable ->GetColumnDefinitions(ColumnDescriptors) for I while I <= ColumnDescriptors->Size() { set ColumnDescriptor = ColumnDescriptors->GetItem(I) if ColumnDescriptor == NULL continue /* XXX: Insulation Type table column names and types are hardcoded here... */ if ColumnDescriptor.Type <> "String" continue else if ColumnDescriptor.Name == "InsulationType" InsulationTypeColumnIndex = I else if ColumnDescriptor.Name == "OutfittingColor" ColorColumnIndex = I } // If no InsulationType or OutfittingCollor Collumn in the table , Message if InsulationTypeColumnIndex == 0 or ColorColumnIndex == 0 Notify("Piping Insulation Type table does not defined any colours for outfitting...") else Notify("InsulationType & OutfittingColor columns found") // Build InsulationType value list and Color value list for from the Insulation Table I = 1 InsulationTypeTable->GetSize(NbRows, NbColumns) for I while I <= NbRows { if InsulationTypeTable->GetRow(I, CellsList) == false continue set InsulationTypeCell = CellsList->GetItem(InsulationTypeColumnIndex) set ColorCell = CellsList->GetItem(ColorColumnIndex) if InsulationTypeCell == NULL or ColorCell == NULL continue InsulationType = InsulationTypeCell->GetAttributeString("ValueAsString") Color = ColorCell->GetAttributeString("ValueAsString") CachedInsulationTypeTable->SetAttributeString(InsulationType, Color) } } // If no Insulation Type table table in ResourceSet, Message else { MessageContent = BuildMessageNLS(MessageCatalogName,"PIP_0001_ERR_FluidTableNotDefined") if MessageContent->Length() <= 0 Notify("No Piping Insulation type table defined for Piping...") else Notify("Insulation Type table Name - " + InsulationTypeTable.Name) } // Build the list of Insulations occurent from the ROOT /* XXX: Improve this by retrieving active level's root parent? */ RootReferenceList = GetEditorRoots("VPMReference") if RootReferenceList->Size() == 1 set RootReference = RootReferenceList->GetItem(1) if RootReference <> NULL set RootOccurrenceList = RootReference->ListOccurrences(RootReference) if RootOccurrenceList <> NULL and RootOccurrenceList->Size() == 1 set RootOccurrence = RootOccurrenceList->GetItem(1) if RootOccurrence <> NULL { I = 1 set InsulationList = RootOccurrence->Query("Piping_Insulation_Occurrence", "") for I while I <= InsulationList->Size() { set GraphicManager = NULL if I > 0 and I <= InsulationList->Size() { set InsOccurence = InsulationList->GetItem(I) if InsOccurence == NULL continue set InsRef = InsOccurence.Reference set GraphicManager = InsOccurence } if GraphicManager == NULL continue // check if the table contains the value of Insulation Type set on the Insulation Reference if CachedInsulationTypeTable->HasAttribute(InsRef.V_InsulationType) == false { GraphicManager.Color = "#FFFFFF" Notify("InsulationType not found" + " - " + InsulationTypeTable.Name + " - " + InsulationTypeColumnIndex + "-" + InsulationType + " - " + ColorColumnIndex + "-" + Color + " - " + CachedInsulationTypeTable.Name) } // If yes , retreive corresponding color else { GraphicManager.Color = CachedInsulationTypeTable->GetAttributeString(InsRef.V_InsulationType) Count = Count + 1 Notify("InsulationType - " + InsRef.V_InsulationType ) } } MessageContent = BuildMessageNLS(MessageCatalogName,"PIP_0003_INF_ElementsCountNotification" , I - 1, Count) if MessageContent->Length() <= 0 Notify(ToString(I - 1) + " Piping element(s) analysed, " + ToString(Count), " colorised.") else Notify(MessageContent) }
3DXML
Video
Color Pipe automatically during design thanks to business Rule
Need :
Coloring tubing, Piping HVAC according Parent LineID information
Remark : an EKL rule to be executed automaticaly in real time. this rule is attached toi the Collaborative space through a ResourceSet
The function must be done automatically via Business Rule. Objective is to color object live during the design of the piping network.
To avoid having impact on the overall App performances it could be better to use an Action that user will execute manually instead of using this method
Setup:
Put in place Business Rule (BR) in
- The resource : “Business Logic for Items”
- BR “After creation of PPR Link”
This BR is called during each creation of implement links. This is the case when a piping object is attached to a LineID.
So we can use it to controle the associated line to a pipe and set automatically the good color
Video:
Code:
//Notify("ImplementLink Rule") let lSources(List) let lTargets(List) let ustrRelationName(String) let iRigidPipe(Piping_Rigid_Pipe) let iLineInst(Piping_Line_Inst) set lSources = Parameters->GetAttributeObject("Source") set lTargets = Parameters->GetAttributeObject("Target") ustrRelationName = Parameters->GetAttributeString("RelationType") if ((ustrRelationName == "PLM_ImplementLink_Target") and (lSources.Size() > 0) and (lTargets.Size() > 0)) { let sourcePhysicalInstance(VPMInstance) let targetLogicalInstance(RFLVPMLogicalInstance) set targetLogicalInstance = lTargets[lTargets.Size()] set sourcePhysicalInstance = lSources[lSources.Size()] if (sourcePhysicalInstance <> NULL and targetLogicalInstance <> NULL) { let ustrLogicalInstanceName(String) let ustrPhycialInstanceName(String) ustrLogicalInstanceName= targetLogicalInstance.Name ustrPhycialInstanceName= sourcePhysicalInstance.Name if(sourcePhysicalInstance.IsSupporting("Piping_Valve_Inst")) { sourcePhysicalInstance.Name = targetLogicalInstance.Name } else if(sourcePhysicalInstance.IsSupporting("Piping_Pipe_Inst") AND targetLogicalInstance.IsSupporting("Piping_Line_Inst")) { set iRigidPipe=sourcePhysicalInstance.Reference set iLineInst = targetLogicalInstance Notify("Pipe : #, Line ID : #",sourcePhysicalInstance.Name,targetLogicalInstance.Name) if(iLineInst.Name == "FFL00001") { iRigidPipe.SetColor(51,63,255) } else { iRigidPipe.SetColor(14,129,40) } } else if(sourcePhysicalInstance.IsSupporting("HVAC_Duct_Inst") AND targetLogicalInstance.IsSupporting("HVAC_Line_Inst")) { let fexibleDuct (HVAC_Flexible_Duct) let rigid_Duct1 (HVAC_Rigid_Duct) } else if(sourcePhysicalInstance.IsSupporting("Piping_Insulation_Inst") AND targetLogicalInstance.IsSupporting("Piping_Line_Inst")) { let pipeInsulation (Piping_Insulation) set pipeInsulation = sourcePhysicalInstance.Reference let prd(Piping_Rigid_Pipe) let Opacity(Integer) Opacity = 50 pipeInsulation.SetOpacity(Opacity) if(iLineInst.Name == "FFL00001") { pipeInsulation.SetColor(51,63,255) } else { pipeInsulation.SetColor(14,129,40) } } } }