+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    197

    Default How to continue execution of the routine?

    Registered forum members do not see this ad.

    Dear masters.
    After setting the UCS "OB" as continue the execution of the routine?
    Once completed the cycle, how to reset the previous UCS?

    Code:
    ;;teknomatika
    (defun c:asna (/ hdist vdist divn distseg pti1 pts1 pti2)
    (command "ucs" "OB" "pause" "");;The execution is stopping here.
    (setq hdist (getdist "\nHorizontal Distance: "))
    (setq vdist(getdist "\nVertical Distance "))
    (setq divn (getint "\nDivisons Number: "))
    (setq distseg (/ hdist divn))
    (setq pti1 (getpoint "\nStart Point: "))
    (setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1)))
    (setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
    (repeat divn
    (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""")
    (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
    (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
    (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))     
    (princ)
    );repeat
    )
    (prompt "\nTo invoque command type ASNA ")

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Code:
    (command "_.ucs" "_P")
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    197

    Default

    Quote Originally Posted by Lee Mac View Post
    Code:
    (command "_.ucs" "_P")
    Lee,
    That, to return to the previous UCS?
    But to allow the continuation of routine after setting the UCS "OB"?

    Code:
    (command "ucs" "OB" "pause" "");;The execution is stopping here.

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,008

    Default

    You need to write it like:
    Code:
    (command "_UCS" "_OB" pause)
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    197

    Default

    Tanks.
    Ok Works. But it ends with a weird "Command: nil"
    Is it so?


    Code:
    ;;teknomatika
    (defun c:asna (/ oldclay hdist vdist divn distseg pti1 pts1 pti2)
    (setq oldclay (getvar "clayer"))
    (command "layer" "new" "asnas" "color" "8" "asnas" "")
    (command "layer" "set" "asnas" "")
    ;;(command "_.ucs" "_P");; Not work
    (command "_UCS" "_OB" pause)
    (setq hdist (getdist "\nHorizontal Distance: "))
    (setq vdist(getdist "\nVertical Distance "))
    (setq divn (getint "\nDivisons Number: "))
    (setq distseg (/ hdist divn))
    (setq pti1 (getpoint "\nStart Point: "))
    (setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1)))
    (setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
    (repeat divn
    (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""")
    (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
    (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
    (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))     
    (princ)
    );repeat
    (setvar "clayer" oldclay)
    (command "_.ucs" "_P")
    )
    (prompt "\nTo invoque command type ASNA ")

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,008

    Default

    I did some corrections to your code:
    • there is no need to disable AutoOsnap when end the command call,
    • the repeat of that PRINC call is useless
    • in order to allow the routine to exit quietly you need to add a PRINC call as last statement; this will get rid of that final nil.
    Code:
    ...
      (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non" "")
      (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
      (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
      (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))
      (princ)
     );repeat
     (setvar "clayer" oldclay)
     (command "_.ucs" "_P")
     (princ)
    )
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  7. #7
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    197

    Default

    Quote Originally Posted by MSasu View Post
    I did some corrections to your code:
    • there is no need to disable AutoOsnap when end the command call,
    • the repeat of that PRINC call is useless
    • in order to allow the routine to exit quietly you need to add a PRINC call as last statement; this will get rid of that final nil.
    Code:
    ...
      (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non" "")
      (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
      (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
      (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))
      (princ)
     );repeat
     (setvar "clayer" oldclay)
     (command "_.ucs" "_P")
     (princ)
    )
    Mircea,

    tanks for the help!

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    teknomatika,

    Aside: do you understand why the 'nil' was returned to the command-line in your original code?
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #9
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    197

    Default

    Quote Originally Posted by Lee Mac View Post
    teknomatika,

    Aside: do you understand why the 'nil' was returned to the command-line in your original code?
    Lee,
    I think so.
    For explanation of Mircea, but also because of the fact it was a mistake to my poor location of (Princ) inside the loop.

    Tanks for the help.

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by teknomatika View Post
    I think so.
    To clarify for you: In your original code, nil is returned to the command-line because the last evaluated expression enclosed by your defun expression is the command expression, and the command function always returns nil (as stated in the documentation).

    Note this behaviour from the Visual LISP IDE Help Documentation on the defun function:

    Quote Originally Posted by VLIDE Help
    defun

    Defines a function.
    Code:
    (defun sym ([arguments] [/ variables...]) expr...)
    Arguments

    sym A symbol naming the function.

    arguments The names of arguments expected by the function.

    / variables The names of one or more local variables for the function.

    expr Any number of AutoLISP expressions to be evaluated when the function executes.

    Return Values

    The result of the last expression evaluated.
    This inherent behaviour is intuitive when definining 'subfunctions', for example:
    Code:
    (defun add2 ( x ) (+ x 2))
    When called with a numerical argument, the above function will return the result of the last expression evaluated inside the function definition (defun), that is, the call to the + function, returning the supplied argument plus 2:
    Code:
    _$ (add2 5)
    7
    Note that this is a property of the defun function and hence applies to all functions defined in such a way. Those functions whose symbol name is prefixed with c: are treated in exactly the same way - the c: prefix simply allows the function to be called as a command directly from the command-line.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. identify the execution of a command
    By rodrigo_sjc_sp in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 17th Oct 2012, 03:00 pm
  2. Customizing user input during command execution
    By sekarr24 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st May 2010, 07:11 pm
  3. Continue Dimension
    By MrT in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 8th Oct 2009, 04:05 pm
  4. Lisp execution error...solution needed..
    By goldy2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 11th Sep 2009, 11:15 am
  5. Exit without execution error (VBA - v2000i)
    By Joltremari in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Jul 2006, 12:24 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts