Lisp routine for setting default hatch setting to "associative"?

Discussion in 'AutoCAD' started by JamieLandmark, Mar 30, 2005.

  1. Hello,

    Is there a lisp routine (or setting such as "dimassoc") that will set the default hatch setting to "associative"? Ours constantly resets to non-associative.

    I'm sure this the problem results from my frequently using "inherit properties."

    Regards,

    Jamie
     
    JamieLandmark, Mar 30, 2005
    #1
  2. JamieLandmark

    Walt Engle Guest

    If you have an acad.lsp or acaddoc.lsp, put in the following line:

    (setvar "hpassoc" 1)
     
    Walt Engle, Mar 31, 2005
    #2
  3. Hey Walt,

    I don't believe I have either .lsp. Can you attach a simple one that I can use?

    Thanks,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #3
  4. JamieLandmark

    Jeff Mishler Guest

    Jamie,
    At the command prompt, type the following 2 lines and note what each one
    returns:
    (findfile "acad.lsp")

    (findfile "acaddoc.lsp")

    If one, or both, returns anything but nil then they exist in the path shown.

    However, depending on your version, Walts suggestion may not work. I know
    that in R2002 HPASSOC is NOT a sysvar, and I don't see an easy way of
    setting it to default to on.(Well, I don't see a hard way either...)
     
    Jeff Mishler, Mar 31, 2005
    #4
  5. JamieLandmark

    Tom Smith Guest

    Just create a text file, paste that line into it, name it acaddoc.lsp, and put it on your Acad search path. It will load in every drawing and change that setting.

    Of course, this will mean that every time you open a drawing you'll be asked if you want to save your changes when you try to close it, whether or not you've done anything, because a variable is being changed.
     
    Tom Smith, Mar 31, 2005
    #5
  6. Hey Jeff,

    I looked for both, and got nil both times.

    I created acaddoc.lsp as suggested by Tom, but as you said it doesn't set a system variable.

    After using "inherit properties" it stays set at "nonassociative".

    Do you know a way around this?

    Regards,

    Jamie

    P.S. Did my e-mail to your cadvault address get through?
     
    JamieLandmark, Mar 31, 2005
    #6
  7. Hey Tom,

    Please see my reply to Jeff above.

    Do I have to save the drawing when exiting in order to keep the changed variable for the next drawing opened?

    Regards,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #7
  8. JamieLandmark

    Walt Engle Guest

    Below is part of my acad.lsp. This loads with every dwg. delete what you don't want.
    I use Arial font but you can change that to any of autocad's fonts. I have added
    semi-colons in front of items that autocad will NOT use. You will notice about 2/3
    of the way down functions of zw, zp, ze & st. These are for me to type "zw", "ze",
    "zp" without having to press the enter key after each "z". Also, "st" is for me to
    stretch from left to right without having to type "c" for crossing. In the event,
    the line "(setvar "hpassoc" 1)
    does not appear to work, change to (command "setvar" "hpassoc" 1).

    (DEFUN S::STARTUP ()
    (COMMAND "STYLE" "STANDARD" "ROMANS" "" "" "" "" "" "")
    ;(COMMAND "STYLE" "STANDARD" "arial.ttf" "" "" "" "" "")
    (SETVAR "AUPREC" 2) ;angular units precision set to 2 places
    (SETVAR "CMDECHO" 0) ;turns off lisp echoing
    (COMMAND "SETVAR" "COORDS" 0) ;turns off dynamics coordinate updating
    ;(COMMAND "SETVAR" "DIMCLRT" 0) ;dimension text color
    (SETVAR "DIMEXE" 0.09) ;extension line distance past dim line
    (COMMAND "SETVAR" "DISPSILH" 1) ;to hide lines during plotting
    ;(SETVAR "DIMTAD" 1) ;dim text above dim line-default is 0
    ;(SETVAR "DIMTIH" 1) ;dim text aligned
    (SETVAR "DIMTXSTY" "STANDARD") ;dim text style
    (SETVAR "DIMTXT" 0.125) ;dim text height
    (SETVAR "DIMCEN" 0.09) ;zero draws no centermark for
    ;center, dia & radius subcommands
    (SETVAR "DIMUNIT" 6) ;arch units format
    (SETVAR "DIMDEC" 5) ;dimension decimal places-5= 1/32th inch
    (SETVAR "DIMAUNIT" 0) ;no decimal places on angular dimension
    (SETVAR "LUNITS" 4) ;arch linear units
    (COMMAND "UNITS" 4 32 1 2 0 "N") ;arch, sixteenths, dec deg, 2 places
    (SETVAR "DIMUPT" 0) ;user placement of dim text-1allows dim placed outside for
    radius and diam
    (COMMAND "SETVAR" "DIMZIN" 7) ;supresses zero feet but not zero inches
    (COMMAND "SETVAR" "EDGEMODE" 1) ;cutting & boundary edge
    (SETVAR "FILEDIA" 1) ;dialog boxes enabled
    (COMMAND "SETVAR" "FONTALT" "ROMANS") ;alternate font
    (SETVAR "FACETRES" 10) ;smoothness of shaded and hidden lines
    (SETVAR "ISAVEPERCENT" 0) ;saves all of dwg instead of most recent part
    (SETVAR "MIRRTEXT" 0) ;mirroring text normally
    (COMMAND "SETVAR" "OSMODE" 32) ;intersection obj snap
    (COMMAND "SETVAR" "LTSCALE" (/ (GETVAR "DIMSCALE") 2)) ;sets ltscale to one-half of
    dimscale
    (COMMAND "SETVAR" "SAVETIME" 10) ;10 minutes automatic saving
    (SETVAR "SORTENTS" 23) ;object sort order
    (SETVAR "TEXTQLTY" 25) ;faster regen for texts
    (COMMAND "SETVAR" "TEXTSTYLE" "STANDARD") ;text style name
    (COMMAND "SETVAR" "TEXTSIZE" 0.125) ;text height
    (COMMAND "TIME" "OFF" "") ;"on" checks times, dates of when
    ;dwg worked on
    (SETVAR "UCSICON" 1) ;ucs icon on
    (COMMAND "VIEWRES" "" 1000) ;resolution for smoother circles
    (SETVAR "HPASSOC" 1)
    ;
    (VMON)
    (prompt "\nLoading Acad.lsp...Please wait.....")
    ;
    (defun c:zw () (command "zoom" "_w"))
    (defun c:zp () (command "zoom" "_p"))
    (defun c:st () (command "stretch" "C"))
    (defun c:ze () (command "zoom" "e"))
    ;
    (defun dtr (a)
    (* pi (/ a 180.0))
    )
    ;
    (Defun Extang (A)
    (Setq A (Tblsearch "STYLE" A))
    (Setq J (Cdr (Assoc 50 A)))
    )
    ;
    (defun rtd (a)
    (/ (* a 180.0) pi)
    )
    ;
    (defun dmstdd (a)
    (setq d (fix a)
    m (/ (fix (* 100 (rem a 1))) 60.0)
    s (/ (* 100 (rem (* 100 (rem a 1)) 1)) 3600.0)
    a (+ d m s)
    )
    )
    ;
    (defun dmstr (a)
    (setq d (fix a)
    m (/ (fix (* 100 (rem a 1))) 60.0)
    s (/ (* 100 (rem (* 100 (rem a 1)) 1)) 3600.0)
    a (dtr (+ d m s))
    )
    )
    ;
    (defun c:rtdms (a)
    (setq a (* a (/ 180.0 pi))
    min (* (- a (fix a)) 60)
    sec (* (- min (fix min)) 60)
    deg (fix a)
    min (fix min)
    )
    )
     
    Walt Engle, Mar 31, 2005
    #8
  9. JamieLandmark

    Jeff Mishler Guest

    The only way around that is to uncheck the Hatch under Special Properties of
    the Inherit Properties Settings. Maybe a new routine to mimic the Inherit
    Properties that only allows certain properties to be modified.....????

    I have not recieved any email at my cadvault account from you, sorry.
     
    Jeff Mishler, Mar 31, 2005
    #9
  10. JamieLandmark

    Walt Engle Guest

    Follow up (sorry, forgot) copy from "(DEFUN" to bottom, insert in Notepad and save in
    your autocad SUPPORT directory as ACAD.LSP. You may be asked the first time you start
    autocad if you want to use acad.lsp for this dwg or all - pick ALL dwgs.
     
    Walt Engle, Mar 31, 2005
    #10
  11. Hey Jeff,

    I'm definitely up for that mimic routine - if it exists.

    Re: my e-mail to you. I basically was just going to ask your recommendation on pursuing that isolating layers lisp routine any further. If you remember, I was interested in having the routine exercise power over xref layers. As it is, I can only use the routine I've seen posted on this discussion group to isolate an individual xref layer, but it doesn't always work. There's also xlist, but it has limitations, too. If you see an easy way to create an isolate layers routine that has greater power over isolating xref layers - and can still work rather quickly, I would be willing to pay you for your time - within reason. But is this reasonable? If it's not worth pursuing, I don't want to beat my head against a wall.

    Regards,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #11
  12. Hey Walt,

    Thank you very much for posting the acad.lsp. I'll take a close look at it.

    I appreciate your time and help,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #12
  13. JamieLandmark

    Tom Smith Guest

    HPASSOC works in 2004, I don't have an earlier version around to check.

    As far as the acaddwhatever.lsp approach, I was only following up on "how to do it" and not endorsing that method.

    Walt and I are 180 degrees apart on this -- I am firmly against having any routine change anything in a drawing upon opening it, without your consent. One reason is the mundane one I mentioned -- getting a prompt to save changes when you haven't knowingly done anything. And, per previous discussions, of all the things that Walt's routine is doing on startup, there is not a single one that I want changed in an existing drawing when I open it. The majority of these things are properly set up in a drawing when it's created, and don't need to be fiddled with ever again. What he uses for an acad.lsp is what I would consider a one-time-only drawing creation routine. Further, if I have saved a drawing with an unusual setting -- for instance with a certain osnap mode, or a different dimstyle setting, or whatever, it is because I intended this in that particular drawing, and the last thing I'd want is to have the way I left the file getting "fixed" the next time I opened it. I want drawings to stay exactly as I left them.

    If your version has the HPASSOC variable, it's kept in the registry and therefore doesn't need to be set in every drawing. Once you type it, or check the box in the BHATCH dialog, the setting will remain constant in all drawings until you change it.

    If you change it by picking "inherit properties" on a non-associative hatch, well, then you'll need to check the box again. I don't know a way to change this behavior of the dialog, and frankly I think it would be undesirable -- inherit should mean inherit, not different.

    If you want a quick way to reset HPASSOC to 1, maybe a button macro or a keyboard command would be the way to go. Bottom line, I don't think that forcing the variable setting in each drawing on startup is going to do what you want anyway.
     
    Tom Smith, Mar 31, 2005
    #13
  14. Hey Tom,

    Thanks very much for the insight. I haven't adopted the acad.lsp yet and your argument against it is pretty convincing.

    Thanks for pointing out the reasoning behind "inherit properties". I've been caught once again being overly nit-picky.

    Regards,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #14
  15. JamieLandmark

    Tom Smith Guest

    Jamie, I've had the reverse question here -- how to set the default to non-associative :)

    The reason being that associative hatches seem a bit buggier in 2004 than previous versions, and sometimes a simple edit operation can cause an associative hatch to go completely haywire and require correction. I looked into changing the registry setting, but so far haven't found the key that stores the setting. Basically, however you left it last is the default, and for us that's usually HPASSOC=1. Changing it drawing by drawing is no good, you'd need to change it every time you ran the hatch command, since that can change it.

    You could do this with a button macro of the form ^c^chpassoc;0;bhatch -- which would set the variable immediately before running the hatch command. This would give you the same default regardless of what you did last, but it wouldn't change the "inherit" behavior.
     
    Tom Smith, Mar 31, 2005
    #15
  16. Hey Tom,

    Thanks for the reply. How do I go about converting your macro into an alias?

    Regards,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #16
  17. JamieLandmark

    Tom Smith Guest

    (defun c:h ()
    (setvar 'hpassoc 1))
    (initdia)
    (command "bhatch")
    (princ)
    )

    This will define a command "h" -- save it as a text file, maybe h.lsp, and add it to your startup suite.
     
    Tom Smith, Mar 31, 2005
    #17
  18. Thanks, Tom, for the routine. I'll use it instead of the standard bhatch.

    Regards,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #18
  19. Hey Tom,

    I tried using the routine, and have encountered a couple of errors.

    The routine starts the bhatch command upon starting AutoCad. After canceling the command, the following text appears:

    bhatch ; error: extra
    right paren on input

    When I enter "h" in order to activate the command, I receive the following:

    Command: h 1
    Command:

    The bhatch command doesn't appear.

    I tried to rectify the parenthesis issue by adding another paren to the beginning of the routine, but this didn't seem to help.

    I've already redifined my alias for bhatch from "h" to "hh", so I don't think I've got a problem of competing aliases (if this is a potential place for error).

    Do you know what's up with the routine?

    Thanks,

    Jamie
     
    JamieLandmark, Mar 31, 2005
    #19
  20. JamieLandmark

    Walt Engle Guest

    Try this:

    (defun c:h ()
    (setvar 'hpassoc 1)
    (initdia)
    (command "bhatch")
    (princ)
    )
     
    Walt Engle, Mar 31, 2005
    #20
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.