- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello there,
I would like to open each occurrence in an already open top assembly and get each appearance as a string.
I'm aware that the command "iProperties.PartColor" allows you to get the Appearance, but it's not working running from the top assembly. I'm probably just missing a simple function. Bellow you can find the code:
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the referenced models For Each oRefDoc In oRefDocs Dim oCurFile As Document oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oCurFileAppearance = iProperties.PartColor 'oCurFileAppearance= oCurFile.Definition.Document.ActiveRenderStyle MessageBox.Show(oCurFileAppearance, "oCurFileAppearance") If oCurFileAppearance = "-" oCurFileAppearance ="-" End If ' MessageBox.Show(oCurFileAppearance, "oCurFileAppearance") oCurFile.Close Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Just to make sure - Do you want the appearance of the document or the occurrence?, beacuase those are not always the same ![]()
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good question. I would like to get the appearance of each ipt. and .iam opened in the "For" cycle.
oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
The appearance that shows on the top of Inventor WIndow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Those are actually two different things (iam and ipt). For an iam, the appearance shown in that dropdown is the appearance set to the selected occurrence in that assembly. The appearance in the document can be something else. So an assembly document in itself can't have an active appearance, only the occurrences of that assembly.
Do I make any sense to you? ![]()
This code however will give you the active appearance of all parts ![]()
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document Dim oAppearances As String = "Appearances:" & vbCrLf For Each oRefDoc As Document In oAsmDoc.AllReferencedDocuments If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Dim oAppearance As String = DirectCast(oRefDoc, PartDocument).ActiveAppearance.DisplayName oAppearances = oAppearances & vbCrLf & oRefDoc.DisplayName & " " & oAppearance End If Next MessageBox.Show(oAppearances, "Appearance list")
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for sharing that example. I'm attempting to modify the loop so that it can change all the colours within an Assembly at the Part level.
My initial attempt simply re-named the active Color within the Part but unfortunately didn't change the Colours appearance.
For Each oRefDoc As Document In oAsmDoc.AllReferencedDocuments If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject DirectCast(oRefDoc, PartDocument).ActiveAppearance.DisplayName = "Cyan" End If Next
Using the likes of Component.Color only creates an assembly appearance overide on the active view rep, which is why I can't use the below;
Component.Color("Example_Part:1") = "Red"
Would appreciate any help on having assembly level iLogic code change a parts Appearance at the part level.