Author Topic: hatch to each layer by color  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
hatch to each layer by color
« on: September 19, 2015, 12:03:45 AM »
hello  friends
i meet  problem again ~
sorry sorry always  help ask
pls understand me




my ask~


i have      hatchs , that  have color
if you see attached file , you can understand


i would like to  seperlate  that hatch  by color


red color    hatch  objects   ->      layer name  : hatch-color number  <- each color number
blue color    hatch  objects   ->      layer name  : hatch-color number  <- each color number


 

« Last Edit: September 19, 2015, 12:09:49 AM by dussla »

ChrisCarlson

  • Guest
Re: hatch to each layer by color
« Reply #1 on: September 21, 2015, 08:50:18 AM »
Well let's break this down.

First, do you want to manually select a hatch and send it to a layer or automagically?

Either way you need to grab hatches.

Code - Auto/Visual Lisp: [Select]
  1. ;;---------------------=={ Select if }==----------------------;;
  2. ;;                                                            ;;
  3. ;;  Provides continuous selection prompts until either a      ;;
  4. ;;  predicate function is validated or a keyword is supplied. ;;
  5. ;;------------------------------------------------------------;;
  6. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  7. ;;------------------------------------------------------------;;
  8. ;;  Arguments:                                                ;;
  9. ;;  msg  - prompt string                                      ;;
  10. ;;  pred - optional predicate function [selection list arg]   ;;
  11. ;;  func - selection function to invoke                       ;;
  12. ;;  keyw - optional initget argument list                     ;;
  13. ;;------------------------------------------------------------;;
  14. ;;  Returns:  Entity selection list, keyword, or nil          ;;
  15. ;;------------------------------------------------------------;;
  16.  
  17. (defun LM:SelectIf ( msg pred func keyw / sel ) (setq pred (eval pred))  
  18.   (while
  19.     (progn (setvar 'ERRNO 0) (if keyw (apply 'initget keyw)) (setq sel (func msg))
  20.       (cond
  21.         ( (= 7 (getvar 'ERRNO))
  22.           (princ "\nMissed, Try again.")
  23.         )
  24.         ( (eq 'STR (type sel))
  25.           nil
  26.         )
  27.         ( (vl-consp sel)
  28.           (if (and pred (not (pred sel)))
  29.             (princ "\nInvalid Object Selected.")
  30.           )
  31.         )
  32.       )
  33.     )
  34.   )
  35.   sel
  36. )
  37.  
http://www.lee-mac.com/selectif.html

When combined with this call, the above function will allow you to manually select a single hatch and store it as entity.

Code - Auto/Visual Lisp: [Select]
  1.     (setq entity
  2.       (car
  3.         (LM:SelectIf "\nSelect a Hatch: "
  4.           (lambda ( x ) (eq "HATCH" (cdr (assoc 0 (entget (car x)))))) entsel nil
  5.         )
  6.       )
  7.     )
  8.  

So we have a hatch selected, whats the next step required?