lisp help

Discussion in 'AutoCAD' started by molokaiboy, Jun 26, 2004.

  1. molokaiboy

    molokaiboy Guest

    I am trying to modify this lisp routine that was given to me but keep running into problems. After it goes through its routine, and inserts the part, I want to run command "X" and command "Y". How do I do this?

    (defun add ()
    (amnew "i" prt)
    )


    (defun ins (/ nlocal nextrn)
    (setvar "filedia" 0)
    (setq nlocal (ammodelinfo "_l"))
    (setq nextrn (ammodelinfo "_x"))
    (if (and (= nlocal 0) (= nextrn 0))
    (Command "_-amcatalog" prt) ;; Attach is assumed
    (Command "_-amcatalog" "" prt)
    )
    (setvar "filedia" 1)

    )

    (DEFUN C:pP-200689-001()
    (setq prt "PP-200689-001")
    (if(tblsearch "block" prt)
    (add)
    (ins)

    ))


    (COMMAND "X") (COMMAND "Y")



    TIA

    Collin
     
    molokaiboy, Jun 26, 2004
    #1
  2. molokaiboy

    Paul Turvill Guest

    What you've posted is only a small part of what would appear to be a much
    larger LISP application. Without code for all of the various functions it
    calls, it's impossible to offer much help. What are the commands "x" and "y"
    anyway?
    ___

    running into problems.
     
    Paul Turvill, Jun 26, 2004
    #2
  3. molokaiboy

    Dean McCarns Guest

    I'm assuming that command "x" and command "y" are native AutoCAD commands
    because if there LISP routines you dont need the command function.

    What your probably running into is that if you run "x" then "y", "y" is
    trying to execute while "x" is asking for some kind of user imput and your
    getting some kind of error message like "invalid entry" or "...does not
    recognize...." because theres no Pause between the two.

    If this is the case, make sure you pause command "x" when asking for user
    imput and ensure "x" is finished executing before you allow "y" to start.

    Do a search on pausing command on the NG, this is thouroughly covered and
    many ways to achive this.

    --
    Dean McCarns
    Enterprise Solutions Pioneers, Inc.

    804-675-2377
    running into problems. After it goes through its routine, and inserts the
    part, I want to run command "X" and command "Y". How do I do this?
     
    Dean McCarns, Jun 26, 2004
    #3
  4. molokaiboy

    Mark Propst Guest

    As Paul says, there's not enough to go on here - other to make wild guesses
    so here's mine :)
    where you have (command "X")
    as we all know "X" is not a native autocad command.
    so you would not use the (command "X") syntax.
    My wild guess is that "X" command is defined somewhere else in your routine
    thusly:
    (defun c:X(????something or maybe nothing in here ???)
    ....something in here presumably....
    )
    if that's the case, then you would call it like
    (C:X)
    ....??? are we getting warm?

    running into problems. After it goes through its routine, and inserts the
    part, I want to run command "X" and command "Y". How do I do this?
     
    Mark Propst, Jun 27, 2004
    #4
  5. molokaiboy

    CAB2k Guest

    See comments in code:

    Code:
    (defun add ()
    (amnew "i" prt)
    )
    
    (defun ins (/ nlocal nextrn)
    (setvar "filedia" 0)
    (setq nlocal (ammodelinfo "_l"))
    (setq nextrn (ammodelinfo "_x"))
    (if (and (= nlocal 0) (= nextrn 0))
    (command "_-amcatalog" prt)
    ;; Attach is assumed
    (command "_-amcatalog" "" prt)
    )
    (setvar "filedia" 1)
    
    )
    
    (defun c:pp-200689-001 ()
    (setq prt "PP-200689-001")
    (if (tblsearch "block" prt)
    (add)
    (ins)
    
    )
    ) ; End of defun c:pp-200689-001
    ;;
    ;;  any other code will run when you load this file
    ;;  not when you run c:pp-200689-001
    (command "X")
    (command "Y")
    
    ;;;
    ;;;=====================================
    ;;; it should look like this
    ;;;=====================================
    (defun c:pp-200689-001 ()
    (setq prt "PP-200689-001")
    (if (tblsearch "block" prt)
    (add)
    (ins)
    
    )
    
    ;;  added code goes here
    ;; like move the inserted block
    (command "._move" (entlast) "" pause pause)
    ;;
    ) ; End of defun c:pp-200689-001
     
    CAB2k, Jun 27, 2004
    #5
  6. molokaiboy

    molokaiboy Guest

    Commands "X" and "Y" would represent an alert box and localizations of the part. I am trying to localize the part once it has been inserted, then have an alert box pop up. I seem to be getting caught because I don't have a pause added to the code. How should I do this?

    TIA

    Collin
     
    molokaiboy, Jun 28, 2004
    #6
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.