Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've got an iLogic that dependent on the end of the file name it pulls information from an excel file and puts it in the iProperties and changes some settings to the file. I want to have it also change the color of all of the parts in the assembly to a certain color in the appearance library at the assembly level. So if the FabricationProcess is SF then change all parts to green, if its FF change all parts to Yellow. If I can also change the color in all view representations that would be great too.
'Sets Sub type to the iproperties document subtype
Dim oSubType As String
oSubType = iProperties.Value("Project", "Document SubType Name")
'File Naming break down
a = ThisDoc.FileName(False)
StageNumber = Split(ThisApplication.ActiveDocument.DisplayName, "-")(2)
SpoolType = Split(ThisApplication.ActiveDocument.DisplayName, "-")(3)
SpoolNumber = Split(ThisApplication.ActiveDocument.DisplayName, "-")(4)
FabricationProcess = Right(a, 2)
'MsgBox("a = " & a, , "")
'MsgBox("Stage Number = " & StageNumber, , "")
'MsgBox("Spool Type = " & SpoolType, , "")
'MsgBox("Spool Number = " & SpoolNumber, , "")
'MsgBox("e = " & a1, , "")
ExcelFile = "C:\CA Workspace\CAD Standards\CA Library A\iLogic Automation\PTED - Table.xlsx"
'Ignores any excel alerts
GoExcel.DisplayAlerts = False
'Stocked material verification
Dim rowNum As Integer = GoExcel.FindRow(ExcelFile, "Stocked", "Spool Type Acronym", "=", SpoolType)
'Checks if no option is available then displays message box to user
If (rowNum >0) Then
SpoolTypeNaming = GoExcel.CurrentRowValue("Spool Type")
Else If (rowNum <0) Then
i = MessageBox.Show("Spool Type not found. Please add type or rename file", "No Spool Type", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End If
'Non-Stocked material verification
Dim rowNum2 As Integer = GoExcel.FindRow(ExcelFile, "Stocked", "Fabrication Process Acronym", "=", FabricationProcess)
If (rowNum2 >0) Then
FabricationProcessNaming = GoExcel.CurrentRowValue("Fabrication Process")
Else If (rowNum2 <0) Then
i = MessageBox.Show("Fabrication Process not found. Please add process or rename file", "No Fabrication Process", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
End If
DescriptionCombined = StageNumber & " - " & SpoolTypeNaming & " - SPOOL #" & SpoolNumber & " - " & FabricationProcessNaming
'i = MessageBox.Show(DescriptionCombined, "Name Testing", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
If oSubType = "Drawing Layout" Then
iFileName = ThisDoc.FileName(False) 'without extension
iProperties.Value("Custom", "CAD FILE NUMBER") = iFileName
iProperties.Value("Project", "Part Number") = iFileName
'get the folder path of the this document
Dim folderpath As String = ThisDoc.Path
iProperties.Value("Custom", "WJ") = "W:\" + folderpath.Substring(16) + "\"
iProperties.Value("Summary", "Title") = "STAGE - " & StageNumber
iProperties.Value("Custom", "LINE 01") = SpoolTypeNaming
iProperties.Value("Custom", "LINE 02") = "SPOOL #" & SpoolNumber
iProperties.Value("Custom", "LINE 03") = FabricationProcessNaming
Exit Sub
End If
If oSubType IsNot "Drawing Layout" Then
iFileName = ThisDoc.FileName(False) 'without extension
iProperties.Value("Project", "Part Number") = iFileName
iProperties.Value("Project", "Stock Number") = iFileName
iProperties.Value("Project", "Cost Center") = "ACC"
iProperties.Value("Project", "Description") = DescriptionCombined
iProperties.Value("Project", "Vendor") = "CA"
'Changes BOM Structure to Purchased
Dim oDoc As Document = ThisApplication.ActiveDocument
oDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure
''Changes BOM Structure to All Levels
If oDoc.DocumentType = kAssemblyDocumentObject Then
'Set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
'Set the structured view to 'All Levels'
oBOM.StructuredViewFirstLevelOnly = False
'Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
oBOM.PartsOnlyViewEnabled = True
Else
Return
End If
Try
' ## If the file is an assembly or a part.
If oDoc.DocumentType = kAssemblyDocumentObject Or oDoc.DocumentType = kPartDocumentObject Then
Dim DocType = oDoc.DocumentType
'Default = 51969
'Normal = 51970
'Phantom = 51971
'Reference = 51972
'Purchased = 51973
'Inseparable = 51974
'Varies = 51975
'## Set the BOM Structure Property
Select Case oDoc.ComponentDefinition.BOMStructure
Case "51970"
iProperties.Value("Custom", "BOM Structure") = "NORMAL"
Case "51971"
iProperties.Value("Custom", "BOM Structure") = "PHANTOM"
Case "51972"
iProperties.Value("Custom", "BOM Structure") = "REFERENCE"
Case "51973"
iProperties.Value("Custom", "BOM Structure") = "PURCHASED"
Case "51974"
iProperties.Value("Custom", "BOM Structure") = "INSEPARABLE"
Case Else
iProperties.Value("Custom", "BOM Structure") = "OTHER"
End Select
End If
Catch
Logger.Error("File: " + ThisDoc.FileName + " Error in Rule BOMTypeToProp writing the BOM Type to Custom Prop")
End Try
'Loads global form
iLogicForm.ShowGlobal("iProperties")
End If
Solved! Go to Solution.