Jump to content
rotaidar

help with macro command

Recommended Posts

rotaidar

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

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
rotaidar

Thank you BIGAL but I want know how to do that in macro.

JzJAdgE.png

 

I mean how to write it here.

Sorry for my english

Share this post


Link to post
Share on other sites
BIGAL

^c^c^p(if (not c:setlayer)(Load "setlayer"))(C:setlayer)

Share this post


Link to post
Share on other sites
rotaidar

Thank you very much :-) it is great

Share this post


Link to post
Share on other sites
rotaidar

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×