autolisp Posted February 24, 2011 Share Posted February 24, 2011 Dear all Plz advice which is best method of create layer inside the lisp 1st (setq oldlayer (getvar "CLAYER")) (if (tblsearch "LAYER" "Dr") (setvar "CLAYER" "Dr") (command ".LAYER" "M" "Dr" "C" "6" "" "") ) (setvar "CLAYER" oldlayer) 2nd (if (not (tblsearch "layer" "dr")) (progn(command ".LAYER" "M" "dr" "C" "50" "" ""))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 24, 2011 Share Posted February 24, 2011 I guess this is one of the best .. (if (not (tblsearch "LAYER" "Dr")) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "Dr") (cons 70 0) (cons 62 6) )) ) Tharwat Quote Link to comment Share on other sites More sharing options...
autolisp Posted February 24, 2011 Author Share Posted February 24, 2011 I guess this is one of the best .. (if (not (tblsearch "LAYER" "Dr")) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "Dr") (cons 70 0) (cons 62 6) )) ) Tharwat dear sir thx for suggestion Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 24, 2011 Share Posted February 24, 2011 dear sirthx for suggestion You're welcome anytime . Tharwat Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 24, 2011 Share Posted February 24, 2011 If you really want in insure setting to a layer: ;++++++++++++ Make Layer Current +++++++++++++++++++++++++++++++++ (defun SetLayer (name / ldef flag) (cond ((or (not name) (not (snvalid name))) (princ "\nBad Aurgment Passed To SetLayer - ") (prin1 name) (exit))) (command "_.LAYER") (if (not (tblsearch "LAYER" name)) (command "_Make" name) (progn (setq ldef (tblsearch "LAYER" name) flag (cdr (assoc 70 ldef))) (and (= (logand flag 1) 1) (command "_Thaw" name)) (and (minusp (cdr (assoc 62 ldef))) (command "_On" name)) (and (= (logand flag 4) 4) (command "_Unlock" name)) (and (= (logand flag 16) 16) (princ "\nCannot Set To XRef Dependent Layer") (quit)) (command "_Set" name))) (command "") name) -David Quote Link to comment Share on other sites More sharing options...
BlackBox Posted February 24, 2011 Share Posted February 24, 2011 Building on David's example... this uses ActiveX: (defun SetLayer2 (layerName / activeDoc layerTable layerItem) (vl-load-com) (vla-startundomark (setq activeDoc (vla-get-activedocument (vlax-get-acad-object)))) (if (= 'STR (type layerName)) (if (not (vl-string-search "|" layerName)) (progn (setq layerTable (vla-get-layers activeDoc)) (if (tblsearch "layer" layerName) (progn (setq layerItem (vla-item layerTable layerName)) (vla-put-freeze layerItem :vlax-false)) (vla-put-layeron layerItem :vlax-true) (vla-put-lock layerItem :vlax-false) (setq layerItem (vla-add layerTable layerName))) (vla-put-activelayer activeDoc layerItem)) (prompt "\n <!> Cannot Set to Xref Dependent Layer <!> ")) (progn (prompt "\n <!> Invalid Argument - ") (prin1 name) (prompt " <!> "))) (vla-endundomark activeDoc) (princ)) Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 24, 2011 Share Posted February 24, 2011 http://www.theswamp.org/index.php?topic=33041.msg384939#msg384939 Quote Link to comment Share on other sites More sharing options...
ccowgill Posted February 24, 2011 Share Posted February 24, 2011 or http://forums.augi.com/showthread.php?t=122277&highlight=layerlist and http://www.theswamp.org/index.php?topic=35588.0;all Quote Link to comment Share on other sites More sharing options...
autolisp Posted February 25, 2011 Author Share Posted February 25, 2011 Dear all thx for help me, i will try & revert back thx Quote Link to comment Share on other sites More sharing options...
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.