Set variable to current dimstyle?

Discussion in 'AutoCAD' started by John Scott, Jul 12, 2004.

  1. John Scott

    John Scott Guest

    Is there a way to set a variable to be equal to the current dimstyle? I
    have a few routines that change to a preset dimstyle and I would like to be
    able to reset the current dimstyle when the routine is finished as well as
    include that in the error handling. Thanks.

    John
     
    John Scott, Jul 12, 2004
    #1
  2. John Scott

    coachball8 Guest

    (setq oldstyle(getvar "dimstyle")
    (setvar "dimstyle" whatever)
    Then at the end (setvar "dimstyle" oldstyle).
     
    coachball8, Jul 12, 2004
    #2
  3. (setq curdimstyle (getvar "DIMSTYLE"))
    (command "DIMSTYLE" "R" <your-other-style>)
    ....<do your thing>...
    (command "DIMSTYLE" "R" curdimstyle)

    Help says you can't use (setvar) to change DIMSTYLE -- as a system variable
    it's read-only. But it's also a command -- you have to use that route to
    change it, or change it back.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Jul 12, 2004
    #3
  4. Whoops...

    DIMSTYLE is a dialog-box command, so it should be:

    (setq curdimstyle (getvar "DIMSTYLE"))
    (command "-DIMSTYLE" "R" <your-other-style>)
    ....<do your thing>...
    (command "-DIMSTYLE" "R" curdimstyle)

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Jul 12, 2004
    #4
  5. John Scott

    coachball8 Guest

    Sorry for jumping the gun on it.........I guess I just assumed that since it is a system variable, it could be treated as such. Thanks for keeping me straight.
     
    coachball8, Jul 13, 2004
    #5
  6. John Scott

    John Scott Guest

    Kent, I have tried just that and I get an error. Is it because the (getvar
    "DIMSTYLE") returns a text value? If I type (setq curdimstyle (getvar
    "DIMSTYLE")) in the command line and press enter and then type (getvar
    "curdimstyle") the reply is nil.

    John
     
    John Scott, Jul 13, 2004
    #6
  7. John Scott

    John Scott Guest

    Kent,
    I got it to work now. Thank you for your help.

    John
     
    John Scott, Jul 13, 2004
    #7
  8. John Scott

    ECCAD Guest

    When you do:
    (setq curdimstyle (getvar "dimstyle"))
    You are assigning a 'new' symbol (variable) the 'value' of the current dimstyle. The 'curdimstyle' is NOT a 'system' variable, like the "DIMSTYLE" is. It is just a variable name. You CAN, however do:
    (setq curdimstyle (getvar "DIMSTYLE"))
    (command "-DIMSTYLE" "R" <your-other-style>)
    ...<do your thing>...
    (command "-DIMSTYLE" "R" curdimstyle)
    As Kent suggested.

    Bob
     
    ECCAD, Jul 13, 2004
    #8
  9. John Scott

    MP Guest

    If I type (setq curdimstyle (getvar
    that's because there is no system variable named "curdimstyle"

    if you type !curdimstyle you should see the value you stored in the variable
    'curdimstyle'
    or (eval curdimstyle)
     
    MP, Jul 13, 2004
    #9
  10. John Scott

    John Scott Guest

    Thanks for the explanation. I've got lots to learn!

    John
     
    John Scott, Jul 13, 2004
    #10
  11. John Scott

    John Scott Guest

    Thanks!

    dimstyle. The 'curdimstyle' is NOT a 'system' variable, like the "DIMSTYLE"
    is. It is just a variable name. You CAN, however do:
     
    John Scott, Jul 13, 2004
    #11
  12. The nil reply is because "curdimstyle" is not a system variable, so you
    can't "getvar" it. There are other ways to read the value of something you
    have set. You should be able, after doing (setq curdimstyle (getvar
    "DIMSTYLE")), to type in !curdimstyle and it should feed back the name of
    whatever was in the DIMSTYLE system variable.

    As to any other errors, it might depend on how you are using this. If it's
    in a pull-down or screen or tablet menu item, then you need to format it
    appropriately, which doesn't even need the (command) function (though you
    can keep it that way if you want):

    ....<whatever comes before>...+
    (setq curdimstyle (getvar "DIMSTYLE")) +
    -DIMSTYLE R <your-other-style> +
    ....<do your thing>...+
    -DIMSTYLE R !curdimstyle+
    ....<anything else>...

    If you keep the DIMSTYLE commands inside a (command) function, you need the
    quotation marks around stuff, including the <your-other-style> text if
    that's not a saved quantity. But you don't want the exclamation point in
    the last line -- it evaluates that quantity without it in those
    circumstances.

    Using it all as first presented, without plus signs, and requiring the
    (command) functions instead of the macro-type format, is appropriate for
    inside a defun item, and maybe some other things.

    I hope that helps.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Jul 13, 2004
    #12
  13. John Scott

    John Scott Guest

    Kent,
    Thank you for the explanation. I was indeed trying to use getvar as a
    quick test of what I had. I also found a step that I had missed and
    corrected that. Once I did (or stopped, in the case of trying getvar) those
    few things, the routine works just fine.
    I really appreciate all of the help.

    John
     
    John Scott, Jul 13, 2004
    #13
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.