Author Topic: Global change hatch background color to none (and nested hatch)  (Read 3771 times)

0 Members and 1 Guest are viewing this topic.

PPETROS

  • Newt
  • Posts: 27
hello everyone
i am try to make a lisp routine to change globally  the hatch background color to none ,  (and nested hatch) , but  I do not.
can anyone help me. thanks
here's the routine.
Code: [Select]
;;;;Global change hatch background color to none (and nested hatch)
(defun C:test ( / *error*) (vl-load-com)
  ;;;(setq *error* (err))
  (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if
      (not (eq (vla-get-isxref block) :vlax-true))
      (vlax-for obj block
        (if
          (eq (vla-get-objectname obj) "AcDbhatch")
          (progn
            (setq obj (vlax-ename->vla-object obj)
                  col (vla-get-backgroundcolor obj)
            )
            (vla-put-entitycolor col -939524096)
            (vla-put-backgroundcolor obj col)
            )
          )
        )
      )
    )
  ;;;(*error* nil)
  (princ)
  )
edit: code tags added
« Last Edit: June 09, 2018, 08:23:15 AM by CAB »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Global change hatch background color to none (and nested hatch)
« Reply #1 on: June 07, 2018, 03:08:54 PM »
Perhaps this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ a d)
  2.     (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  3.   )
  4.     (if (= 0 (vlax-get b 'isxref))
  5.       (vlax-for o b
  6.         (if (and (vlax-write-enabled-p o) (= (vla-get-objectname o) "AcDbHatch"))
  7.           (vlax-put o
  8.                     'visible
  9.                     (cond ((= 0 (vlax-get o 'visible)) -1)
  10.                           (0)
  11.                     )
  12.           )
  13.         )
  14.       )
  15.     )
  16.   )
  17.   (foreach l a (vlax-put l 'lock -1))
  18.   (vla-regen d acallviewports)
  19.   (princ)
  20. )
« Last Edit: June 07, 2018, 03:57:36 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PPETROS

  • Newt
  • Posts: 27
Re: Global change hatch background color to none (and nested hatch)
« Reply #2 on: June 08, 2018, 11:19:55 AM »
It is a good lisp, but it changes the visibility (on/off) of all the hatches. I only want to change the hatch background color to none . Thanks

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Global change hatch background color to none (and nested hatch)
« Reply #3 on: June 08, 2018, 11:58:07 AM »
It is a good lisp, but it changes the visibility (on/off) of all the hatches. I only want to change the hatch background color to none . Thanks
I'm not sure what you mean. You can't change the color to 'none'? Do you mean bylayer or byblock?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

steve.carson

  • Newt
  • Posts: 108
Re: Global change hatch background color to none (and nested hatch)
« Reply #4 on: June 08, 2018, 12:20:30 PM »
I think he means like in the attached image. I saw there is a property of the hatch called "BackgroundColor", but I don't know the first thing about dealing with VLA colors, or how to set it to None.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Global change hatch background color to none (and nested hatch)
« Reply #5 on: June 08, 2018, 12:34:16 PM »
Set it to 'None' manually, then check the value of the property and reverse engineer it  :lol:

PPETROS

  • Newt
  • Posts: 27
Re: Global change hatch background color to none (and nested hatch)
« Reply #6 on: June 08, 2018, 12:58:29 PM »
i mean the hatch property, changing the background color to none, but also globally change hatch and nested hatch with lisp

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Global change hatch background color to none (and nested hatch)
« Reply #7 on: June 08, 2018, 01:07:56 PM »
Maybe post a sample drawing with before and after.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PPETROS

  • Newt
  • Posts: 27
Re: Global change hatch background color to none (and nested hatch)
« Reply #8 on: June 08, 2018, 01:17:57 PM »
sample

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Global change hatch background color to none (and nested hatch)
« Reply #9 on: June 08, 2018, 01:33:58 PM »
Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ c a d)
  2.     (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  3.   )
  4.     (if (= 0 (vlax-get b 'isxref))
  5.       (vlax-for o b
  6.         (cond
  7.           ((and (vlax-write-enabled-p o) (= (vla-get-objectname o) "AcDbHatch"))
  8.            (or c (progn (setq c (vla-get-backgroundcolor o)) (vla-put-entitycolor c -939524096)))
  9.            (vla-put-backgroundcolor o c)
  10.           )
  11.         )
  12.       )
  13.     )
  14.   )
  15.   (foreach l a (vlax-put l 'lock -1))
  16.   (vla-regen d acallviewports)
  17.   (princ)
  18. )
« Last Edit: June 08, 2018, 01:46:05 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PPETROS

  • Newt
  • Posts: 27
Re: Global change hatch background color to none (and nested hatch)
« Reply #10 on: June 08, 2018, 01:47:28 PM »
Excellent, that is what i wanted.
Thank you very mach

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Global change hatch background color to none (and nested hatch)
« Reply #11 on: June 08, 2018, 02:05:57 PM »
Excellent, that is what i wanted.
Thank you very mach
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC