See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: LISP to move up or down

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2014-08
    Posts
    1
    Login to Give a bone
    0

    Default LISP to move up or down

    Hello all! I have a need for a lisp routine that offsets a line and then changes its height a specified distance. I've attempted to create this routine as simply as possible and I'm absolutely stuck on one part... changing the "z" value.

    Here is the routine I've written:

    Code:
    (defun C:OE()
    
    (setq o1(getreal "\nEnter Offset Distance: ")) ;Gets offset distance
    (setq e1(getreal "\nEnter Elevation Change: ")) ;Gets elevation change
    
    (Command "offset" o1 pause pause "") ;Runs the offset command
    
    (Command "move" "L" "" "0,0,0" "@0,0,e1") ;changes elevation of last object
    
       (princ)
    )
    The second part of this is that I'd like to repeat the routine without re-entering information as you would with the offset (multiple) command. Can anyone help me?
    Last edited by rkmcswain; 2014-11-12 at 12:22 PM. Reason: added [CODE] tags

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    1

    Lightbulb Re: LISP to move up or down

    Re: the first part
    Note there are probably a dozen different ways to do this, so you'll probably see some other replies with more efficient methods, error checking, etc.
    Having said that, this is the quickest fix for what you have already started.

    Code:
    (defun C:OE ( / o1 e1 str)
    
    (setq o1(getreal "\nEnter Offset Distance: ")) ;Gets offset distance
    (setq e1(getreal "\nEnter Elevation Change: ")) ;Gets elevation change
    (setq str (strcat "0,0," (rtos e1 2)))
    
    (command "._offset" o1 pause pause "") ;Runs the offset command
    
    (command "._move" "_L" "" "" str) ;changes elevation of last object
    
    (princ)
    )
    You were trying to include the variable "e1" inside of a quoted string, and it will not evaluate like this.
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2015-10
    Location
    Alhambra
    Posts
    27
    Login to Give a bone
    1

    Default Re: LISP to move up or down

    Instead of using the Move command to just change the Elevation, you should use the Change command:
    (command"_.Change""_L""""_P""_E" e1 "")

Similar Threads

  1. Move MText at a certain Z value LISP
    By djin_fre3449006 in forum AutoLISP
    Replies: 5
    Last Post: 2013-11-28, 08:17 AM
  2. Lisp to move block along line
    By jayhay35365091 in forum AutoLISP
    Replies: 5
    Last Post: 2013-09-13, 06:01 PM
  3. LISP: move dopo di insert
    By dgomez.189897 in forum AutoCAD General
    Replies: 1
    Last Post: 2009-03-14, 08:38 PM
  4. Move 3D LISP
    By tollyboy22 in forum AutoLISP
    Replies: 6
    Last Post: 2006-04-13, 05:59 PM
  5. Move Lisp
    By lmitsou in forum AutoLISP
    Replies: 2
    Last Post: 2006-02-24, 02:56 PM

Tags for this Thread

Posting Permissions

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