Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

layer status field

13 REPLIES 13
Reply
Message 1 of 14
jledgewood409
613 Views, 13 Replies

layer status field

as I had with my past firm, I would like to create a tool on the tool palette that will create a layer for demo, existing, future, etc. the idea behind these layers as at my previous firm is that you can drag them from the tool palette and they will add a status field extension to every layer already in the dwg. can anyone help me with that?

13 REPLIES 13
Message 2 of 14

hi you can try command>LMAN (layer manager). hope it helps. thanks





Remember : without the difficult times in your LIFE, you wouldn't be who you are today. Be grateful for the good and the bad. ANGER doesn't solve anything. It builds nothing, but it can destroy everything...
Please mark this response as "Accept as Solution" if it answers your question. Kudos gladly accepted.
Message 3 of 14

to add to my original post I have a lisp routine that goes with it. I cant remember how I applied it to work. the idea is that you have established layers i.e. a-wall, a-door, a-flr, etc. that you would apply this lisp and you would gey addition layers with appropriate color and linetype i.e. a-wall-demo, a-door-exist, etc. I had this set up so that I would hit the button in the tool palette and those new layers would populate. I will attach the lisp routine if that helps. I am trying to attach the lisp routine but it wont let me. I will see if I can copy/ paste into this post.

 

;;
;; Sets color and linetype back to bylayer
;;

(defun cllt ()
    (setvar "cecolor" "bylayer")
    (setvar "celtype" "bylayer")
)

;;===== Status Fields =====

;;Adds the status field of "-demo" to all layers in a drawing

(defun c:lay_demo (/ LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
    (cllt)
     (setvar "expert" 5)
     (command "linetype" "load" "dashed2" "" "")    ;loads the dashed2 linetype
     (setvar "expert" 2)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))              ;sets up the table for layers
     (while lname                                ;starts while loop
           (setq lname (strcase (cdr (assoc 2 lname)) T)) ;gets the layer name
            (cond
             ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
              ); 'a wildcard match
              (setq lnmlst (cons lname lnmlst))         ;if no wildcard match, cons layer name
                                                      ;to layer list for layer creation  
                 )
            )
           (setq lname (tblnext "layer"))               ;grabs the next layer
     )
    (foreach L LNMLST                              ;loops through valid layers
        (setq NEWL (strcat L "-demo"))                ;and creates new layers
        (entmake (list '(0 . "layer")
                 '(5 . "28")                    ;handle
                 '(100 . "AcDbSymbolTableRecord")
                 '(100 . "AcDbLayerTableRecord")
                 (cons 2 NEWL)                  ;new layer name
                 '(70 . 64)                     ;flag
                 '(62 . 3)                      ;color
                 '(6 . "dashed2")               ;linetype
          )
           )
     )
    (setvar "cmdecho" 1)
)

;;Adds the status field of "-exst" to all layers in a drawing

(defun c:lay_exst (/ LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
     (cllt)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))                      ;sets up the table for layers
     (while lname                                ;starts while loop
           (setq lname (strcase (cdr (assoc 2 lname)) T)) ;gets the layer name
            (cond
             ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
              ); 'a wildcard match
              (setq lnmlst (cons lname lnmlst))         ;if no wildcard match, cons layer name
                                                      ;to layer list for layer creation  
                 )
            )
           (setq lname (tblnext "layer"))               ;grabs the next layer
     )
    (foreach L LNMLST                                      ;loops through valid layers
        (setq NEWL (strcat L "-exst"))                    ;and creates new layers
        (entmake (list '(0 . "LAYER")
                 '(5 . "28")                            ;handle
                 '(100 . "AcDbSymbolTableRecord")
                 '(100 . "AcDbLayerTableRecord")
                 (cons 2 NEWL)                      ;new layer name
                 '(70 . 64)                         ;flag
                 '(62 . 1)                          ;color
                 '(6 . "continuous")                   ;linetype
             )
           )
     )
    (command "layer" "color" "12" "*-hphv-exst,*-hplt-exst" "")
    (setvar "cmdecho" 1)
)

