Jump to content

change solid hatch


CAD

Recommended Posts

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.

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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 by CAD
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

 

Thanks Lee, I thought they might be stored somewhere in the "ActiveDocument vla-object". :thumbsup:

 

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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