Is there some fast and easy way to make all the lines, polylines, circles, etc one color using VB.net?
So far i have tried looping lines, circles, arcs, bspline curves, ellpises and elliptical arcs with something like this:
Dim Line As SolidEdgeFrameworkSupport.Line2d Dim Lines As SolidEdgeFrameworkSupport.Lines2d For i = 1 To Lines.Count Line = Lines.Item(i) Line.Style.LinearColor = RGB(0, 0, 0) Next
But looping all these elements is really slow and it still does not cover polylines. What would be a better way to solve this problem?
You may change the color of all used styles directly and then redraw the view:
Dim NewLineColor As Int32 = RGB(0, 0, 0) ' Black (RGB) ' Change the line style Dim objDoc As DraftDocument = objApp.ActiveDocument For Each lineStyle As LinearStyle In objDoc.LinearStyles lineStyle.Color = NewLineColor Next ' Update the drawing window Dim objWin As SheetWindow = objDoc.Windows.Item(1) objWin.Update()
BUT: If there is any drawing object with an overwritten line color, you have to change the color for that object in its Style property to overwrite it again, like you were already doing!
Actually, I don't know of any API function to remove the overrides, like is is possible interactively. I believe the RemoveAllSegmentedStyles() on each drawing object does NOT do that, but I haven't checked it yet.
If you really need to change the color individually for each drawing object, than you should disable ScreenUpdating and some other properties on the Application object. This makes the execution much faster:
Dim NewLineColor As Int32 = RGB(0, 0, 0) ' Black (RGB) ' Disable any screen updating and UI updates objApp.ScreenUpdating = False objApp.DisplayAlerts = False objApp.Interactive = False ' Update all drawing objects Dim objDoc As DraftDocument = objApp.ActiveDocument For Each lin As Line2d In objDoc.ActiveSheet.Lines2d lin.Style.LinearColor = NewLineColor Next For Each arc As Arc2d In objDoc.ActiveSheet.Arcs2d arc.Style.LinearColor = NewLineColor Next For Each cir As Circle2d In objDoc.ActiveSheet.Circles2d cir.Style.LinearColor = NewLineColor Next '... more to do here (PolyLines are represented as LineStrings) ' Enable again screen updating and UI updates objApp.Interactive = True objApp.DisplayAlerts = True objApp.ScreenUpdating = True ' Refresh the drawing window Dim objWin As SheetWindow = objDoc.Windows.Item(1)
Disabling ScreenUpdating and other properties made it fast enough for me.
But I am still struggling to change all of the objects.
The DXF origins from AutoCAD, the names of the green objects are for example AcDb3dPolyline-A89B. They seem to be polylines, but I can't find polylines under SolidEdgeFrameworkSupport method. What else could it be?