Fast way to change line weight or layer for selected views in Inventor Drawing using API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everybody,
I would like to modify all lines' widths of selected drawing views. My colleague have noticed that doing it thorough selection of a referenced component in the browser pane and using Properties... command is the fastest. In this GUI approach a form appears where By layer checkbox can be deactivated and Line Weight can be selected. The lines are modified almost instantly also for heavy models with lots of lines. Is there a way to achieve similar performance using API?
What I've tried is to select all the segments of DrawingCurves and insert them into an ObjectCollection. Than using Sheet.ChangeLayer method I've moved lines to a layer with thinner line. This unfortunately takes much more time, up to few minutes for bigger assemblies.
This is what I've tried, but the performance wasn't satisfying.
Public Sub drawingChangeLayer()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim curveObColl As ObjectCollection
Set curveObColl = ThisApplication.TransientObjects.CreateObjectCollection
Dim oselSet As SelectSet
Set oselSet = oDrawDoc.SelectSet
Dim oDrView As DrawingView
For Each oDrView In oselSet
Dim oCurve As DrawingCurve
For Each oCurve In oDrView.DrawingCurves()
Dim oSeg As DrawingCurveSegment
If Not oCurve.Segments Is Nothing Then
For Each oSeg In oCurve.Segments
Call curveObColl.Add(oSeg)
Next
End If
Next
Next
Dim lay As Layer
Set lay = oDrawDoc.StylesManager.Layers.Item(226)
Call oSheet.ChangeLayer(curveObColl, lay)
End Sub
Thanks in advance.
Michal