rotaidar Posted October 21, 2017 Posted October 21, 2017 Hi. Can someone please help me, tell me or explain to me how to create new layer with macro. I want define a new button which when I push it will make new layer and ask me for define name and colour of new layer. I'm kind a new to this. I found only this code using LISP. But I want macro for button. (defun c:SetLayer (/ name col) (if (setq name (getstring t "New layer name: ")) (if (tblsearch "LAYER" name) (progn (prompt "Layer already exists, set as current.") (setvar "CLayer" name)) (if (setq col (acad_colordlg 7 nil)) (progn (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) (cons 2 name) (cons 62 col))) (prompt "Layer created and set current.") (setvar "CLayer" name))))) (princ)) Thank you for your time guys and have a nice day Quote
BIGAL Posted October 22, 2017 Posted October 22, 2017 Add something like a DCL for the questions see below for getvals3.lsp ; can add linetype if required (defun c:SetLayer ( / name col ) (if (not AH:Getval3)(Load "getval3")) (ah:getval3 "Enter layer name"12 10 "New" "Enter Colour" 5 4 "3" "Enter Linetype"12 10 "Continuous") (setq name val1 col val2) (if (tblsearch "LAYER" name) (progn (prompt "Layer already exists, set as current.") (setvar "CLayer" name)) (if (setq col (acad_colordlg 7 nil)) (progn (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(70 . 0) (cons 2 name) (cons 62 col))) ; add linetype here (prompt "Layer created and set current.") (setvar "CLayer" name)))) (princ)) GETVALS3.lsp Quote
rotaidar Posted October 22, 2017 Author Posted October 22, 2017 Thank you BIGAL but I want know how to do that in macro. I mean how to write it here. Sorry for my english Quote
BIGAL Posted October 22, 2017 Posted October 22, 2017 ^c^c^p(if (not c:setlayer)(Load "setlayer"))(C:setlayer) Quote
rotaidar Posted October 23, 2017 Author Posted October 23, 2017 Thank you very much :-) it is great Quote
rotaidar Posted November 25, 2017 Author Posted November 25, 2017 Is there any way how to write it all as macro and not only as reference link for that command? Thank you for your time Quote
tombu Posted November 27, 2017 Posted November 27, 2017 Untested: ^C^C-LA M \C About Pausing Macros for User Input: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-9D921CDD-89A3-44AB-865A-00F8986611F2 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.