+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    59

    Default All solid hatching within blocks color change edit - need help

    Registered forum members do not see this ad.

    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?

    Code:
    (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)

  2. #2
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    452

    Default

    Code:
    (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)

  3. #3
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    59

    Default

    Registered forum members do not see this ad.

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

Similar Threads

  1. Solid hatch color change in and outside of blocks
    By K Baden in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 23rd Aug 2017, 01:34 pm
  2. Lisp to change the color of all incl blocks
    By raffich in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 3rd Sep 2015, 06:10 am
  3. Edit Multiple Blocks (color) at once?
    By TimZilla in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 6th May 2014, 12:20 pm
  4. Change a solid fill to a shade of the solid color
    By hgruber in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 24th Apr 2008, 01:49 pm
  5. how to change a layer color in a block made out several blocks
    By firsrate_caduser in forum AutoCAD General
    Replies: 6
    Last Post: 16th Nov 2006, 06:25 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts