- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, this is a sort of a continuation from THIS forum post, but it's not relevant to the parent topic so I wanted to create a new one.
From the last post I was able to get an external rule working for an individual part and being able to suppress certain features as called out from a list. I wanted to upgrade this to work within the assembly environment and search through all of the parts for features by that name and suppress/un-suppress them.
As said before, I was able to get it to work within a part. It is meant to prompt the user to select if the features should be On or Off, set that option to the IsVisible variable, then set the suppression state.
I believe my issue lies in defining the oFeature/oFeatures variables (Bolded and Underlined). Much of the info online is fairly outdated so I think I'm just using incorrect syntax. Getting the "Unable to cast COM object of type..." error on that line. Any help would be much appreciated!
Sub Main() Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oRefDocs As DocumentsEnumerator oRefDocs = oAssyDoc.AllReferencedDocuments Dim oRefDoc As Document Dim IsVisible As Boolean = InputRadioBox("Turn all CAD Aids On/Off", "On", "Off", False, "iLogic") Dim AidFeatures As New List(Of String) AidFeatures.Add("Feature1") AidFeatures.Add("Feature2") AidFeatures.Add("Feature3") For Each oRefDoc In oRefDocs If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then Dim oFeatures As PartFeatures = oRefDoc.AllReferencedDocuments For Each oString In AidFeatures oFeature = oFeatures.Item(oString) If oFeature.Name.Contains(oString) Then If IsVisible = True Feature.IsActive(oFeature.Name) = True End If If IsVisible = False Feature.IsActive(oFeature.Name) = False End If End If Next End If Next End Sub
Solved! Go to Solution.