Monday 18 February 2013

Create New Layer





Autolisp Codes :
(defun c:Newlayer (/ Layername Color)
  ;;Author:Ganesh Shetty, Copyright © 2013 -http://autolispgs.blogspot.in
  (setq Layername(getstring "\nEnter New Layer Name:"))
  (if (not (Tblsearch "LAYER" Layername))
    (progn
      (setq color(getint "\nEnter Color Type for New Layer:"))
      (command "_Layer" "New" layername "c" color layername "")
      (princ(strcat "\nLayer \"" layername "\"Created ."))
    )
    (princ "\nLayer Name Already exist.")
  )
  (princ)
);end defun



Visual Lisp Codes:


(Defun c:New-layer()
  (vl-load-com)
  (setq *Activedoc(vla-get-activedocument(vlax-get-acad-object)))
  (setq layers(vla-get-layers *Activedoc))
  (setq Nlay(getstring "\nEnter New Layer Name:"))
  (if
    (not
      (vl-catch-all-error-p
(vl-catch-all-apply 'Vla-item (list layers Nlay))
      )
    )
    (princ "\nLayer Name Already exist.")
    (progn
      (setq laycol(getint "\nEnter Color for New Layer:"))
      (vla-put-color (vla-add layers Nlay) laycol)
      (princ(strcat "\nLayer \"" Nlay "\"Created ."))
    )
  )
  (vlax-release-object *Activedoc)
  (princ)
)




2 comments:

  1. Can you add to the first code, that will make the new layer created layer the current layer?

    ReplyDelete
  2. Replica Audemars Piguet Watches, combining elegant style and cutting-edge technology, a variety of styles of Replica Audemars Piguet royal oak chronograph Watches, the pointer walks between your exclusive taste style.

    ReplyDelete