Jump to content

Description by make Layer


Christina_

Recommended Posts

Hello Cad Users,

I am Christina new to CadTutor and Lisp.

I’m 14 year student with much affection for AutoCad & Autolisp.

And I have a question about Layers…

Found this very nice tutor from Expert Lee Mac and will like to know how to have a description by the layers?

(defun _layer4 ( name colour linetype lineweight plot )
   (if (null (tblsearch "LAYER" name))
       (entmake
           (list
              '(0 . "LAYER")
              '(100 . "AcDbSymbolTableRecord")
              '(100 . "AcDbLayerTableRecord")
              '(70 . 0)
               (cons 2 name)
               (cons 6
                   (if (tblsearch "LTYPE" linetype)
                       linetype
                       "Continuous"
                   )
               )
               (cons 62 colour)
               (cons 290 plot)
               (cons 370 lineweight)
           )
       )
   )
)
(defun c:test4 ( / )
   (foreach item
      '(
           ("Layer7" 4 "HIDDEN"     40 1)
           ("Layer8" 3 "Continuous" 90 0)
           ("Layer9" 2 "PHANTOM"    20 1)
       )
       (apply '_layer4 item)
   )
   (princ)
)

Thank you to read this,

Christina

Link to comment
Share on other sites

Hello Cad Users,

I am Christina new to CadTutor and Lisp.

I’m 14 year student with much affection for AutoCad & Autolisp.

 

Christina

 

Hi Christina , Welcome to CADTutor.

 

Now that's the spirt!

 

And I have a question about Layers…

Found this very nice tutor from Expert Lee Mac and will like to know how to have a description by the layers?

 

ARe you wanting to add layer descriptions? only to the newly created layers? or even existing ones?

 

Quick hack

(defun _layer4 ( name colour linetype lineweight plot des)
   (if (null (tblsearch "LAYER" name))
       [color="blue"](progn[/color]
        (entmake
            (list
               '(0 . "LAYER")
               '(100 . "AcDbSymbolTableRecord")
               '(100 . "AcDbLayerTableRecord")
               '(70 . 0)
                (cons 2 name)
                (cons 6
                    (if (tblsearch "LTYPE" linetype)
                        linetype
                        "Continuous"
                    )
                )
                (cons 62 colour)
                (cons 290 plot)
                (cons 370 lineweight)
            )
        	)
             [color="blue"](command "-layer" "_Description" des name "")[/color]
   		[color="blue"])[/color]
)
     )

(defun c:test4 ( / )
   (foreach item
      '(
           ("Layer7" 4 "HIDDEN"     40 1 [color="blue"]"whoopie"[/color])
           ("Layer8" 3 "Continuous" 90 0  [color="blue"]"hello")[/color]
           ("Layer9" 2 "PHANTOM"    20 1 [color="blue"]"banana cake"[/color])
       )
       (apply '_layer4 item)
   )
   (princ)
)

Edited by pBe
Link to comment
Share on other sites

Hi pBe,

 

 

I will be very happy by new layers, i search few days for this :)

Have try with: (if description (list (list -3 (list "AcAecLayerStandard" (cons 1000 "") (cons 1000 description))))) but no succes

The idea by existing ones make me very curious...

 

Thank you for reply!

Link to comment
Share on other sites

Oh I see, you want a non command line approach. I never really did try to figure out how to add description thru dictionaries. But that will a first for me too.

 

You may try (vla-put-description layerobject "description") but you may need to overhaul the code you posted above. :)

 

The idea by existing ones make me very curious..

 

I know right? But like i said, you may have to re-write the entire code.

Link to comment
Share on other sites

Hi Christina & welcome to CADTutor :)

 

Please try the following:

(defun _layer4 ( lay col lin lwt plt des )
   (if (null (tblsearch "LAYER" lay))
       (progn
           (regapp "AcAecLayerStandard")
           (entmake
               (append
                   (list
                      '(000 . "LAYER")
                      '(100 . "AcDbSymbolTableRecord")
                      '(100 . "AcDbLayerTableRecord")
                      '(070 . 0)
                       (cons 2 lay)
                       (cons 6
                           (if (tblsearch "LTYPE" lin)
                               lin
                               "Continuous"
                           )
                       )
                       (cons 062 col)
                       (cons 290 plt)
                       (cons 370 lwt)
                   )
                   (if des
                       (list
                           (list -3
                               (list "AcAecLayerStandard"
                                   (cons 1000 "")
                                   (cons 1000 des)
                               )
                           )
                       )
                   )
               )
           )
       )
   )
)
(defun c:test4 ( / )
   (foreach item
      '(
           ("Layer7" 4 "HIDDEN"     40 1 "My Hidden Layer")
           ("Layer8" 3 "Continuous" 90 0 "My Continuous Layer")
           ("Layer9" 2 "PHANTOM"    20 1 "My Phantom Layer")
       )
       (apply '_layer4 item)
   )
   (princ)
)

Link to comment
Share on other sites

@ pBe, now I will search about your idea to edit when the Layer exist ;)

@ Lee Mac,

Happy to meet the master of Lisp, we know about your knowledge even in Belgium!

Yes, finally its works, my daddy will happy too!

I have always use regapp on the wrong place…

Both very thank you for the Welcome and to solve my problem! :)

Christina

Link to comment
Share on other sites

You are too kind Christina! - Thank you for your flattering compliments. :)

 

I'm pleased the code is working well for you, and that you are happy with the outcome.

 

All the best.

Link to comment
Share on other sites

Please try the following:

       (progn
           (regapp "AcAecLayerStandard")
           (....)
                   (if des
                       (list
                           (list -3
                               (list "AcAecLayerStandard"
                                   (cons 1000 "")
                                   (cons 1000 des)
                               )
                           )
...
                

 

So that's how its done.

 

Thank you Lee :thumbsup:

Link to comment
Share on other sites

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