Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/20/2019 in all areas

  1. I think the reason is color. The layer number is the same as the index color. Here's a small routine to help you out. (defun JH:selset-to-list (selset / lst iter) (setq iter 0) (repeat (sslength selset) (setq lst (cons (ssname selset iter) lst) iter (1+ iter)) ) (reverse lst) ) (defun c:pl_layer ( / *error* activeundo alphabet lay pls pls_list number alphabet exist) (defun *error* ( msg ) (vla-EndUndoMark adoc) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*")) (princ (strcat "Error: " msg)) ) ) (setq acadobj (vlax-get-acad-object) adoc (vla-get-ActiveDocument acadobj) msp (vla-get-ModelSpace adoc) activeundo nil) (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T)) (setq pls (ssget '((0 . "LWPOLYLINE")))) ;;; Uncomment below and comment/delete above if you'd like to select lines inclusive. ;;; (setq pls (ssget '((0 . "*LINE")))) (if pls (progn (setq pls_list (JH:selset-to-list pls) number 1 alphabet 64) (foreach i pls_list (setq exist (if (tblsearch "LAYER" (setq lay (strcat (if (> alphabet 64) (chr alphabet) "") (itoa number)))) T nil)) (entmod (subst (cons 8 lay) (assoc 8 (entget i)) (entget i) ) ) ;; If you want the color of the new layer generated to change as well, uncomment below ;; (if (not exist) (vla-put-Color (vla-item (vla-get-layers adoc) lay) number)) (if (= number 255) (setq number 1 alphabet (1+ alphabet)) (setq number (1+ number)) ) ) ) ) (if activeundo nil (vla-EndUndoMark adoc)) (princ) ) Honestly, if you want to only change the colors of the lines, below is more than enough to do the job: (vla-put-Color (vlax-ename->vla-object i) number) or even (cons 62 number) is more than enough to do it.... much faster this way. Anyway, as BIGAL points out, what are you trying to achieve in the end of this? Pretty sure there are more effective ways to get what you want other than putting each line in their separate layers. Thanks, Jonathan Handojo
    1 point
×
×
  • Create New...