Results 1 to 4 of 4

Thread: Need point to relate to picked points, not QUOTE and static. .

  1. #1
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Need point to relate to picked points, not QUOTE and static. .

    I am just starting w/ lisp and trying to make a routine to draw a line between blocks based on three points. I select the first two points, in this case, midpoints of sqaures, or quadrants of circles. The problem is, the third point I am getting by recombining the x coordinate from one of my picked points, and the y coordinate from the other picked point, and it is quoting that exact point. I need the third point to be recalculated every time I use the command relative to the two points I pick, but don't know the command(s) that will allow this.

    Here is what I have so far. This was done using Lisp generator also, which might change the rules a bit:

    Code:
    ; Define the function (the program). 
    (defun c:WIRE ( / PNT1 PNT3 PNT2 OLDCE OLDERR OLDTE)
      ; Save the current value of cmdecho then redefine it. 
      (setq OLDCE (getvar "cmdecho"))
      (setvar "cmdecho" 1)
      ; Save the current value of texteval then set it to 1
      (setq OLDTE (getvar "texteval"))
      (setvar "texteval" 1)
      ; Save the current value of the error handling subroutine then redefine it. 
      (setq OLDERR *error*)
      (defun *error* (errmes)
        (princ (strcat "\nExecution of WIRE4 halted by the following error: " ERRMES))
        (setvar "cmdecho" OLDCE)
        (setq *error* OLDERR)
        (prin1)
      )
      ;(setq *error* nil)
      ; NOTE: to turn error handling off, erase the semicolon in the line above. 
    
      ; GET a POINT from the user and store it in PNT1. 
      (setq PNT1 (getpoint "\nSelect the starting point. "))
    
      ; GET a POINT from the user and store it in PNT3. 
      (setq PNT3 (getpoint "\nSelect the ending point. "))
    
      ; OPERATION - store the result in PNT2.  
      (setq PNT2 (LIST (CAR (QUOTE (6756.58 2948.74 0.0))) (CADR (QUOTE (7003.39 3010.24 0.0))) (CADDR (QUOTE (7003.39 3010.24 0.0)))))
    
      ; Input to AutoCAD's command line. 
      (command
        "line"
        PNT1
        PNT2
        PNT3
        ""
      )
    
      ; Reset "cmdecho" to previous value. 
      (setvar "cmdecho" OLDCE)
      ; Reset "texteval" to previous value. 
      (setvar "texteval" OLDTE)
      ; Reset *error* to previous definition. 
      (setq *error* OLDERR)
      ; Exit quietly (no return value.)
      (prin1)
    )

    Also, I would need this to do a condition, or if then, because based on the location of the two blocks I am selecting, the x coordinate and y coodinate would need to be swapped to make the line draw correct, but I will take this one step at a time right now. Here are some screen shots.

    Any help would be appreciated. I'm sure this is an easy question.
    Attached Images Attached Images
    Last edited by RobertB; 2009-05-27 at 04:52 PM. Reason: Added code tags

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Need point to relate to picked points, not QUOTE and static. .

    Whatever that "generator" is, it certainly is doing some old-school stuff with error handling. Decades old-school.

    As for your real issue, you gotten the points stored in variables, use them.

    And there is no need to modify TextEval in the current code.

    (Green is stuff to delete, red stuff to add.)

    Code:
    ; Define the function (the program). 
    (defun c:WIRE ( / PNT1 PNT3 PNT2 OLDCE OLDTE OLDERR *error*)
      ; Save the current value of cmdecho then redefine it. 
      (setq OLDCE (getvar "cmdecho"))
      (setvar "cmdecho" 1)
      ; Save the current value of texteval then set it to 1
      (setq OLDTE (getvar "texteval"))
      (setvar "texteval" 1)
      ; Save the current value of the error handling subroutine then redefine it. 
      (setq OLDERR *error*)
      (defun *error* (errmes)
        (princ (strcat "\nExecution of WIRE4 halted by the following error: " ERRMES))
        (setvar "cmdecho" OLDCE)
        (setq *error* OLDERR)
        (prin1)
      )
      ;(setq *error* nil)
      ; NOTE: to turn error handling off, erase the semicolon in the line above. 
    
      ; GET a POINT from the user and store it in PNT1. 
      (setq PNT1 (getpoint "\nSelect the starting point. "))
    
      ; GET a POINT from the user and store it in PNT3. 
      (setq PNT3 (getpoint "\nSelect the ending point. "))
    
      ; OPERATION - store the result in PNT2.  
      (setq PNT2 (LIST (CAR (QUOTE (6756.58 2948.74 0.0))) (CADR (QUOTE (7003.39 3010.24 0.0))) (CADDR (QUOTE (7003.39 3010.24 0.0)))))
      (setq PNT2 (list (min (nth 0 PNT1) (nth 0 PNT3)) (max (nth 1 PNT1) (nth 1 PNT3)) 0.0))
    
      ; Input to AutoCAD's command line. 
      (command
        "line"
        PNT1
        PNT2
        PNT3
        ""
      )
    
      ; Reset "cmdecho" to previous value. 
      (setvar "cmdecho" OLDCE)
      ; Reset "texteval" to previous value. 
      (setvar "texteval" OLDTE)
      ; Reset *error* to previous definition. 
      (setq *error* OLDERR)
      ; Exit quietly (no return value.)
      (prin1)
    )
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  3. #3
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Re: Need point to relate to picked points, not QUOTE and static. .

    Yea, some of the stuff you deleted I saw myself and figured it was things added by the generator that weren't needed, but if I don't know what I'm doing I tend to not touch things.

    Routine works as it should with your changes, thanks a lot! Now I just have to analyze and see what that codes doing.

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Need point to relate to picked points, not QUOTE and static. .

    Quote Originally Posted by M. Kubitza View Post
    Routine works as it should with your changes, thanks a lot! Now I just have to analyze and see what that codes doing.
    This is the most important change:
    Code:
    (setq PNT2 
     (list 
      (min (nth 0 PNT1) (nth 0 PNT3)) 
      (max (nth 1 PNT1) (nth 1 PNT3)) 
      0.0))
    Here is the breakdown:
    Make variable pnt2 a list of three coordinates. The first coordinate (X) needs to be the minimum of the two selected point's X coordinate. The second coordinate (Y) needs to be the maximum of the two selected point's Y coordinate. The third coordinate is immaterial and is just forced to zero. It could be calculated if needed, but since you are doing a diagram we are safe assuming zero.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

Similar Threads

  1. Rotating text based on 2 picked points
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 9
    Last Post: 2014-02-12, 05:25 PM
  2. Extrusion between picked points
    By dct73 in forum Revit Architecture - General
    Replies: 5
    Last Post: 2012-03-29, 08:25 PM
  3. Determining if a Point is picked inside a 3D Solid
    By roger_wall in forum VBA/COM Interop
    Replies: 0
    Last Post: 2007-02-01, 12:07 AM
  4. Replies: 3
    Last Post: 2006-06-08, 08:54 AM
  5. Associative dimensions that remember side of point picked
    By lcamara in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2005-01-14, 11:16 PM

Posting Permissions

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