Alan0522 Posted April 27, 2020 Posted April 27, 2020 Hey guys, I got a drawing which has about 200 blocks. I am wondering is there a lisp that can help to change color of all hatches within these blocks to color 253? Thank you guys Quote
Lee Mac Posted April 27, 2020 Posted April 27, 2020 Here's a very simple example: (defun c:hcol ( / c d ) (setq c 253) (vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object)))) (if (= :vlax-false (vla-get-isxref b) (vla-get-islayout b)) (vlax-for o b (if (and (= "AcDbHatch" (vla-get-objectname o)) (vlax-write-enabled-p o)) (vla-put-color o c) ) ) ) ) (vla-regen d acallviewports) (princ) ) (vl-load-com) (princ) 1 Quote
Sami2601 Posted January 8 Posted January 8 Hey guys, Is there also a way to change the properties of all the hatches in a layer (for ex layer "01211") to pattern : DOT, with scale :1.333, angle :100, color :120,120,120 and backroungcolor : none. Thank you. Quote
BIGAL Posted January 8 Posted January 8 Try this (defun c:hcol ( / colobj lay x obj ss ang) (setq colObj (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2)))) (vla-setRGB colObj 120 120 120) (setq ang 100) (setq ang (* pi (/ ang 180.0))) ; convert to radians (setq lay (cdr (assoc 8 (entget (car (entsel "\nPick an object for layer ")))))) (setq ss (ssget "X" (list (cons 0 "HATCH")(cons 8 lay)))) (if (= ss nil) (alert "No hatches detected") (progn (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (vlax-put obj 'TrueColor colobj) (vlax-put obj 'PatternScale 1.333) (vlax-put obj 'PatternAngle ang) ) ) ) (princ) ) 2 Quote
Recommended Posts
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.