LISP CHANGING HATCHING PROPERTIES

LISP CHANGING HATCHING PROPERTIES

rahmathide_legion
Explorer Explorer
1,584 Views
2 Replies
Message 1 of 3

LISP CHANGING HATCHING PROPERTIES

rahmathide_legion
Explorer
Explorer

This Code is got an error 

(defun C:H5 (\ D)
   (setq D (SSGET))
   (command "-HATCHEDIT"D"" "ansi32" "300" "0" "" )
   (princ)
)

this error is "unknown H5 command" 

and my question is how to change with layer properties and hatch pattern of this code?

i'm new to work with lisp😄

0 Likes
1,585 Views
2 Replies
Replies (2)
Message 2 of 3

hosneyalaa
Advisor
Advisor

 

 

 

( defun c : test (  / ss i en )  
(  if   ( setq ss ( ssget ' (  (  0   .   "HATCH"  )   )  )  )  
( progname
  ( repeater ( setq i ( sslength ss )  )

( setq en ( ssname ss ( setq i (  1  - i )  )  )  )  
( setq objvl ( vlax - ename -  > vla -  object en )  )  
( vla - setPattern objvl acHatchPatternTypePreDefined "ansi32"   )  
( vlax - put - property objvl ' layer "0"  )

)  ; repeat
  )  
)  ;   if  
( princ )  
)

 

 

 

 

 

 

 

 

0 Likes
Message 3 of 3

ВeekeeCZ
Consultant
Consultant

Here's your code fixed. For more info look HERE , HERE .

 

Some commands behaves a bit differently when used from autocad command-line or from LISP. The -hatchedit is the case. While in autocad you can select multiple objects, in lisp just single one. The (initcommandvesion) can help, usually, to get the current autocad version. BTW a good trick how to see the lisp-version behaviour is run (command-s "-hatchedit") from the command-line.

 

(defun c:H5 ( / d)  							; its the other one
  (if (setq d (ssget "_:L" '((0 . "HATCH"))))  				; limit the selection for HATCHes only, exclude objects in locked layers
    (progn
      (initcommandversion)						; lisp version of -hatchedit allows single selection only. this way you'll get autocad's version
      (command "-HATCHEDIT" d "" "_Properties"  "ansi32" 300 0)))
  (princ)
  )

 

0 Likes