Jump to content

VBA how to check for layers and create some?


firavolla

Recommended Posts

Simple question.

What I want is when the user clicks a button, a macro will execute some vba code and check if the current drawing has/has not some layers in it...like layerA, layerB, layerC. If the drawing does not have those layers, then create them for the current drawing.

Any help?Advice? Thank you.

Link to comment
Share on other sites

Ok...So I've managed to do that...But the question now is how to set the color of the linetype of the layer? It's something like

ThisDrawing.Layers.Item(counter).TrueColor=??????

Link to comment
Share on other sites

I believe AutoCAD 2004 has the older .color property still avaialble, though not listed in the help files.

 

The newer .TrueColor can be modified by first creating the object:

 

Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")

 

then modifying the properties accordingly:

 

Call color.SetRGB(80, 100, 244)

 

finally:

 

ThisDrawing.Layers.Item(counter).TrueColor = color

 

Code taken from the Developer Documentation Examples

Link to comment
Share on other sites

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...