CAD Posted July 28, 2017 Posted July 28, 2017 Hello, Is there a lisp that can find all hatch pattern SOLID in a drawing, change to AR-Sand and scale 1000, in and outside the blocks when load lisp. Quote
BIGAL Posted July 29, 2017 Posted July 29, 2017 (edited) Try this out. (vl-load-com) (defun sol-sand ( / ss obj ent) (if (setq ss (ssget "x" (list(cons 0 "HATCH")(cons 2 "SOLID")))) (progn (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (vla-setPattern obj acHatchPatternTypePreDefined "AR-SAND") (vla-put-PatternScale obj 1000) ) ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for block (vla-get-blocks doc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (if (and (= "AcDbHatch" (vla-get-objectname ent))(= "SOLID" (vla-get-PatternName ent))) (progn (vla-setPattern ent acHatchPatternTypePreDefined "AR-SAND") (vla-put-PatternScale ent 1000) ) ) ) ) ) ) (vla-regen doc acactiveviewport) (princ) ) (sol-sand) Edited July 30, 2017 by BIGAL Quote
CAD Posted July 29, 2017 Author Posted July 29, 2017 (edited) Good morning Bigal, THe lisp works fine for all solid hatch but, can u modified it also work for solid Hatch that is in a block? when is done it Popup {Hatches changed in current view} can it turn off , thx alot!! forget to mention can it also create all solid hatch with a boundryline thickness 5mm Edited July 29, 2017 by CAD Quote
Lee Mac Posted July 29, 2017 Posted July 29, 2017 Pretty much the same as Al above, but iterating over blocks: (defun c:sol2sand ( / 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) ) (progn (vla-setpattern obj achatchpatterntypepredefined "AR-SAND") (vla-put-patternscale obj 1000.0) ) ) ) ) ) (vla-regen doc acallviewports) (princ) ) (vl-load-com) (princ) 1 Quote
CAD Posted July 29, 2017 Author Posted July 29, 2017 thx this work fine!! leemac , thx Bigal! thx all Quote
Grrr Posted July 30, 2017 Posted July 30, 2017 These solutions make me wonder: Is it possible to obtain a list of the hatch pattern names? Quote
Lee Mac Posted July 30, 2017 Posted July 30, 2017 These solutions make me wonder:Is it possible to obtain a list of the hatch pattern names? The function I posted here demonstrates one possible method: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/storing-variable-associate-recall/m-p/4658935#M317364 Quote
Grrr Posted July 30, 2017 Posted July 30, 2017 The function I posted here demonstrates one possible method:https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/storing-variable-associate-recall/m-p/4658935#M317364 Thanks Lee, I thought they might be stored somewhere in the "ActiveDocument vla-object". Your subfunction reminds me of a similar technique I tried recently (using your LM:directoryfiles function): (setq FontPaths (apply 'append (mapcar (function (lambda (x) (append (LM:directoryfiles x "*.ttf" T) (LM:directoryfiles x "*.shx" T) ) ) ) (SplitStringToList ";" (getenv "ACAD")) ; support paths ) ) ) That fragment is from a code I used to generate different textstyles based on the font files from the support paths (prompting with List Box which one to create). Just sharing with you the idea I wrote. Quote
K Baden Posted August 8, 2017 Posted August 8, 2017 This thread is the closest i could find to my current issue. I have a code that finds "cross" hatch patters, removes a white background mask we used to add, and changes the scale to 32. I am using this command within a larger command that basically calls up several LISPs we have that fix some simple standards stuff. The problem I'm having is that if a Cross hatch pattern doesn't exist on the drawing, It gives me an error on this command and will not finish the rest of the combined LISP command. is there any way to change this so that it will not Give me an error if the hatching doesn't exist, and just continue? The error im getting is this in the command line: "Command: IB ; error: bad argument type: lselsetp nil" (defun c:IB () ;Set hatch scale to 32 (mapcar '(lambda (x) (setpropertyvalue x "PatternScale" 32) ) (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "HATCH")(2 . "CROSS")))))) (if (setq ss (ssget "X" '((0 . "HATCH") (2 . "CROSS")))) (progn (setq count 0) (repeat (sslength ss) (command "-hatchedit" (ssname ss count) "co" "" ".") (setq count (1+ count)) ) ) ) (princ) ) Quote
Lee Mac Posted August 8, 2017 Posted August 8, 2017 Hint: see this troubleshooter. You will need to test the value returned by the ssget function before passing it to the ssnamex function - in the same way that you do with the second half of the code. In fact, since both selection sets use the same filter, the first operation could be performed within the repeat loop that you already have. Quote
K Baden Posted August 17, 2017 Posted August 17, 2017 I find myself back here again, but for a different reason! The above code that changes settings for solid hatching, can that be tailored to change the color of all solid hatch, inside or outside of a block, regardless of layer, without having to select anything manually? edit: the color im looking to change to is 255,255,255 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.