Jump to content

Recommended Posts

Posted

Is there a way to automatically generate layers based on color? I just downloaded a CAD object that's only got 1 layer but several different colored lines. It would be extremely painstaking if I had to take each and every line and place it on a different layer. It would be much easier if I could tell AutoCAD 2006 to simply split the object up by color and place each one on a different layer. Is this possible?

Posted

You could use Qselect to select by color and add to a layer.

Guest Alan Cullen
Posted

Use the CHANGE command with FILTER to select all lines of a particular colour. Also check the threads listed at the bottom of this page for more advice.

Posted

Heres a lisp I butchered up, for your task. it will create layers by color number and place those colors on the appropriate layer.

 

 
(defun c:lbc ( / SelectionSet counter EntData EntColor)
(prompt "\nSelect the entitie(s) you want to create layers by color... ")
(setq SelectionSet (ssget))
(if (not SelectionSet)
(prompt "\n There was nothing selected! ")
     (progn
(setq counter 0)
(repeat (sslength SelectionSet)
(setq EntData (entget (ssname SelectionSet counter))
         EntColor (cdr (assoc 62 EntData))
);-setq
(setq counter (1+ counter))
(command "-layer" "n" EntColor "c" EntColor EntColor "")
(setq EntData (subst (cons 8 (rtos EntColor))(assoc 8 EntData) EntData))
(entmod EntData)
(princ)
);-repeat
      );-progn
);-if
);-defun
(princ)

 

but after reading Alan & SLW good answers I think I might have wasted my time.:lol:

  • 3 years later...
Posted

Mate, this is why i'm (trying to) learning lisp, this worked PERFECTLY. I have over 200,000 lines, to process. selecting them all takes half a day. Using your lisp takes 5 seconds. THANKYOU

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