Jump to content

Search for a layer and create if it doesn't exist


playerdraft123

Recommended Posts

Hello, I am hoping that someone can help me with creating a lisp routine that will search an open drawing for a specific layer, and if that layer doesn't exist within the drawing, then the lisp routine will create it (specifying a color, linetype, etc). Any help on this would be greatly appreciated.

Link to comment
Share on other sites

Welcome to CADTutor. :)

 

This old post may be of use to you.

 

Also, consider:

 

(if (tblsearch "layer" "[color=red]YourLayerName[/color]")
 ;; Layer exists
 ;; Layer does not exist
)

Edited by BlackBox
Link to comment
Share on other sites

This old post may be of use to you.

 

Thanks Renderman, I am pretty new to this. I tried to pick my way through the code in the post that you linked to without much success. It looks like it picks a layer from an excel (csv) file. I will try to find something on the forums to accompany the table search function that you posted, and post my results.

Link to comment
Share on other sites

Thanks Renderman, I am pretty new to this. I tried to pick my way through the code in the post that you linked to without much success. It looks like it picks a layer from an excel (csv) file. I will try to find something on the forums to accompany the table search function that you posted, and post my results.

 

You're welcome.

 

If you're just starting out, you might consider the -LAYER Command, before getting into some of the complexities inherent to the CSV method noted in my other post. :thumbsup:

Link to comment
Share on other sites

Hello, I am hoping that someone can help me with creating a lisp routine that will search an open drawing for a specific layer, and if that layer doesn't exist within the drawing, then the lisp routine will create it (specifying a color, linetype, etc). Any help on this would be greatly appreciated.

 

(command "-layer" "make" "text" "color" "7" "" "")

or

(command "-layer" "m" "text" "c" "7" "" "")

 

If the layer exists it just makes it the current layer, sets the color to 7, if the layer doesn't exist it makes it and set the color to 7.

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