Message 1 of 2
Change appearence colors assembly by iproperty value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
In an assembly, I want to run a code, so I can change the appearence colors by an Iproperty value. The code "art" has for example the value "FAS", then the color must be changed in red color. I Made a code, but it has no errors, but also it do not work. Can anyone help me?
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document Dim oPart As ComponentOccurrence Dim oLib As AssetLibrary oLib = ThisApplication.AssetLibraries.Item("Autodesk Appearance Library") 'work the referenced models For Each oRefDoc In oRefDocs Dim oCurFile As Document oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oCurFileName = oCurFile.FullFileName 'defines backslash As the subdirectory separator Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar Try For Each oProp As Inventor.Property In oRefDoc.PropertySets.Item("Inventor User Defined Properties") If oProp.Name = "art" And oProp.Expression = "FAS" Then Component.Color(oProp.Name) = "Red" iLogicVb.UpdateWhenDone = True End If If oProp.Name = "art" And oProp.Expression = "PLA" Then Component.Color(oProp.Name) = "Blue" iLogicVb.UpdateWhenDone = True End If Next Catch End Try oCurFile.Close Next 'update all InventorVb.DocumentUpdate() End Sub