Can I use Inherit hatch from the command line?

 Trying to speed up my hatching procedure with some macros, and I can't find a way to access the Inherit Hatch option from the command line.  I can use (command "hatch") and get command line options for a lot of things, but I don't see inherit in there.  Am I missing it somewhere?

Thanks.

Comments

  •  Hello John,
    Sorry i also can't find inherit option for command line.
  •  Is there any way to access Inherit Hatch from LISP?  

  • I think you will have to create your own function to do this. But that is not terribly hard.

    1.
    There are number of drawing variables that influence the result of the -HATCH command. If you export the settings to a csv file you can easily find them as they all begin with "HP" (which stands for Hatch Pattern). If you correctly change these variables, the -HATCH command will create the hatch you want.

    2.
    To get the values for these "HP" variables from an existing hatch entity you have to query that entity. Try copy/pasting this code and selecting an existing hatch:
    [code](vlax-dump-object (vlax-ename->vla-object (car (entsel))))[/code]
    As you can see there are a number of object properties that are related to hatch pattern data.

    3.
    So all you need to do is create a function that reads the values from an existing hatch entity and sets op the "HP*" variables accordingly. After that you can just run the -HATCH command. Such a function can look something like this:
    [code]
    (defun c:InheritHatchVars ( / ename object)
      (if
        (and
          (setq ename (car (entsel)))
          (setq object (vlax-ename->vla-object ename))
        )
        (progn
          (setvar 'hpname (vla-get-patternname object))
          (setvar 'hpang (vla-get-patternangle object))
          ; etc...
          ; etc...
        )
      )
    )
    [/code]
  •  Thanks for the help.  I messed with that a bit, but my Lisp skills are rudimentary.  It may be beyond me to implement this correctly.  It seems that when the "User Defined" pattern is used, that requires some additional testing, etc. to inherit correctly (cross-hatch, etc.)

    Anyway, it would be nice if this were supported some day -- having a command line implementation of the "Inherit Hatch" button in the dialog box seems like it should be not to hard to implement.  But maybe I'm wrong.

  • Try this,

    same vein as Roy, but not using visual lisp:

    [code](defun C:IHATCH ( / sset ent ihatch-name)
     (princ "\nSelect HATCH pattern to inherit properties from") ; Provide prompt
        (setq sset (ssget ":S" '((0 . "HATCH")))) ; Allow Single selection of only HATCH objects
        (if (= (type sset) 'PICKSET) ; if user has made a valid selection
            (progn
                (setq ent (entget(ssname sset 0))) ; retrieve Hatch properties
                (setvar "HPNAME" (setq ihatch-name (cdr (assoc 2 ent)))) ; find the Hatch pattern name and set it
                (setvar "HPASSOC" (cdr (assoc 71 ent))) ; Set the Hatch associativity on/off
                (if (/= ihatch-name "SOLID") ; IF the Hatch name doesn't equal SOLID
                        (progn ; THEN set the following options
                            (setvar "HPANG" (cdr (assoc 52 ent))) ; Hatch angle
                            (setvar "HPSCALE"  (cdr (assoc 41 ent))) ; Hatch scale
                            (setvar "HPDOUBLE"  (cdr (assoc 77 ent))) ; Double hatch on/off
                        ); end progn
                ); end if
                (command "._HATCH")
            ); end progn
            (princ "\nNo Hatch pattern selected")
        ); end if
    (prin1) ; make a quiet exit
    ); end DEFUN IHATCH

    (defun C:IH () (C:IHATCH)) ; define IH as shortcut key[/code]

    you could easily update to visual using Roy's info. Advantage of visual lisp is that you don't have to deal with cryptic DXF codes.

    Regards,

    Jason Bourhill

    CAD Concepts


  • @ John:
    My function was obviously not finished: ; etc... ; etc ...
    I was just trying to give you the basic information for creating such a function yourself.
  • Jason - Many thanks for that routine.  It works great!  Thanks so much.

    Roy - Thanks to you as well.  I was never hoping that anyone would provide a complete routine, so yours was helpful and did give me some start on experimenting.  It's just my abilities are limited in that.

    I hope this function will be useful to others as well -- it will certainly speed up my work when I'm hatching detail sections.
This discussion has been closed.