Lisp routine help

Discussion in 'AutoCAD' started by ghiggins457, Apr 2, 2004.

  1. ghiggins457

    ghiggins457 Guest

    I am trying to debug a lisp routine that somebody else wrote and I corrected (sorta). This program brings draws a line from a certain point and then draws a bubble and puts text in the center of the bubble prompted by the user. The problem is after you hit the text you want, the program tries creating a new layer for the bubble to be put into. It brings up a palette for you to pick colors, then a dialogue box for line types, then it creates a new layer. Can you see anything in this program that would prompt this to happen?

    (setq OM (getvar "ORTHOMODE")
    SM (getvar "SNAPMODE")
    OS (getvar "OSMODE")
    SF (getvar "DIMSCALE")
    CL (getvar "CLAYER")
    BM (getvar "BLIPMODE")
    PBX (getvar "PICKBOX")
    SU (getvar "SNAPUNIT")
    scale1 (* 1 SF)
    );end setq
    ;set variables for program
    ; (setvar "CMDECHO" 0)
    ; (setvar "MENUECHO" 1)
    ; (setvar "ORTHOMODE" 1)
    ; (setvar "SNAPMODE" 1)
    ; (setvar "OSMODE" 512)
    ; (setvar "PICKBOX" 10)
    ; (setvar "BLIPMODE" 0)
    ; (setvar "SNAPUNIT" '(0.03125 0.03125))
    ;Scale Component Values
    (setq rad1 (* scale1 0.125)
    );end setq
    ;get info
    (setq pt1 (getpoint "\nPick Leader Start point: "))
    (setq pt2 (getpoint pt1 "\nPick Bubble Location: "))
    (setq ang1 (angle pt1 pt2))

    ;processing info
    (setq pt3 (polar pt2 ang1 (* -1 rad1)))
    ;Draw Leader line and break it
    (command "line" pt1 pt3 "")
    (command "circle" pt2 rad1)
    (setq tag1 (getstring "\nType TAG Text:"))
    (command "erase" (ssget "L") "")
    (command "insert" "tag" pt2 scale1 "" 0 tag1)
    (setvar "osmode" 1)

    ;End Program
    ; (setvar "MENUECHO" 0)
    ; (setvar "ORTHOMODE" OM)
    ; (setvar "SNAPMODE" SM)
    ; (setvar "OSMODE" OS)
    ; (setvar "PICKBOX" PBX)
    ; (setvar "BLIPMODE" BM)
    ; (setvar "SNAPUNIT" SU)

    (princ)
    );END defun
     
    ghiggins457, Apr 2, 2004
    #1
  2. ghiggins457

    TCEBob Guest

    It appears that the program is assuming a block called "tag." Without
    the block it dies after erasing the circle. Where all the options come
    from, I guess there is a routine redefining "insert" floating around.
    Try "insert" at the command line and see what happens.

    rs
     
    TCEBob, Apr 2, 2004
    #2
  3. ghiggins457

    Barr Guest

    There's a CLAYER saved in the setup, but no call for changing the
    current layer. I'm guessing some code is missing. Maybe we could see
    the entire routine?
    -doug
     
    Barr, Apr 2, 2004
    #3
  4. ghiggins457

    CAB2k Guest

    The insert command is calling the dialog box, to supress it add a dash in front.

    (command "-insert" "tag" pt2 scale1 "" 0 tag1)

    Ther is no Layer command in the code you posted.
     
    CAB2k, Apr 2, 2004
    #4
  5. ghiggins457

    ghiggins457 Guest

    I am sorry. I should have been a little bit more clear. I do have a block set up that it is bringing into the drawing. I am trying to rewrite it so that I don't have to do that, but it is only causing problems. I am still getting the layer color and line type box. It's driving me crazy.
     
    ghiggins457, Apr 5, 2004
    #5
  6. ghiggins457

    ghiggins457 Guest

    Here is the entire routine:

    ; Program to Insert Tag and draw leader Tag.lsp

    (defun c:tag ( / pt1 pt2 pt3 pt4 pt5 pt6 pt7 ang1 ang1d ang2 ang2d rad1)

    ;get variable settings
    (setq OM (getvar "ORTHOMODE")
    SM (getvar "SNAPMODE")
    OS (getvar "OSMODE")
    SF (getvar "DIMSCALE")
    CL (getvar "CLAYER")
    BM (getvar "BLIPMODE")
    PBX (getvar "PICKBOX")
    SU (getvar "SNAPUNIT")
    scale1 (* 1 SF)
    );end setq
    ;set variables for program
    ; (setvar "CMDECHO" 0)
    ; (setvar "MENUECHO" 1)
    ; (setvar "ORTHOMODE" 1)
    ; (setvar "SNAPMODE" 1)
    ; (setvar "OSMODE" 512)
    ; (setvar "PICKBOX" 10)
    ; (setvar "BLIPMODE" 0)
    ; (setvar "SNAPUNIT" '(0.03125 0.03125))
    ;Scale Component Values
    (setq rad1 (* scale1 0.125)
    );end setq
    ;get info
    (setvar "osmode" 0)
    (setvar "orthomode" 0)
    (setq pt1 (getpoint "\nPick Leader Start point: "))
    (setq pt2 (getpoint pt1 "\nPick Bubble Location: "))
    (setq ang1 (angle pt1 pt2))

    ;processing info
    (setq pt3 (polar pt2 ang1 (* -1 rad1)))
    ;Draw Leader line and break it
    (command "line" pt1 pt3 "")
    (command "circle" pt2 rad1)
    (setq tag1 (getstring "\nType TAG Text:"))
    (command "erase" (ssget "L") "")
    (command "insert" "tag" pt2 scale1 "" 0 tag1)
    (setvar "osmode" 1)

    ;End Program
    ; (setvar "MENUECHO" 0)
    ; (setvar "ORTHOMODE" OM)
    ; (setvar "SNAPMODE" SM)
    ; (setvar "OSMODE" OS)
    ; (setvar "PICKBOX" PBX)
    ; (setvar "BLIPMODE" BM)
    ; (setvar "SNAPUNIT" SU)

    (princ)
    );END defun
     
    ghiggins457, Apr 5, 2004
    #6
  7. ghiggins457

    bob.at Guest

    How does your block "tag" lock like? It must be a block with *exact one* attribut, so that this attribut is filled with your input string

    bob.at
     
    bob.at, Apr 5, 2004
    #7
  8. ghiggins457

    ghiggins457 Guest

    I'm not quite sure I understand what you are talking about with the block.
     
    ghiggins457, Apr 5, 2004
    #8
  9. ghiggins457

    bob.at Guest

    Your block must meet the following criteria:
    1.) Name of the block must be "tag"
    2.) Block consists of some fixed geometric entities, i.g a polyline or some arcs (wich build your bubble)
    3.) Block must have an Attribut, which can store the text string you enter as "TAG text". This attribut is created with "ATTDEF" command.

    To get the block definition at insert command you can do one of two things:
    1.) make a drawing (with the bubble and the attdef) with name tag.dwg an store it in the autocad support path or
    2.) draw your bubble and the attdef and define a block using command "block" in the current drawing.

    I've tried this and had no problem using your program (AutoCAD 2002)

    bob.at
     
    bob.at, Apr 5, 2004
    #9
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.