;;Adds the status field of "-futr" to all layers in a drawing

(defun c:lay_futr (/ CNAME TNAME LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
     (cllt)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))                    ;sets up the table for layers
     (while lname                            ;starts while loop
        (setq cname (cdr (assoc 62 lname)))         ;gets the layer color
        (setq tname (strcase (cdr (assoc 6 lname)) T))     ;gets the layer linetype
           (setq lname (strcase (cdr (assoc 2 lname)) T))     ;gets the layer name
            (cond
                 ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
                ) ; 'a wildcard match
            (setq NEWL (strcat lname "-futr"))            ;and creates new layers
            (entmake
                (list
                    '(0 . "LAYER")
                             '(5 . "28")                        ;handle
                             '(100 . "AcDbSymbolTableRecord")
                             '(100 . "AcDbLayerTableRecord")
                             (cons 2 NEWL)                      ;new layer name
                             '(70 . 64)                         ;flag
                             (cons 62 cname)                     ;color
                             (cons 6 tname)                       ;linetype
                     )
               )
               )
            )
           (setq lname (tblnext "layer"))                   ;grabs the next layer
     )
    (setvar "cmdecho" 1)
)

;;Adds the status field of "-move" to all layers in a drawing

(defun c:lay_move (/ CNAME TNAME LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
     (cllt)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))                    ;sets up the table for layers
     (while lname                            ;starts while loop
        (setq cname (cdr (assoc 62 lname)))         ;gets the layer color
        (setq tname (strcase (cdr (assoc 6 lname)) T))     ;gets the layer linetype
           (setq lname (strcase (cdr (assoc 2 lname)) T))     ;gets the layer name
            (cond
                 ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
            ) ; 'a wildcard match
            (setq NEWL (strcat lname "-move"))            ;and creates new layers
            (entmake
                (list
                    '(0 . "LAYER")
                             '(5 . "28")                        ;handle
                             '(100 . "AcDbSymbolTableRecord")
                             '(100 . "AcDbLayerTableRecord")
                             (cons 2 NEWL)                      ;new layer name
                             '(70 . 64)                         ;flag
                             (cons 62 cname)                     ;color
                             (cons 6 tname)                       ;linetype
                     )
               )
               )
            )
           (setq lname (tblnext "layer"))                   ;grabs the next layer
     )
    (setvar "cmdecho" 1)
)

;;Adds the status field of "-nicn" to all layers in a drawing

(defun c:lay_nicn (/ LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
    (cllt)
     (setvar "expert" 5)
     (command "linetype" "load" "hidden2" "" "")    ;loads the dashed2 linetype
     (setvar "expert" 2)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))              ;sets up the table for layers
     (while lname                                            ;starts while loop
           (setq lname (strcase (cdr (assoc 2 lname)) T)) ;gets the layer name
            (cond
             ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
              ); 'a wildcard match
              (setq lnmlst (cons lname lnmlst))         ;if no wildcard match, cons layer name
                                                      ;to layer list for layer creation  
                 )
            )
           (setq lname (tblnext "layer"))                   ;grabs the next layer
     )
    (foreach L LNMLST                                      ;loops through valid layers
        (setq NEWL (strcat L "-nicn"))                    ;and creates new layers
        (entmake (list '(0 . "LAYER")
                 '(5 . "28")                    ;handle
                 '(100 . "AcDbSymbolTableRecord")
                 '(100 . "AcDbLayerTableRecord")
                 (cons 2 NEWL)                  ;new layer name
                 '(70 . 64)                     ;flag
                 '(62 . 😎                      ;color
                 '(6 . "hidden2")               ;linetype
          )
           )
     )
    (setvar "cmdecho" 1)
)

;;Adds the status field of "-relo" to all layers in a drawing

