Jump to content
K Baden

All solid hatching within blocks color change edit - need help

Recommended Posts

K Baden

Good morning all!

I have a code that works perfectly for updating the color to the truecolor 255,255,255 for all solid hatching.

Basically i just need this exact code, except i need it to update the color to ByBlock.

 

Can anyone help me out?

 

(defun c:hw (/ doc)
 (or *colorobject*
     (setq *colorobject*
     (vla-getinterfaceobject
       (vlax-get-acad-object)
       (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2))
     )
     )
 )
 (if
   (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-setrgb (list *colorobject* 255 255 255))))
    (progn (vlax-for blk (vla-get-blocks (setq doc (vla-get-Activedocument (vlax-get-acad-object))))
      (if (= :vlax-false (vla-get-isxref blk))
	(vlax-for obj blk
	  (if (and (= "AcDbHatch" (vla-get-objectname obj))
		   (= "SOLID" (strcase (vla-get-patternname obj)))
		   (vlax-write-enabled-p obj)
	      )
	    (vl-catch-all-apply 'vla-put-truecolor (list obj *colorobject*))
	  )
	)
      )
    )
    (vla-regen doc acallviewports)
    )
 )
 (princ)
)
(vl-load-com)
(princ)

Share this post


Link to post
Share on other sites
ronjonp
(defun c:hw (/ doc)
 (vlax-for blk	(vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object))))
   (if	(= :vlax-false (vla-get-isxref blk))
     (vlax-for	obj blk
(if (and (= "AcDbHatch" (vla-get-objectname obj))
	 (= "SOLID" (strcase (vla-get-patternname obj)))
	 (vlax-write-enabled-p obj)
    )
  (vl-catch-all-apply 'vla-put-color (list obj 0))
)
     )
   )
 )
 (vla-regen doc acallviewports)
 (princ)
)
(vl-load-com)

Share this post


Link to post
Share on other sites
K Baden

Beautiful thank you! I wasn't sure on how to get ByBlock without using the word ByBlock. I appreciate your help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×