- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a program where I have been deleting multiple features in a part document based on name. This program has been working it is just incredibly slow as the part regenerates after each feature deletion.
Here is the code that is being used for this.
Public Sub DeleteSBCalFeatures()
Dim sbDef As Inventor.PartComponentDefinition
sbDef = Occ.Definition
For Each feat As Inventor.PartFeature In sbDef.Features
Try
If feat.Name.Contains("SBCal-") Then
feat.Delete(False, False, False)
End If
Catch
End Try
Next
End SubWhen you do this thru the user interface and select all of the features from the model tree the deletion process is much quicker than the program above.
I thought I would try using SelectSet to delete the features in one shot similarly to selecting them from the model tree.
The code below is what I tried. It just errors out without a good error message. It errors out at the selSet.Delete() line
Public Sub DeleteSBCalFeaturesSs()
Dim sbDef As Inventor.PartComponentDefinition
sbDef = Occ.Definition
Dim selSet As Inventor.SelectSet
Dim sbDoc As Inventor.PartDocument
sbDoc = sbDef.Document
selSet = sbDoc.SelectSet
selSet.Clear()
For Each feat As Inventor.PartFeature In sbDef.Features
Try
If feat.Name.Contains("SBCal-") Then
selSet.Select(feat)
End If
Catch
End Try
Next
selSet.Delete()
selSet.Clear()
End SubDo you have thoughts on how to make either the first process faster or make the SelectSet.Delete() function work?
Thanks
Solved! Go to Solution.