Changing colors in background of draft

Creator
Creator

Hello People,

 

I am working on a macro which changes the old draft template to a new one. I've already fixed some color changes which are in the styles. 

 

Now is the following the problem:

I have some lines and blocks in the background sheets ( A4, A3, etc. ). Of these i want to change the colors. So something like "for every item in each sheet in active document make the color black". but then in code.

 

This is a bit of the code which changes the color in the active sheet.

  For Each SEDimensionStyle As SolidEdgeFrameworkSupport.DimensionStyle In SEDimensionStyles
                    SEDimensionStyle.DrivenColor = 8421376
                    SEDimensionStyle.DrivingColor = 8421376
                Next

                Dim SECharTextStyles As SolidEdgeFramework.TextCharStyles
                SECharTextStyles = SEDraftDocument.TextCharStyles

                For Each SECharTextStyle As SolidEdgeFramework.TextCharStyle In SECharTextStyles
                    SECharTextStyle.Color = 0

 I've searched in Spy for Solid Edge and thought that i had to be at the partslist and then at the showsheetbackground.

 

I hope you can help me to get further.

 

Kindly Regards,

Justin

14 REPLIES

Re: Entering background in draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Justin,

 

you can iterate over the background sheets as follows:

 

For Each sheet As SolidEdgeDraft.Sheet In dftDoc.Sections.BackgroundSection.Sheets
    ...
Next
Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Entering background in draft

Creator
Creator

I have this now. ( the code which changes the colors is in the spoiler )

Public SEDraftDocument As SolidEdgeDraft.DraftDocument
Spoiler
If SENoDocuments() = True Then
MsgBoxNoDocuments()
Else

If SENoDraftDocument() = True Then
MsgBoxNoDraftDocument()
Else

SEDraftDocument = SEApplication.ActiveDocument

Dim SELinearStyles As SolidEdgeFramework.LinearStyles
SELinearStyles = SEDraftDocument.LinearStyles

For Each SELinearStyle As SolidEdgeFramework.LinearStyle In SELinearStyles
SELinearStyle.Color = 0
Next

Dim SEDimensionStyles As SolidEdgeFrameworkSupport.DimensionStyles
SEDimensionStyles = SEDraftDocument.DimensionStyles

For Each SEDimensionStyle As SolidEdgeFrameworkSupport.DimensionStyle In SEDimensionStyles
SEDimensionStyle.DrivenColor = 8421376
SEDimensionStyle.DrivingColor = 8421376
Next

Dim SECharTextStyles As SolidEdgeFramework.TextCharStyles
SECharTextStyles = SEDraftDocument.TextCharStyles

For Each SECharTextStyle As SolidEdgeFramework.TextCharStyle In SECharTextStyles
SECharTextStyle.Color = 0
Next
End If
End If
For Each sheet as SolidEdgeDraft.Sheet In SEDraftDocument.Sections.BackgroundSection.Sheets            
Dim SEselectset = SEDraftDocument.SelectSet Dim highset = SEDraftDocument.HighlightSets.Add() For i As Integer = 1 To SEDraftDocument.ActiveSheet.Lines2d.Count Dim line2d = SEDraftDocument.ActiveSheet.Lines2d.Item(i) SEselectset.Add(line2d) highset.AddItem(line2d)
line2d.Style.LinearColor = 0
Next Next

The code selects all the lines in the active sheet but not in every sheet.

 

Re: Entering background in draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Justin,

 

the following code would change the LinearColor of all lines found on all foreground and background sheets:

 

'Change LinearColor of all Line2d objects on all foreground sheets
For Each sheet As SolidEdgeDraft.Sheet In SEDraftDocument.Sections.WorkingSection.Sheets
   For Each line2d As SolidEdgeDraft.Line2d In sheet.Lines2d
      line2d.Style.LinearColor = 0
   Next
Next

'Change LinearColor of all Line2d objects on all background sheets
For Each sheet As SolidEdgeDraft.Sheet In SEDraftDocument.Sections.BackgroundSection.Sheets
   For Each line2d As SolidEdgeDraft.Line2d In sheet.Lines2d
      line2d.Style.LinearColor = 0
   Next
Next
      
Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Entering background in draft

Creator
Creator

Thanks a lot This works for me!

 

Here is the code I've used. ( changed it a litle bit )

 

        For Each sheet As SolidEdgeDraft.Sheet In SEDraftDocument.Sections.WorkingSection.Sheets
            For Each line2d As SolidEdgeFrameworkSupport.Line2d In sheet.Lines2d
                line2d.Style.LinearColor = 0
            Next
        Next

        'Change LinearColor of all Line2d objects on all background sheets
        For Each sheet As SolidEdgeDraft.Sheet In SEDraftDocument.Sections.BackgroundSection.Sheets
            For Each line2d As SolidEdgeFrameworkSupport.Line2d In sheet.Lines2d
                line2d.Style.LinearColor = 0
            Next
        Next

Re: Entering background in draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Justin,

 

fine I could help you.

 

Just a note: You marked your own post as a solution, giving a Kudo would also be nice Smiley Wink

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Entering background in draft

Creator
Creator

Just another question....

 

Like you can see in the picture, isn't everything black.

The items which are pink, are grouped as block.

 

 

I was thinking of 2 solutions:

1: select all and make it black

2: ungroup elements, select text boxes, make text black.

 

See attached image for more info.

This is just a test drawing so i know that the model link is broken.Knipsel.JPG

Re: Entering background in draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Justin,

 

the hierarchie to access the TextBoxes inside of a block (BlockOccurrence object) is as follows:

 

sheet.BlockOccurrences.Item(i).BlockView.TextBoxes

 

To edit the text color of a specific TextBox object:

 

textBoxes.Item(j).Edit.Color=colorString

 

Please check the SDK help file for the objects:

  • BlockOccurrences
  • BlockOccurrence
  • BlockView
  • TextBoxes
  • TextBox
  • TextEdit

 (Edit)

If your pink marked text objects should be simply grouped instead of being part of a block, you simply have to iterate over the sheet.Groups collection and for each Group object iterate over its TextBoxes collection to get access to the individual TextBox objects to change their text color.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de

Re: Entering background in draft

Creator
Creator

Hello again,

 

Thanks for your help. The ungrouping works fine, but i cant find the color. If i search for the color in spy, I can only find the borderlinecolor and the fillcolor. These are already at "0" so i think that this isn't the property i need.

        For Each sheet As SolidEdgeDraft.Sheet In SEDraftDocument.Sections.BackgroundSection.Sheets
            For Each line2d As SolidEdgeFrameworkSupport.Line2d In sheet.Lines2d
                line2d.Style.LinearColor = 0

            Next
            For Each group As SolidEdgeFrameworkSupport.Group In sheet.Groups
                group.Ungroup()
                For Each textbox As SolidEdgeFrameworkSupport.TextBox In sheet.TextBox
                    textbox.BorderLineColor = 0
                    textbox.FillColor = 0
                Next
            Next

Knipsel.JPGI am looking for the property which changes the magenta in black.

 edit: I've just noticed that it isn't text but a callout.

Re: Changing colors in background of draft

Solution Partner Legend Solution Partner Legend
Solution Partner Legend
Justin,

The text color of a TextBox object is made available via its Edit property, which returns a TextEdit object. This object allows setting the text color via its Color property.
Kind regards,
Wolfgang Kunert - www.wksyspro.de