Author Topic: changing Hatch color  (Read 171 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 634
changing Hatch color
« on: March 24, 2020, 08:40:27 AM »
Hi friends,

How are you?

In my project have about 300,000 pieces of hatches, there are 2 colors; red and green...
I'd like to change all red hatches to color 31 and green to 141 color.

I'm trying to using quick select, and isn't working. Maybe a lisp could help me.

Anybody could help me out, please?

File attached

Thank in advance
FabrÝcio
« Last Edit: March 24, 2020, 09:32:34 AM by Fabricio28 »

rayakmal

  • Newt
  • Posts: 35
Re: changing Hatch color
« Reply #1 on: March 24, 2020, 10:01:36 AM »
Hi friends,

How are you?

In my project have about 300,000 pieces of hatches, there are 2 colors; red and green...
I'd like to change all red hatches to color 31 and green to 141 color.

I'm trying to using quick select, and isn't working. Maybe a lisp could help me.

Anybody could help me out, please?

File attached

Thank in advance
FabrÝcio

Have you ever tried 'Filter' command ? it's one of Autocad Command.

alumina

  • Mosquito
  • Posts: 1
Re: changing Hatch color
« Reply #2 on: March 24, 2020, 01:17:24 PM »
Code: [Select]
(defun c:ch (/ dc ss k n) (vl-load-com)
  (if (setq dc (vla-get-ActiveDocument
        (vlax-get-acad-object))
          ss (ssget "X" '((0 . "hatch") (-4 . "<or")
            (62 . 1) (62 . 3) (-4 . "or>"))))
    (progn (vla-StartUndomark dc)
      (repeat (setq k (sslength ss))
        (setq k (1- k) n (vlax-ename->vla-object
          (ssname ss k)))
        (vla-put-Color n (if (= (vla-get-Color n) 1) 31 141)))
      (vla-EndUndomark dc)
    )
  ) (prin1)
)

ronjonp

  • Needs a day job
  • Posts: 7111

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Fabricio28

  • Swamp Rat
  • Posts: 634
Re: changing Hatch color
« Reply #4 on: March 25, 2020, 08:00:39 AM »

Fabricio28

  • Swamp Rat
  • Posts: 634
Re: changing Hatch color
« Reply #5 on: March 25, 2020, 08:01:49 AM »
Code: [Select]
(defun c:ch (/ dc ss k n) (vl-load-com)
  (if (setq dc (vla-get-ActiveDocument
        (vlax-get-acad-object))
          ss (ssget "X" '((0 . "hatch") (-4 . "<or")
            (62 . 1) (62 . 3) (-4 . "or>"))))
    (progn (vla-StartUndomark dc)
      (repeat (setq k (sslength ss))
        (setq k (1- k) n (vlax-ename->vla-object
          (ssname ss k)))
        (vla-put-Color n (if (= (vla-get-Color n) 1) 31 141)))
      (vla-EndUndomark dc)
    )
  ) (prin1)
)

Thank you for the help.

Fabricio