Jump to content

help with macro command


rotaidar

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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