Message 1 of 6
Trouble toggling iPart plane visibility using VBA

Not applicable
09-16-2014
08:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to toggle the visibility of every WorkPlane in every part of a SelectionSet using VBA. I am using the following code to do so:
Public Sub toggleBasePlanes() Dim selectedParts As SelectSet Dim oOccurence As ComponentOccurrence Dim oWorkPlane As WorkPlane Dim basePlanes As WorkPlanes Set selectedParts = ThisApplication.ActiveDocument.SelectSet For Each oOccurence In selectedParts Set basePlanes = oOccurence.Definition.WorkPlanes For Each oWorkPlane In basePlanes oWorkPlane.Visible = Not oWorkPlane.Visible Next oWorkPlane Next oOccurence End Sub
This works well for standard parts and assemblies, but I get the following error when I run it on an iPart:
Furthermore, it appears that I do not get the error when I run the code on iParts that were created in the current session of Inventor. I am out of ideas, maybe I need to access the planes differently for an iPart? Any help would be appreciated.