Jump to content
tigger29900

Layer Properties using VBA

Recommended Posts

tigger29900

Newbie here

 

i have been using this forum frequently as of late and had a question i was hoping you could help me with.

 

I am building a program in visual basic to select certain layers and change their color to outline a certain path on a layer diagram. I need to program a clear button that sets all of the layer colors back to color 7 as efficiently as possible

any help would be appreciated

 

Secondly and less important

 

I was trying to figure out a way to select all of the text in the selected layers and export them to excel to build an effected equipment list. )I'm not sure if this is even possible)

 

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites
BlackBox

Welcome to CADTutor!

 

You may find posting questions like this answered more quickly, appropriately, when posted in one of the programming forums found here. Also be sure to use

[/url] when posting code.

Perhaps a moderator can move this? 

[quote name='tigger29900']
I am building a program in visual basic to select certain layers and change their color to outline a certain path on a layer diagram. I need to program a clear button that sets all of the layer colors back to color 7 as efficiently as possible[/quote]

I'd personally recommend that you use Visual LISP, or VB.NET in lieu of VBA, just because there's a lot more support (i.e., sample code, tutorials, documentation, etc.) to help you learn.

In any event, use the ClearButton_Click Event to iterate through the Layers Collection, and change the Color Property.

Visual LISP example:

[code]
(defun c:FOO ()
 (vl-load-com)
 ((lambda (acDoc / oLayer)
    (vlax-for oLayer (vla-get-layers acDoc)
      (if (/= acWhite (vla-get-color oLayer))
        (vla-put-color oLayer acWhite))))
   (vla-get-activedocument (vlax-get-acad-object)))
 (princ))

 

 

Yes, this is possible. Give the programming forums a search, as I am sure this has been discussed before.

 

Hope this helps (HTH).

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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