(defun c:lay_relo (/ CNAME TNAME LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
     (cllt)
     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))                    ;sets up the table for layers
     (while lname                            ;starts while loop
        (setq cname (cdr (assoc 62 lname)))         ;gets the layer color
        (setq tname (strcase (cdr (assoc 6 lname)) T))     ;gets the layer linetype
           (setq lname (strcase (cdr (assoc 2 lname)) T))     ;gets the layer name
            (cond
                 ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
            ) ; 'a wildcard match
            (setq NEWL (strcat lname "-relo"))            ;and creates new layers
            (entmake
                (list
                    '(0 . "LAYER")
                             '(5 . "28")                        ;handle
                             '(100 . "AcDbSymbolTableRecord")
                             '(100 . "AcDbLayerTableRecord")
                             (cons 2 NEWL)                      ;new layer name
                             '(70 . 64)                         ;flag
                             (cons 62 cname)                     ;color
                             (cons 6 tname)                       ;linetype
                     )
               )
               )
            )
           (setq lname (tblnext "layer"))                   ;grabs the next layer
     )
    (setvar "cmdecho" 1)
)

;;=========== Base Bid Layers vs. Alternate Layers =================

;;Adds the status field of "-BB*" & "-AT*" to all layers in a drawing

(defun c:lay_bb (/ CNAME TNAME LNAME LNMLST NEWL)
    (setvar "cmdecho" 0)
     (cllt)
    (setq bbno (getint "\n Please enter the Base Bid Number: "))
    
    (if (or (< bbno 9)(= bbno 9))                    ;if the base bid number
        (setq bbno (strcat "0" (rots bbno(2,1))))                ;is lessthan or eq to 9 then
    )                                    ;add "0" to the number

     (setq LNMLST nil)
     (setq lname (tblnext "layer" T))                    ;sets up the table for layers
     (while lname                            ;starts while loop
        (setq cname (cdr (assoc 62 lname)))         ;gets the layer color
        (setq tname (strcase (cdr (assoc 6 lname)) T))     ;gets the layer linetype
           (setq lname (strcase (cdr (assoc 2 lname)) T))     ;gets the layer name
            (cond
                 ((/=
                  (wcmatch lname '"0,*|*,*defpoints*,*noplot*,*demo*,*exst*,*futr*,*move*,*nicn*,*relo*,*temp*,*anno*,*code*,*strc-grid,*iden*,*hphv*,*hplt*,*sh10*,*sh11*,*sh12*,*sh13*,*sh14*,*tblk*,*-bb*,*-al*") T
            ) ; 'a wildcard match
            (setq NEWLBB (strcat lname "-bb" bbno))            ;and creates new layers
            (entmake
                (list
                    '(0 . "LAYER")
                             '(5 . "28")                        ;handle
                             '(100 . "AcDbSymbolTableRecord")
                             '(100 . "AcDbLayerTableRecord")
                             (cons 2 NEWLBB)                      ;new layer name
                             '(70 . 64)                         ;flag
                             (cons 62 cname)                     ;color
                             (cons 6 tname)                       ;linetype
                     )
               )
            (setq NEWLAL (strcat lname "-al" bbno))            ;and creates new layers
            (entmake
                (list
                    '(0 . "LAYER")
                             '(5 . "28")                        ;handle
                             '(100 . "AcDbSymbolTableRecord")
                             '(100 . "AcDbLayerTableRecord")
                             (cons 2 NEWLAL)                      ;new layer name
                             '(70 . 64)                         ;flag
                             (cons 62 cname)                     ;color
                             (cons 6 tname)                       ;linetype
                     )
               )
               )
            )
           (setq lname (tblnext "layer"))                   ;grabs the next layer
     )
    (setvar "cmdecho" 1)
)

Message 4 of 14
acadhelp1
in reply to: jledgewood409

Is the problem adding this lisp command in the tool palette?
If so, then you need to look for the "command tool" and duplicate it and edit the duplicate tool. Hope this helps.


Jon Page

AutoCAD Design Manager
Message 5 of 14
jledgewood409
in reply to: acadhelp1

I suppose that could be the problem. I believe I am missing a step. where do I start to look for the "command tool?"

I believe that is where I am stuck.

Message 6 of 14

my ulitmate goal is to get the lisp routine to work so I can have the layers with the extension -demo, -exist, etc. from my lisp routine or any other way. it doesnt have to be associated with the tool palette, although that would make it easier.

Message 7 of 14
scot-65
in reply to: jledgewood409

If one is wanting to post a LSP file, and it does not want to
attach, create a copy of the file and add a dot-TXT to the end.
Example: AA.lsp to AA.lsp.txt
Now it will attach.

As far as your ultimate goal, look into threads that talk about
ACADDOC.LSP, ACAD.LSP, or having the file extension MNL.
These will load when the editor is first started.
Don't forget about the secure location path...

Next part of your ultimate goal is to create a command in the CUI.
Once that is accomplished, you can use that command not only
on the keyboard (no CUI is needed for the keyboard method), but
in all other UI areas including the ribbon, screen menu, pull-down,
and toolbars. Close that tool palette - It's only there as a poor-mans
way of enhancing the AutoCAD editor (ditto with the startup suite).

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 8 of 14
acadhelp1
in reply to: scot-65

Scot-65 is right.  Tool Palettes are just a launching mechanism, like a button on the Ribbon, Toolbar, menu or just typing the command name.  

 

If you want the access through Tool Palette (after getting the loading worked out), you can add the lisp commands as tools in the Tool Palette. You can find the command tool in the "Command Tool Samples" tab of Tool Palettes. See the attached image.  

 

Hope this helps,

Jon



Jon Page

AutoCAD Design Manager
Message 9 of 14
jledgewood409
in reply to: scot-65

how do I go about creating a command for that lisp routine?

before I would left click on the icon in the tool pallette and drag it to the screen and drop it. from that point all layers have duplicate layer with the extension -demo, -exist, etc.

 

I am also attaching the lisp routine with the .txt extension

 

this lisp routine worked a couple of years ago, so it was on an earlier version of CAD. probably autocad 2012 or 2013.

Message 10 of 14
acadhelp1
in reply to: jledgewood409

The lisp routine should still work.

I'm looking at what you pasted earlier, the commands are already defined.  They look like this: (defun c:lay_demo (/ LNAME LNMLST NEWL). The "defun c:" will denote commands.  Without the "c:", these are functions that can be call within this lisp code, not directly at command line. There are several other commands in there.  I will leave those for you to find.  Be sure to look at the comments, they start at the ; (semi-colon).

 

I am not great with lisp, so I only know basics, but I know this much.  🙂 You should try to learn a little more about this code.

Oh by the way, you still need to get this lisp code to autoload.  Check out the topics that Scot-65 mentions.

 

Hope this helps a little.



Jon Page

AutoCAD Design Manager
Message 11 of 14
jledgewood409
in reply to: acadhelp1

I found the commands. to type out the command is rather longwinded. how can I make this a tool on a toolbar? or a tool on a tool pallette?

Message 12 of 14
Balaji_Ram
in reply to: jledgewood409

Hi,

 

You can add a new command and drag it to the tool palette.

To do this, right click the mouse button and select "Customize commands" and add a new command.

Customize the macro for the new command to have it invoke your Lisp command.

 

I have attached a screenshot to show the steps.

 

If you want to create the tool palette shortcut using the API, you can have a look at the "samples\editor\SimpleToolPalette_dg" sample in the ObjectARX SDK.

 

Regards,

Balaji

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 13 of 14
jledgewood409
in reply to: Balaji_Ram

I believe that is where I get stuck, the macro. I cant remember where to get the information to type in the macro line of hte new command?

Message 14 of 14
Balaji_Ram
in reply to: jledgewood409

Hi,

 

I had some issues in posting my reply to this forum post, so had to send an email directly.

I am repeating it here just in case it is needed in future.

 

<<<

The Lisp statements can be directly embedded in those macros. 

For example, this should invoke the custom command implemented in VLisp :^C^C(c:test)

After you have created a new command, drag it over the tool palette. After the shortcut has been created, right click on it and customize its properties to include the macro.
You will find more info on using Lisp statement in macros here :http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS73099cc... 

>>>

 

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost