Message 1 of 6
Problem Removing Custom Attributes
Not applicable
09-20-2012
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am trying to remove all custom attributes from a document.
With a fairly small document (with about 700 instances of the custom attribute), my code works fine, but with larger models (say about 9000 instances, Navisworks becomes unresponsive. Looking at the task manager, the code is still running, but it never exits.
ANy ideas? The code is below:
Dim nwstate As ComApi.InwOpState10
nwstate = ComApiBridge.ComApiBridge.State
Dim Search As New Search
Search.Selection.SelectAll()
Search.SearchConditions.Add(SearchCondition.HasCategoryByDisplayName("MyAttribute"))
Dim items As ModelItemCollection = Search.FindAll(Application.ActiveDocument, True)
Application.ActiveDocument.CurrentSelection.CopyFrom(items)
Dim index As Integer
For Each nwpath As ComApi.InwOaPath In nwstate.CurrentSelection.Paths
index = 0
Dim nwNode As ComApi.InwGUIPropertyNode2 = nwstate.GetGUIPropertyNode(nwpath, True)
For Each nwAtt As ComApi.InwGUIAttribute2 In nwNode.GUIAttributes()
If Not nwAtt.UserDefined Then Continue For
index += 1
nwNode.RemoveUserDefined(index)
Exit For
Next
GC.KeepAlive(nwNode)
GC.KeepAlive(nwpath)
Next
GC.KeepAlive(nwstate)
End If
Many thanks,
Mike