BLOACH85 Posted March 26, 2009 Posted March 26, 2009 Hey i have a layer creation lisp that needs to envoke as soon as a drawing opens not load but envoke to where when the dwg is opened the layers are created does anyone know how to do this? Quote
uddfl Posted March 26, 2009 Posted March 26, 2009 http://www.jtbworld.com/lisp/acaddoc.htm Or APPLOAD --> Startup Suite Quote
Lee Mac Posted March 26, 2009 Posted March 26, 2009 As I said in your other thread, make a call to the LISP in your ACADDOC.lsp file, or add it to the start-up suite with (c:lispname) in the LISP file. Quote
oliver Posted March 26, 2009 Posted March 26, 2009 Add it to the start-up suite with (c:lispname) in the LISP file. Absolutely.. Quote
BLOACH85 Posted March 27, 2009 Author Posted March 27, 2009 so if its already in the startup suite all i have to do is put (c:standardlayers) in the lisp file and in the acad2009doc.lsp put the same thing? Quote
Lee Mac Posted March 27, 2009 Posted March 27, 2009 so if its already in the startup suite all i have to do is put (c:standardlayers) in the lisp file and in the acad2009doc.lsp put the same thing? I would do one or the other - not both. As for modifying the acad2009doc.lsp ~ a quote from the link provided by Uddfl: Warning Do not modify the reserved acad2008doc.lsp file. Autodesk provides the acad2008doc.lsp file, which contains AutoLISP-defined functions that are required by AutoCAD. This file is loaded into memory immediately before the acaddoc.lsp file is loaded. How to create acaddoc.lsp if it does not exist... I assume this applies to the '09 file also.... Just a heads-up Lee Quote
BLOACH85 Posted March 27, 2009 Author Posted March 27, 2009 OK i did the other way but im coming up with an error bad function at each dwg load. Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 I would drop the c: in the defun, and call it with (functionname) in startup Quote
BLOACH85 Posted March 27, 2009 Author Posted March 27, 2009 oK it works but i have another question, If i already have the layer created its automatically overwriting it. Most of my layes are set up for the color to be changed. Most of my dwgs if i open them the layer that example was origanlly yellow(bylayer) and i changed to red automatically changes back to bylayer. anyway to stop this? Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 use some logic to see if the layer exists, can you post your code so we can look at it? Im thinking if you try to layer set, if it fails, then create it else skip it Quote
BLOACH85 Posted March 27, 2009 Author Posted March 27, 2009 Here is the code, All of my fixes just arent cutting it. (defun c:standardlayers (/ *error*) (defun *error* (msg) (and Osmode# (setvar "osmode" Osmode#)) (command "_.undo" "_e") (if (not (member msg '("console break" "Function cancelled" "quit / exit abort") ) ;_ member ) ;_ not (princ (strcat "\nError: " msg)) ) ;_ if ) ;_ defun ; Layers (command "layer" "m" "Const" "lt" "continuous" "" "c" "1" "" "") (command "layer" "m" "Steel" "lt" "continuous" "" "c" "2" "" "") (command "layer" "m" "Dimension" "lt" "continuous" "" "c" "4" "" "") (command "layer" "m" "Hidden" "lt" "Hidden" "" "c" "1" "" "") (command "layer" "m" "Text" "lt" "continuous" "" "c" "7" "" "") (command "layer" "m" "Welds" "lt" "continuous" "" "c" "6" "" "") (command "layer" "m" "Ref" "lt" "continuous" "" "c" "8" "" "") (command "-linetype" "load" "hidden" "" "yes" "") (princ) );end of defun (C:standardlayers) When it comes to putting commands in the routines i just get put at a stand still. Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 This works, but its ugly. (if (not (= (command "-layer" "s" "YourLayer" "") nil)) (command "-layer" "m" "YourLayer" "c" "2" "" "") ) Im not much of a lisper, vba is my thing, but the principal is the same Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 the next step would be to make a function you feed with values to simplfy typing. thinking out loud (defun CheckLayer(/ LayerName LayerColor LayerLinetype) (if (not (= (command "-layer" "s" LayerName "") nil)) (command "-layer" "m" LayerName "c" LayerColor "" "lt" LayerLinetype "" "") ) ) which you could call from your main routine as (CheckLayer "Layer1Name" "Layer1Color" "L1LT") Quote
BLOACH85 Posted March 27, 2009 Author Posted March 27, 2009 how did you get it to work all im getting is COMMAND: ERROR TO MANY ARGUMENTS Quote
The Buzzard Posted March 27, 2009 Posted March 27, 2009 Give this a try, ;;;///////////////////////////////////////////////////////////////// (defun c:standardlayers () ;Define function (SET_LAYER) ;Goto SET_LAYER Function (princ) ;Exit quietly ) ;End of define function ;;;///////////////////////////////////////////////////////////////// (defun SET_LAYER () ;Define function (CREATE_LAYER "Const" "1" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Steel" "2" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Dimension" "4" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Hidden" "1" "HIDDEN") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Text" "7" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Welds" "6" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType (CREATE_LAYER "Ref" "8" "CONTINUOUS") ;Goto CREATE_Layer Function, Layer Name, Color, LineType ) ;End define function ;;;///////////////////////////////////////////////////////////////// (defun CREATE_LAYER (NLAY CLR LT / LAY FRZ) ;Define function, Declare variables and arguments (setq LAY (tblsearch "layer" NLAY)) ;Search drawing to find layer (if ;If the following returns true (not LAY) ;Layer not in drawing (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") ;Layer command ~ make new layer with color and linetype (progn ;Then do the following (setq FRZ (cdr (assoc 70 LAY))) ;Variable FRZ is frozen layer (if (= FRZ 65) ;Layer frozen from last edit (progn ;Then do the following (command "_.layer" "t" NLAY "") ;Thaw new layer if frozen (command "_.layer" "s" NLAY "") ;Set new layer ) ;End progn (otherwise...) (command "_.layer" "s" NLAY "") ;Set new layer ) ;End if ) ;End progn (otherwise...) ) ;End if ) ;End define function ;;;///////////////////////////////////////////////////////////////// Quote
The Buzzard Posted March 27, 2009 Posted March 27, 2009 BLOACH, Sorry, Just edited the SET_LAYER function to make color corrections to match the function you posted. The Buzzard Quote
Lee Mac Posted March 27, 2009 Posted March 27, 2009 Did this not work for you? http://www.cadtutor.net/forum/showpost.php?p=224949&postcount=5 Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 how did you get it to work all im getting is COMMAND: ERROR TO MANY ARGUMENTS which part did you try? The first one worked for me, the second one I was thinking out loud Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 after more testing, it only works if the layer already exists. I would use Lee's or Buzzard's method, as they know LISP better than I Quote
Recommended Posts
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.