Jump to content

Checking if a Layer is present then proceeding?


Recommended Posts

Posted

All,

 

I am confused on how i can create a layer list using VL and see if i can find a perfect match of a particular layer i am looking for. Example:

 

Is P-DOMW-CPIP-D existing in the drawing?

If so, continue.

If not, alert the user.

 

Simple, but i have exhausted my self searching for some samples in the help menu.

 

Thanks ahead of time,

Matt

Posted

(tblsearch "LAYER" "P-DOMW-CPIP-D")

Or if you really want VL...

 

(not
 (vl-catch-all-error-p
   (vl-catch-all-apply 'vla-item
     (list
       (vla-get-Layers
         (vla-get-ActiveDocument
           (vlax-get-acad-object)
         )
       )
       "P-DOMW-CPIP-D"
     )
   )
 )
)

Or checking against a constructed layer list:

(member "P-DOMW-CPIP-D"
 (while (setq def (tblnext "LAYER" (null def)))
   (setq lst (cons (cdr (assoc 2 def)) lst))
 )
)

(vl-position "P-DOMW-CPIP-D"
 (vlax-for l
   (vla-get-Layers
     (vla-get-ActiveDocument
       (vlax-get-acad-object)
     )
   )
   (setq lst (cons (vla-get-Name l) lst))
 )
)

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