Jump to content

set hatch color in the block to white and set on the background.


Recommended Posts

Posted

Hi
I'm searching for a lisp. I got many drawings where the blocks bacground colour is black. In real the colour is white.
See below, on the write site, background colour is black, I want all hatch background colour white. Is there any Lisp that can change the colour?
 

Blockproblem.png

Posted

Are you sure the background color is just a see through color when printing, if you make the infill white it will print as Black. Do you want no color maybe redo the block and use wipeout.

 

Post a dwg so can see what is going on.

  • Like 1
Posted

thanks for the reply, I attached the dwg file.
I always get such dwg files with those blockes. All blockes are black I need the background colour white and I dont know any solution, so I must change them one by one. It takes so much time.

block-problem.dwg

Posted (edited)

This will changes hatches within block definitions to truecolor 255,255,255.

(defun c:foo (/ a co d)
  ;; RJP » 2022-12-13
  (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  (vlax-for b (vla-get-blocks d)
    (if	(= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
      (vlax-for	o b
	(or co (vla-setrgb (setq co (vla-get-truecolor o)) 255 255 255))
	(if (and (vlax-write-enabled-p o)
		 (wcmatch (vla-get-objectname o) "AcDbHatch")
		 (= 7 (vla-get-color o))
	    )
	  (vla-put-truecolor o co)
	)
      )
    )
  )
  (foreach l a (vlax-put l 'lock -1))
  (vla-regen d acallviewports)
  (princ)
)

 

Edited by ronjonp
Posted (edited)

Hi ronjonp,  this code changes all hatch colours to 255,255,255 but I want only the black hatch colour 7 change into 255,255,255.  How can I change this code ?
I have attached a photo. At the moment the hatches in the block are black, but I want it white like on the left side

Blockproblem1.png

Edited by Burzum
Posted (edited)
41 minutes ago, Burzum said:

Hi ronjonp,  this code changes all hatch colours to 255,255,255 but I want only the black hatch colour 7 change into 255,255,255.  How can I change this code ?
I have attached a photo. At the moment the hatches in the block are black, but I want it white like on the left side

@Burzum I updated the code above.

Edited by ronjonp
Posted (edited)
53 minutes ago, ronjonp said:

@Burzum I updated the code above.

thanks you  it works greate :)  a little bit wish, is it possible to set the changed hatches into the background? some blocks have the hatches in the front so the numbers in the blocks are not visible
I tried with the command Hatchtoback but its not working for blocks, I must edit every block

Edited by Burzum
Posted
46 minutes ago, Burzum said:

thanks you  it works greate :)  a little bit wish, is it possible to set the changed hatches into the background? some blocks have the hatches in the front so the numbers in the blocks are not visible
I tried with the command Hatchtoback but its not working for blocks, I must edit every block

See if you can implement THIS into the code. I have 'real' work to do ATM.

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