Jump to content

Getting help from the Autocad ActiveX and VBA reference


Recommended Posts

Posted
for example , a specific layer without extracting it out of its collection

 

Since all Layer objects are stored within the Layers Collection, you would inexorably need to retrieve the Layer object from the Collection in order to operate on it, for example, to lock Layer "0":

 

Using Visual LISP:

(if
   (not
       (vl-catch-all-error-p
           (setq lay
               (vl-catch-all-apply 'vla-item
                   (list
                       (vla-get-layers
                           (vla-get-activedocument
                               (vlax-get-acad-object)
                           )
                       )
                       "0"
                   )
               )
           )
       )
   )
   (vla-put-lock lay :vlax-true)
)

Using Vanilla AutoLISP:

(if (setq lay (tblobjname "layer" "0"))
   (progn
       (setq lay (entget lay)
             bit (assoc 70 lay)
       )
       (entmod (subst (cons 70 (logior 4 (cdr bit))) bit lay))
   )
)

Using a combination of Vanilla / Visual:

(if (setq lay (tblobjname "layer" "0"))
   (vla-put-lock (vlax-ename->vla-object lay) :vlax-true)
)

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    10

  • samifox

    10

  • asos2000

    1

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