Jump to content

Help With lisp for auto layer creation..??


Recommended Posts

Posted

Hey guys im currently working on a lisp to create standard layers but here is my two problems. I want it to automatically envoke at each drawing startup to create the layers. also if the layer allready exists i want it to overwrite it. Is there any way to do this?

Posted

Well, to make it run at the startup of each drawing session, just make a call to it in your ACADDOC.lsp file :)

Posted
also if the layer allready exists i want it to overwrite it

 

Do you mean delete that layer and everything on it and create your one, or just change some properties of the old one?

Posted

Well pretty much if its there i dont want to completely delete it and everything on it, Just change properties so all draftsmen are using fully uniformed layers. Let me ask you another question, I have a computer up here that will not load a custom linetype that is in the acad.lin all other linetypes load but the user defined will not. its in the right place on the search path but am i missing something? I have been working on it all morning.

Posted

I'm not sure about your linetype issue, but for the layers, something in this format would do the trick:

 

(defun c:layupd (/ oldcmd laylist)
 (setq oldcmd (getvar "CMDECHO")) (setvar "CMDECHO" 0)

 (setq laylist '(("LAYER1" "4" "CONTINUOUS")
         ("LAYER2" "3" "HIDDEN")))

 (foreach lay laylist
   (if (not (tblsearch "LAYER" (car lay)))
     (command "-layer" "m" (car lay) "C" (cadr lay) (car lay) "")
     (command "-layer" "C" (cadr lay) (car lay) ""))
   (if (tblsearch "LTYPE" (caddr lay))
     (command "-layer" "LT" (caddr lay) (car lay) "")
     (princ (strcat "\n" (caddr lay) " Linetype could not be found!"))))

 (setvar "CMDECHO" oldcmd)
 (princ))

(c:layupd)

 

This will update the layers as specified in the layer list at the top, this will update colour and linetype, but can be modified if necessary.

Posted

Word of advice:

entmake will return nil if layer exists so you will need to have two conditions:

1. entmake new layers

2. entmod existing layers not correctly defined.

Posted
Word of advice:

entmake will return nil if layer exists so you will need to have two conditions:

1. entmake new layers

2. entmod existing layers not correctly defined.

 

Just using the "command call" seems to work :thumbsup:

Posted

Sure it does. Command works good.

But if you want to create a thousand layers or so in the blink of an eye, your going to need something a bit more beefy then just command. *wink*

Posted
Sure it does. Command works good.

But if you want to create a thousand layers or so in the blink of an eye, your going to need something a bit more beefy then just command. *wink*

 

Hehe ok, cheers John :)

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