- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The below code works great when used within a part file, but when I add the part to an assembly, the part errors. For example, a single line of iLogic code in the assembly to change the width of the part will cause the part file to run its iLogic code, and error. When I comment out the below code, the part updates correctly in the assembly. I think the error is in the "com.autodesk.inventor.FaceAttributes" line, but I don't know how else I can find each face to update.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
' Get all of the faces that have the "FaceColor" attribute.
Dim oFaces As ObjectCollection
oFaces = oPartDoc.AttributeManager.FindObjects( "com.autodesk.inventor.FaceAttributes", "FaceColor")
' Iterate through all faces that have colors and change.
Dim oFace As Face
Dim oAssets as Assets
oAssets = oPartDoc.Assets
Dim oAsset as Asset
oAsset = oAssets.Item("Bamboo")
For Each oFace In oFaces
oFace.Appearance = oAsset
Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was completely wrong about where I thought the problem was. When I looked at this fresh this morning I noticed that the oPartDoc is referencing "ThisApplication.ActiveDocument". In my assembly I am passing variables to the part file, executing code in that part file, but it is not the active document, my assembly file is. Changing oPartDoc to "ThisDoc.Document" fixed the problem and all is good.
Dim oPartDoc As PartDocument oPartDoc = ThisDoc.Document 'ThisApplication.ActiveDocument