Jump to content
CAD_Noob

Demo Lisp

Recommended Posts

CAD_Noob

I found this lisp by Kent which enable the user to pick an entity and add "-DEMO" to its layer name, change its color and linetype which is working great.

Can this be modified to accept multiple selection rather than by pick only.
And if i select a block if does not change the color and linetype.

 

(defun c:DEMO (/ esel ent DLname)
  (while (setq esel (entsel "\nPick object to put on its Demo Layer: "))
    (setq
      ent (car esel)
      DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")
    )
    (command
      "_.layer" "_make" DLname "_color" 40 "" "_ltype" "HIDDEN2" "" ""
      "_.chprop" ent "" "_layer" DLname ""
    )
  )
  (princ)
)

 

Edited by CAD_Noob
typo error

Share this post


Link to post
Share on other sites
Emmanuel Delay

Sure, I renamed the command CLCL

 

(defun change_layer_color_ltp ( ent /  DLname)
    (setq
      ;;ent (car esel)
      DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")
    )
    (command
      "_.layer" "_make" DLname "_color" 40 "" "_ltype" "HIDDEN2" "" ""
      "_.chprop" ent "" "_layer" DLname ""
    )
  (princ)
)

(defun c:clcl ( / ss i)
  ;; selection
  (princ "\nMake selection: ")
  (setq ss (ssget))
  ;; now perform the function for every selected entity
  (setq i 0)
  (repeat (sslength ss)
    (change_layer_color_ltp (ssname ss i))
    (setq i (+ i 1))
  )
  (princ)
)

Edited by Emmanuel Delay
  • Thanks 1

Share this post


Link to post
Share on other sites
CAD_Noob
3 hours ago, Emmanuel Delay said:

Sure, I renamed the command CLCL

 


(defun change_layer_color_ltp ( ent /  DLname)
    (setq
      ;;ent (car esel)
      DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")
    )
    (command
      "_.layer" "_make" DLname "_color" 40 "" "_ltype" "HIDDEN2" "" ""
      "_.chprop" ent "" "_layer" DLname ""
    )
  (princ)
)

(defun c:clcl ( / ss i)
  ;; selection
  (princ "\nMake selection: ")
  (setq ss (ssget))
  ;; now perform the function for every selected entity
  (setq i 0)
  (repeat (sslength ss)
    (change_layer_color_ltp (ssname ss i))
    (setq i (+ i 1))
  )
  (princ)
)

 

Hi @Emmanuel Delay; thanks for this. Will try tomorrow as I do not have AutoCAD at home.

 

  • Like 1

Share this post


Link to post
Share on other sites
CAD_Noob

Thanks so much! working well.

Just need to edit some blocks to ByLayer for the routine to take effect.

Some blocks are a bit hard to edit though there are couples of nested block 

Share this post


Link to post
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.   Paste as plain text instead

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