Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change hatch transparency in nested blocks

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
lamalaluan
1293 Views, 2 Replies

Change hatch transparency in nested blocks

Hi guys,

 

I am new to lisp and I would like to know what line/s should I change on the lisp below to change the transparency of hatch in nested blocks. The code works perfectly in changing the hatch colour.

 

Thanks!

 

(defun c:HC ( / aDoc color)
     (vl-load-com)
     (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) 
     (if (setq color (acad_colordlg 7 t))
         (progn
             (vlax-for blk (vla-get-blocks aDoc)
                 (if (and
       (eq :vlax-false (vla-get-islayout blk))
       (eq :vlax-false (vla-get-isxref blk))
   )
   (vlax-for itm blk
       (if (eq  (vla-get-ObjectName itm) "AcDbHatch" )
           (vla-put-color itm color)
       )
    )
       )
          )
          (vla-regen adoc acActiveViewport)
      )
    )
    (princ)
)
2 REPLIES 2
Message 2 of 3
phanaem
in reply to: lamalaluan

You only need to change (setq color (acad_colordlg 7 t)) to (setq color (getstring"\nSpecify transparency (0-90): ")) and vla-put-color to vla-put-entitytransparency ,and it would work, but you also need to check the input validity, so try this:

(defun c:HT ( / aDoc tr)
     (vl-load-com)
     (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) 
     (if
       (progn
         (initget 132)
         (setq tr (getint "\nSpecify transparency (0-90): "))
         (cond
           ((eq (type tr) 'int)
            (if (<= 0 tr 90) (setq tr (itoa tr)))
           )
           ((eq (type tr) 'str)
            (or
              (wcmatch (strcase tr) "BYLAYER,BYBLOCK")
              (not (princ "\nInvalid value."))
            )
           )
         )
       )
       (vlax-for blk (vla-get-blocks aDoc)
         (if
           (and
             (eq :vlax-false (vla-get-islayout blk))
             (eq :vlax-false (vla-get-isxref blk))
           )
           (vlax-for itm blk
             (if
               (eq (vla-get-ObjectName itm) "AcDbHatch")
               (vla-put-entitytransparency itm tr)
             )
           )
         )
       )   
     )
     (vla-regen adoc acActiveViewport)
     (princ)
)

 

Message 3 of 3
lamalaluan
in reply to: phanaem

Woah thanks! That's exactly what I am looking for!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost