Creat List of idw Layers using iLogic

Creat List of idw Layers using iLogic

Anonymous
Not applicable
883 Views
3 Replies
Message 1 of 4

Creat List of idw Layers using iLogic

Anonymous
Not applicable

Hello All,

 

I'm hoping this is an easy question & just something I'm overlooking.

I have the following code

 

'get single layer
Dim odoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oBaseLayer As Layer

oBaseLayer = odoc.StylesManager.Layers.Item("DWG__TXT50")

'change color To red
Dim oColor As Color

oColor = oBaseLayer.Color
oColor.Red = 0
oColor.Green = 0
oColor.Blue = 0
oBaseLayer.Color = oColor

This code will find the layer "DWG__TXT50" & change its color to Black which is great.

 

I want to ad an "IF" statement to this so that the code will search all Layers within idw that have in string "DWG" & change all those layers colors to Black.

For some reason I cannot find any code/api to get idw layers in an item list to interrogate them.

 

PLEASE HELP!! lol

 

Many Thanks in advance

 

Tim

0 Likes
Accepted solutions (1)
884 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor

'oBaseLayer = odoc.StylesManager.Layers.Item("DWG__TXT50") 'change color To red
For each oBaselayer in odoc.stylemanager.layers

Dim oColor As Color
oColor = oBaseLayer.Color
oColor.Red = 0
oColor.Green = 0
oColor.Blue = 0
oBaseLayer.Color = oColor
Next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

HermJan.Otterman
Advisor
Advisor
Accepted solution

Hallo Tim,

 

here is a bit of code...

 

 

 

 Dim LayerCollection As LayersEnumerator = thisdoc.Document.StylesManager.Layers

        Dim Layer As Layer

        'loop through LayerCollection
        For Each Layer In LayerCollection
            'assumption If DWG is in the name then alway the first 3 letters!
            Dim layerName As String = Layer.Name
            Dim first3Letters As String = Strings.Left(layerName, 3)
            If first3Letters = "DWG" Then
                'change color
                'Color Black
                Dim oColor As Color = Layer.Color
                oColor.Red = 0
                oColor.Green = 0
                oColor.Blue = 0
                Layer.Color = oColor
            End If
        Next

 it goes through every layer, checking the first three letters. if they are "DWG" then the color will be black

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 4 of 4

Anonymous
Not applicable

Excellent!!! Worked a treat.

 

Thanks Herm Jan much appreciated

 

Kind Regards

 

Tim

0 Likes