Dimstyle check

Discussion in 'AutoCAD' started by Xolo, Jul 26, 2004.

  1. Xolo

    Xolo Guest

    Just curious,

    Is it possible to write a LISP that will

    A. Check to see if the user is in paperspace/modelspace.
    B. Insert a block at a scale of 1:1 if in paperspace.
    C. Insert the block at the dimscale factor if in modelspace.

    If so, do you think you could give me some pointers as to how to accomplish
    this? This would reduce my custom menu's quite considerably if this was
    possible.

    Thanks in advance for all your help,

    Xolo
     
    Xolo, Jul 26, 2004
    #1
  2. Xolo

    T.Willey Guest

    (setq spc1 (getvar "cvport")) <- get the space
    (setq dsc1 (getvar "dimscale"))
    (if (= spc 1) <- in a paper space
    (insert with paperspace setup)
    (insert with modelspace setup)
    );- if

    Tim
     
    T.Willey, Jul 26, 2004
    #2
  3. Xolo

    Xolo Guest

    Hey Chip,

    To allow my button to insert the individual block that I want do I modify
    the LISP in this section;

    (setq TPIBR (strcat"blockname=" TPIB))

    and just change "blockname" to the actual block that I want to have
    inserted?

    Thanks for the example,

    Xolo

    Here's an example....
     
    Xolo, Jul 26, 2004
    #3
  4. Xolo

    Rick Keller Guest

    How about this?
     
    Rick Keller, Jul 26, 2004
    #4
  5. Xolo

    Rick Keller Guest

    Probably should have cleared the vars..

    Rick
     
    Rick Keller, Jul 26, 2004
    #5
  6. Xolo

    T.Willey Guest

    Rick,

    You should check for the system variable "cvport" instead of "tilemode" because if you are in a viewport it will still think you are in paper space with tilemode.

    Just to let you know.
    Tim
     
    T.Willey, Jul 26, 2004
    #6
  7. Xolo

    Rick Keller Guest

    Good Point.

    Thanks
    Rick


    because if you are in a viewport it will still think you are in paper space
    with tilemode.
     
    Rick Keller, Jul 26, 2004
    #7
  8. Xolo

    Chip Harper Guest

    This is part of a freebie utility (you can download the entire thing from my
    site) for Tool Palettes. Basicly setq TBIP to the desired black name then
    load the insertion lisp. It inserts in model space at dimscale, in a open
    viewport at viewport scale and in paperspace at 1:1. (setq TPIBR
    (strcat"blockname=" TPIB)) is used to redefine a block on insertion...and
    that is controlled by this portion of the code ....
    (setq TPIR "T") ; Redefine block on insert T=true F=false
     
    Chip Harper, Jul 26, 2004
    #8
  9. Xolo

    ECCAD Guest

    To use Chips example:
    If your block is on a support path...
    (setq TPIB "blockname"); set your blockname here
    If your block is: H:\myblocks\blockname.dwg
    (setq TPIB "H:/myblocks/blockname")
    ........ Then
    (TPinsert)

    Bob
     
    ECCAD, Jul 26, 2004
    #9
  10. Xolo

    Xolo Guest

    Thanks Bob,

    My blocks are grouped into the menu file folder which does have a support
    path.

    Xolo

    To use Chips example:
    If your block is on a support path...
    (setq TPIB "blockname"); set your blockname here
    If your block is: H:\myblocks\blockname.dwg
    (setq TPIB "H:/myblocks/blockname")
    ........ Then
    (TPinsert)

    Bob
     
    Xolo, Jul 26, 2004
    #10
  11. Xolo

    Chip Harper Guest

    You would only need to have one lisp ... however you choose to select the
    blocks (toolbar, toolpalette or menu) you setq the value of TPIB to your
    block name and load the lisp file.

    Like this for a partial menu...

    [Column2_Above]^C^C(progn(setq TPIB "Column2_Above")(load "TPInsert"));

    Like this for a button...

    ^C^C(progn(setq TPIB "Column2_Above")(load "TPInsert"));
     
    Chip Harper, Jul 26, 2004
    #11
  12. Xolo

    Xolo Guest

    Chip,

    Just to make sure of what you've said,

    "Column2_Above" would contain the block name that I want to be used from the
    exerpt

    ^C^C(progn(setq TPIB "Column2_Above")(load "TPInsert"));
    from the toolbar button? That's way too easy......I keep thinking everything
    about LISP has got to be more complicated than that all the time.

    Thanks a lot,

    Xolo


    You would only need to have one lisp ... however you choose to select the
    blocks (toolbar, toolpalette or menu) you setq the value of TPIB to your
    block name and load the lisp file.

    Like this for a partial menu...

    [Column2_Above]^C^C(progn(setq TPIB "Column2_Above")(load "TPInsert"));

    Like this for a button...

    ^C^C(progn(setq TPIB "Column2_Above")(load "TPInsert"));
     
    Xolo, Jul 26, 2004
    #12
  13. Xolo

    Chip Harper Guest

    Yep thats it. I'm lazy and like things easy. :)
     
    Chip Harper, Jul 26, 2004
    #13
  14. Xolo

    Xolo Guest

    Hey Chip,

    It doesn't seem to be working for me. Don't know if you ever used to get
    this error when trying to use this LISP or not, but I'm adding it to see if
    you possibly have seen this problem before (this is spat out at the command
    line).

    Command: (progn(setq TPIB "Material Baloon 1-01.dwg")(load "TPInsert"))

    Error: syntax error; error: An error has occurred inside the *error*
    functionAutoCAD variable setting rejected: "cmdecho" nil

    Xolo
    Yep thats it. I'm lazy and like things easy. :)
     
    Xolo, Jul 26, 2004
    #14
  15. Xolo

    Chip Harper Guest

    No, if fact I just added a button coded as indicated.....from my mns file
    ....
    [_Button("Insert Block", "Steel_16.bmp". "Steel_24.bmp")]^C^C(progn(setq
    TPIB "Column2_Above")(load "TPInsert"));

    I downloaded the zip file and unzipped it to a folder in the support path,
    restarted AutoCAD, hit the button and it worked great.
    The block was inserted at dimscale. So the file wasn't corrupted in
    uploading....

    From my command line ...

    Command: (progn(setq TPIB "Column2_Above")(load "TPInsert"))
     
    Chip Harper, Jul 27, 2004
    #15
  16. Xolo

    Xolo Guest

    Chip,

    I'm using full AutoCAD 2002. Not LT. I've been having that "cmdecho" error
    quite often for some unknown reason.

    The file I am referencing to is already in the support path having added it
    personally.

    Am I correct in assuming the part "Column2_Above" is to be the name of the
    block that is going to be used? ie.
    (progn(setq TPIB "Material Baloon 1-01.dwg")(load "TPInsert"))

    I haven't set up a custom button yet, but that really isn't that hard at
    all......but I still keep getting that same error. Well, I guess I can just
    use what Rick suggested.....at least I'll take a look to see if it does
    really work for me and that I don't get any errors.

    If you can figure out what setting I have that's causing this error, please
    let me know. I'ld really rather to use your code.

    Thanks for all of your help,

    Xolo
    No, if fact I just added a button coded as indicated.....from my mns file
    ....
    [_Button("Insert Block", "Steel_16.bmp". "Steel_24.bmp")]^C^C(progn(setq
    TPIB "Column2_Above")(load "TPInsert"));

    I downloaded the zip file and unzipped it to a folder in the support path,
    restarted AutoCAD, hit the button and it worked great.
    The block was inserted at dimscale. So the file wasn't corrupted in
    uploading....

    From my command line ...

    Command: (progn(setq TPIB "Column2_Above")(load "TPInsert"))
     
    Xolo, Jul 27, 2004
    #16
  17. Xolo

    ECCAD Guest

    Comment out the line:
    (setvar "cmdecho" CME)
    within the error function.

    Bob
     
    ECCAD, Jul 27, 2004
    #17
  18. Xolo

    Xolo Guest

    I'll give that a try.

    Thanks Bob,

    Xolo

    Comment out the line:
    (setvar "cmdecho" CME)
    within the error function.

    Bob
     
    Xolo, Jul 28, 2004
    #18
  19. Xolo

    Xolo Guest

    Hey Bob,

    I tried that and I kept coming up with this error now

    (progn(setq TPIB "Material Baloon 1-01.dwg")(load "TPInsert"))

    Error: syntax error
    TPinsert Terminated

    Weird!?!?! What the heck could be causing this to happen? Could it be one of
    the variable settings?

    Xolo

    Comment out the line:
    (setvar "cmdecho" CME)
    within the error function.

    Bob
     
    Xolo, Jul 28, 2004
    #19
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.