update hatch scales with lisp??

Discussion in 'AutoCAD' started by C Witt, May 19, 2004.

  1. C Witt

    C Witt Guest

    Ok, a bit of background..

    we have 10 hatch patterns with set "scales" for each dimstyle (so they
    match in paperspace)..

    what i want to do:
    create a lisp command that will prompt the user to select a hatch
    "object" (if it matches one of our standard patterns) and update it's
    scale based on the current dim style.

    the problem:
    i have looked at the dxf codes for hatch.. and am beyond lost.. there
    are way to many factors to take into account..


    can someone here help me out with this??.. I need to know what dxf
    codes I will need to alter, and how they interact with each other..

    TIA.
     
    C Witt, May 19, 2004
    #1
  2. You might have an easier time with activeX.

    vla-get-patternscale
    vla-put-patternscale
     
    Jason Piercey, May 19, 2004
    #2
  3. C Witt

    C Witt Guest

    ......i can't find anything on that in the help.. (and i noramly don't
    work with activeX)..
     
    C Witt, May 19, 2004
    #3
  4. You have to look in the vba and activeX reference.

    ; select hatch entity and get the ename
    (setq hatchObject (car (entsel "\nselect a hatch object: ")))

    ; convert the ename to a vla-object
    (setq hatchObject (vlax-ename->vla-object hatchObject))

    ; to get the pattern scale
    (vla-get-patternscale hatchObject)

    ; to change the pattern scale
    (vla-put-patternscale hatchObject 2.0)
     
    Jason Piercey, May 19, 2004
    #4
  5. C Witt

    C Witt Guest

    Jason, sorry to pester you on this..

    I am looking in the "vba and activeX reference" and am not seeing
    anything remotely close to this..

    another thing.. I tried the code you posted, but it won't update the
    existing hatch.. if you "edit" it then the "scale" is the new scale,
    but it still displays as the the old scale.
     
    C Witt, May 19, 2004
    #5
  6. Not pestering at all.

    In the VBA and ActiveX reference go to properties
    then scroll down to PatternScale property. You have
    to translate the VBA syntax to LISP.

    Are you using non-associative patterns? With some
    quick tests I am seeing some odd behavior with
    patterns that are not associative. Not sure what, if
    anything, you can do about that. Perhaps someone
    else has an idea?
     
    Jason Piercey, May 19, 2004
    #6
  7. C Witt

    C Witt Guest

    we don't ever use associative hatch (intentionally anyway)..
     
    C Witt, May 19, 2004
    #7
  8. The hatch scale is kept in number 41 in the association list.
    Type in:
    (setq hatchobject (entget (car (entsel))))
    <...pick hatch...>
    Then type in
    (assoc 41 hatchobject)
    which returns:
    (41 . <hatch scale here>)

    Shouldn't be too hard to do an entmod/entupd thing to change that, maybe
    even for all hatch patterns in a drawing at once.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, May 19, 2004
    #8
  9. C Witt

    C Witt Guest

    But there is more than one DXF code related to the scale of a hatch
    pattern..
     
    C Witt, May 19, 2004
    #9
  10. C Witt

    C Witt Guest

    i fixed that problem by changing it back to a dxf code, and doing an
    entmake/entdel..
     
    C Witt, May 19, 2004
    #10
  11. C Witt

    Steve Doman Guest

    If all else fails, try using the hatchedit command:

    (defun c:dimhatch (/ ss n dimscale)
    (if (setq ss (ssget ":L" '((0 . "HATCH"))))
    (progn (setq n 0)
    (if (zerop (setq dimscale (getvar "dimscale")))
    (setq dimscale 1.0)
    )
    (repeat (sslength ss)
    (vl-cmdf "._hatchedit"
    (ssname ss n)
    "_prop"
    ""
    dimscale
    ""
    )
    (setq n (1+ n))
    )
    )
    )
    (princ)
    )

    Steve Doman
     
    Steve Doman, May 19, 2004
    #11
  12. Since the title of this thread says "with lisp," do you really need DXF
    codes? Won't "assoc" values do?

    Kent Cooper, AIA

    ...
     
    Kent Cooper, AIA, May 19, 2004
    #12
  13. C Witt

    C Witt Guest

    that would not allow for the customization i need. What i have will do
    just what i need.

    But thank you anyway.
     
    C Witt, May 19, 2004
    #13
  14. C Witt

    C Witt Guest

    same thing.. no?? assoc changes dxf codes.

     
    C Witt, May 19, 2004
    #14
  15. C Witt

    Steve Doman Guest

    You're welcomed anyway! I just went back and read your original post
    and just now noticed that you wanted to process only hatch patterns that
    match your list of standard hatch patterns. That feature could be
    easily added to the little routine I posted with (if (wcmatch..., but if
    you've got a solution then run with it. :)

    Steve Doman
     
    Steve Doman, May 19, 2004
    #15
  16. But there must be some difference, or there wouldn't be only one assoc value
    but multiple DXF codes related to hatch scale. Maybe changing the one assoc
    value with a lisp routine will change ALL the DXF ones.
    Kent Cooper, AIA

    ----- Original Message -----
    From: "C Witt" <>
    Newsgroups: autodesk.autocad.customization
    Sent: Wednesday, May 19, 2004 5:46 PM
    Subject: Re: update hatch scales with lisp??
     
    Kent Cooper, AIA, May 20, 2004
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.