+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Forum Newbie
    Discipline
    Surveying
    Using
    AutoCAD 2017
    Join Date
    Oct 2017
    Posts
    3

    Default help with macro command

    Registered forum members do not see this ad.

    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.
    Code:
    (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

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    Add something like a DCL for the questions see below for getvals3.lsp

    Code:
    ; 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))
    Attached Files
    A man who never made mistakes never made anything

  3. #3
    Forum Newbie
    Discipline
    Surveying
    Using
    AutoCAD 2017
    Join Date
    Oct 2017
    Posts
    3

    Default

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


    I mean how to write it here.
    Sorry for my english

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    ^c^c^p(if (not c:setlayer)(Load "setlayer"))(C:setlayer)
    A man who never made mistakes never made anything

  5. #5
    Forum Newbie
    Discipline
    Surveying
    Using
    AutoCAD 2017
    Join Date
    Oct 2017
    Posts
    3

    Default

    Registered forum members do not see this ad.

    Thank you very much :-) it is great

Similar Threads

  1. Macro - Unknown command for any multiple command
    By p0peye in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 2
    Last Post: 2nd Nov 2013, 10:27 am
  2. SELECT in macro won't stay selected!!!! How to hide Macro in command line aswell?
    By jamesfear in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 11
    Last Post: 31st Jul 2012, 02:23 am
  3. Macro command in command prompts shortcut?
    By Benjo in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 13
    Last Post: 10th Feb 2011, 04:11 am
  4. Macro command in command prompts shortcut?
    By Benjo in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 1
    Last Post: 8th Feb 2011, 05:57 pm
  5. Create a Command to run macro from command line
    By Andresig in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 16th Sep 2010, 09:16 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts