Jump to content

Issue With Layers


skotseno
 Share

Recommended Posts

I am new to this but I need a lisp that would create the following layers with every (even pre existing) files that I open.

 

Layer: 1 in cyan, 2 in white, 2L in white, 3 in red, 4 in yellow, 5 in white, 6 in blue, SK1 in cyan, SK2 in white, SK3 in red, SK4 in yellow, and SK6 in blue.

 

I have looked at existing lisps and macros but I am new and am having trouble making sense of them.

Link to comment
Share on other sites

I think this will do the trick; please try to fill by yourself the remaining cases:

(foreach layerItem '([color=blue][color=red]("1" 4) [color=orange]("2" 7)[/color][/color] ("2L" 7)[/color])
(entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord")
               (cons 2 (car layerItem)) '(70 . 0) (cons 62 (cadr layerItem)) '(6 . "Continuous")))
)

Link to comment
Share on other sites

I am new to this but I need a lisp that would create the following layers with every (even pre existing) files that I open.

 

Layer: 1 in cyan, 2 in white, 2L in white, 3 in red, 4 in yellow, 5 in white, 6 in blue, SK1 in cyan, SK2 in white, SK3 in red, SK4 in yellow, and SK6 in blue.

 

I have looked at existing lisps and macros but I am new and am having trouble making sense of them.

 

Why not simply make these layers part of your template? :unsure:

 

I think this will do the trick; please try to fill by yourself the remaining cases:

(foreach layerItem '([color=blue][color=red]("1" 4) [color=orange]("2" 7)[/color][/color] ("2L" 7)[/color])
(entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord")
               (cons 2 (car layerItem)) '(70 . 0) (cons 62 (cadr layerItem)) '(6 . "Continuous")))
)

 

Building on Mircea's post, here's a Visual LISP adaptation:

 

((lambda (oLayers / layerName)
  (foreach layerItem '(("1" 4) ("2" 7) ("2L" 7))
   (vla-put-color
     (apply
       (if (tblsearch "layer" (setq layerName (car layerItem)))
        'vla-item
        'vla-add
       )
       (list oLayers layerName)
     )
     (cadr layerItem)
   )
  )
)
 (vla-get-layers
   (vla-get-activedocument (vlax-get-acad-object))
 )
)

Link to comment
Share on other sites

Why not simply make these layers part of your template?

That was my first thought also, but next notified that OP was looking to have that layer structure created on existing drawings too.

Link to comment
Share on other sites

Old fashioned script will do also just open in notepad add layers change etc

 

-la
n layer1 C layer1 1
n layer2 C layer2 2
n layer3 C layer3 3

Link to comment
Share on other sites

Thanks Lee Mac! I tried posting this code into acaddoc but nothing happens. please advise.

 

(defun _layer3 ( name color linetype lineweight plot )

(if (null (tblsearch "LAYER" name))

(entmake

(list

'(0 . "LAYER")

'(100 . "AcDbSymbolTableRecord")

'(100 . "AcDbLayerTableRecord")

'(70 . 0)

(cons 1 name)

(cons 6 linetype)

(cons 4 colour)

(cons 290 plot)

(cons 15 lineweight)

)

)

)

)

 

(_layer3 "2" 7 "Continuous" 15 1)

(_layer3 "2L" 7 "Continuous" 15 1)

(_layer3 "3" 1 "Hidden" 15 1)

(_layer3 "4" 2 "Center" 15 1)

(_layer3 "SK1" 4 "Continuous" 15 1)

(_layer3 "SK2" 7 "Continuous" 15 1)

(_layer3 "SK3" 1 "Hidden" 15 1)

(_layer3 "SK4" 2 "Center" 15 1)

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

 Share

×
×
  • Create New...