Jump to content

Reading Lineweigth & color value with VBA


Recommended Posts

Posted

Hello all,

 

When running a macro, I would like to "read" the current value of the color & lwt settings, so I can change them back after the macro is finished.

For the linetype, textstyle & current layer I used the following, but that doesn't work for the color & lwt.

 

Does anyone has an idea?

 

Thanks in advange,

 

Robin

 

L = ThisDrawing.ActiveLayer.Name

LT = ThisDrawing.ActiveLinetype.Name

S = ThisDrawing.ActiveTextStyle.Name

 

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Tekst_zwart")

ThisDrawing.ActiveTextStyle = ThisDrawing.TextStyles.Item("Iso")

ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("Bylayer")

 

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item(L)

ThisDrawing.ActiveTextStyle = ThisDrawing.TextStyles.Item(S)

ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item(LT)

Posted
Hello all,

 

When running a macro, I would like to "read" the current value of the color & lwt settings, so I can change them back after the macro is finished.

For the linetype, textstyle & current layer I used the following, but that doesn't work for the color & lwt.

 

Does anyone has an idea?

 

Thanks in advange,

 

Robin

 

L = ThisDrawing.ActiveLayer.Name

LT = ThisDrawing.ActiveLinetype.Name

S = ThisDrawing.ActiveTextStyle.Name

 

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Tekst_zwart")

ThisDrawing.ActiveTextStyle = ThisDrawing.TextStyles.Item("Iso")

ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("Bylayer")

 

ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item(L)

ThisDrawing.ActiveTextStyle = ThisDrawing.TextStyles.Item(S)

ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item(LT)

 

Take a look at system variables "CECOLOR" and "CELWEIGHT"

 

 

You can store variable at the start of code something like this

 

dim ccl

dim cwt

 

ccl = Thisdrawing.Getsystemvariable ("CECOLOR")

 

cwt = ThisDrawing.GetSystemVariable ("CELWEIGHT")

 

and and the end restore all:

 

Thisdrawing.Setsystemvariable("CECOLOR", ccl) etc etc

 

HTH

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...