Reply

Changing line color within groups with draft views

[ Edited ]

 

Can anyone please tell me the VB6 code to change existing line colors of geometry within groups that are within draft views?

I can achieve this if the groups are not within any draft views but they are on any sheet or in the background sheet then I cannot figure the code out. I hope the answer is simple....

For example I thought this would do it but it doesn't.

For Each objGroup In objDoc.Sheets(1).Background.DrawingViews

            'Get the Linear color

            ccolor = objGroup.LinearColor

            'Sets the color

            If ccolor = seColorGreen Then

               objGroup.LinearColor = seColorBlack

            End If

        Next

Many Thanks

 

Posted by: Allan Anderton
Post date: 3/26/2010 12:25:03 AM

7 REPLIES

RE: Changing line color within groups with draft views

[ Edited ]

This will go through all the drawing views in all the sheets (background or not) in your DFTAnd will get all the groups inside the views.

 For each sh in objDoc.Sheets

   For each dv in sh.DrawingViews       For Each objGroup In dv.Sheet.Groups

            'Get the Linear color

            ccolor = objGroup.LinearColor

            'Sets the color

            If ccolor = seColorGreen Then

               objGroup.LinearColor = seColorBlack

            End If

        Next   NextNext

 

Regards,

Julian

 

Posted by: Julian Guillo
Post date: 3/26/2010 7:57:30 AM

RE: Changing line color within groups with draft views

[ Edited ]

 

Thanks for this but it does not achieve anything using this code?

 

Posted by: Allan Anderton
Post date: 3/28/2010 10:15:12 PM

RE: Changing line color within groups with draft views

[ Edited ]

 

Got it working - thanks

However it does not do groups within groups.

 

Anyone any ideas?

 

Posted by: Allan Anderton
Post date: 3/28/2010 10:50:04 PM

RE: Changing line color within groups with draft views

[ Edited ]

 

This could do the trick.

'Main loopFor each sh in objDoc.Sheets

   For each dv in sh.DrawingViews       For Each objGroup In dv.Sheet.Groups

           changeGroupStyle objGroup        Next   NextNext

'Recursive function to change nested groups.

Sub changeGroupStyle(ByVal objGroup As SolidEdgeFrameworkSupport.Group)Dim grp As SolidEdgeFrameworkSupport.Group   'Sets the color    If ccolor = seColorGreen Then     objGroup.LinearColor = seColorBlack    EndIf    If objGroup.HasNested = 1 Then          changeGroupStyle(grp)       ForEach grp In objGroup.Groups      Next    EndIf EndSub    ccolor = objGroup.LinearColor 

 

Posted by: Julian Guillo
Post date: 3/28/2010 11:40:25 PM

RE: Changing line color within groups with draft views

[ Edited ]

 

Sorry, i always forget to format the code...

 

This could do the trick.

'Main loopFor each sh in objDoc.Sheets

   For each dv in sh.DrawingViews       For Each objGroup In dv.Sheet.Groups

           changeGroupStyle objGroup        Next   NextNext

'Recursive function to change nested groups.

 Sub changeGroupStyle(ByVal objGroup As SolidEdgeFrameworkSupport.Group)Dim grp As SolidEdgeFrameworkSupport.Group   ccolor = objGroup.LinearColor   'Sets the color   If ccolor = seColorGreen Then      objGroup.LinearColor = seColorBlack   End If   If objGroup.HasNested = 1 Then      For Each grp In objGroup.Groups         changeGroupStyle(grp)      Next   End IfEnd Sub

 

Posted by: Julian Guillo
Post date: 3/28/2010 11:48:05 PM

RE: Changing line color within groups with draft views

[ Edited ]

 

thanks

 

Posted by: Allan Anderton
Post date: 3/29/2010 1:03:49 AM

RE: Changing line color within groups with draft views

[ Edited ]

 

hi mark

i'm trying to do some line coloring myself and came across your post. i can see the code you got is missing some "frame work" such as conecting to SE and getting the active dft. would you please post the finale code you got working for us too?

 

Posted by: alon raviv
Post date: 5/12/2010 3:42:20 AM