Jump to content

Point Problem did not mark the point for xy variable


Recommended Posts

Posted

Point Problem did not mark the point for xy variable

 

(DEFUN C:SD()

  (SETQ

    P1(GETPOINT "\n Pick Start Point :")

    P2(GETPOINT P1 "\n Pick End Point :")

    EV(GETREAL  "\n Enter Distance :")

    XV(+(CAR P1)EV) YV(CADR P1) ZV(CADDR P1)XY(LIST XV YV ZV)

    

    )

  (COMMAND "POINT" P1) ; POINT P1

  (COMMAND "POINT" P2) ; POINT P2

  (COMMAND "POINT" XY) ; NEW POINT FROM P1 X - AXIS  VALUE FOR EV DISTANCE

  

  (PRINT XY)

  )

 

Posted (edited)

Do a quick test and see what the LISP is doing use this at the end:

 

(princ "\n") ; newline
(princ P1)
(princ "\n")
(princ P2)
(princ "\n")
(princ XY)

 

Might give you a hint what isn't quite right. Noting that in the command line something like ( x y z) could be a point, something like 575 is a number, probably not a point

 

Though on my test it did make a point

Edited by Steven P
Posted

Commands in general expect strings specifically when referring to coordinates, so here is one way doing it.

(setq XY (strcat (rtos XV) "," (rtos YV) "," (rtos ZV)))

(command "POINT" xy)

 

  • Like 1
Posted

This is working on my end, I don't know if the missing spaces when setting the variables might affect, so here is what I used and works.

(defun c:sd(/ ev p1 p2 xv xy yv zv)
  (setq p1 (getpoint "\n Pick the start point :")
        p2 (getpoint p1 "\n Pick the end point :")
        ev (getreal  "\n Enter the distance :")
        xv (+(car p1) ev)
        yv (cadr p1)
        zv (caddr p1)
        xy (list xv yv zv)
  )
  (command "point" p1) ; point p1
  (command "point" p2) ; point p2
  (command "point" xy) ; new point from p1 x - axis  value for ev distance
  (print xy)
  (princ)
)

 

Posted (edited)

and another way:

 

(DEFUN C:SD ( / )
  (setq P1 (GETPOINT "\n Pick Start Point :") )
  (setq P2 (GETPOINT P1 "\n Pick End Point :") )
  (setq EV (GETREAL  "\n Enter Distance :") )
  (setq XY (mapcar '+ (list EV 0 0) P1))

  (COMMAND "POINT" P1) ; POINT P1
  (COMMAND "POINT" P2) ; POINT P2
  (COMMAND "POINT" XY) ; NEW POINT FROM P1 X - AXIS  VALUE FOR EV DISTANCE
  (PRINT XY)
)

 

 

EDITED CODE SLIGHTLY

Edited by Steven P
  • Like 2
Posted
6 hours ago, Steven P said:

and another way:

 

(DEFUN C:SD()
  (SETQ
    P1(GETPOINT "\n Pick Start Point :")
    P2(GETPOINT P1 "\n Pick End Point :")
    EV(GETREAL  "\n Enter Distance :")
    (SETQ XY (mapcar '+ (list EV 0 0) P1)))
  )
  (COMMAND "POINT" P1) ; POINT P1
  (COMMAND "POINT" P2) ; POINT P2
  (COMMAND "POINT" XY) ; NEW POINT FROM P1 X - AXIS  VALUE FOR EV DISTANCE
  (PRINT XY)
)

 

error: too few arguments in SETQ: (SETQ P1 (GETPOINT "\n Pick Start Point :") P2 (GETPOINT P1 "\n Pick End Point :") EV (GETREAL "\n Enter Distance :") (SETQ XY (MAPCAR (QUOTE +) (LIST EV 0 0) P1)))

Posted
8 hours ago, Steven P said:

Do a quick test and see what the LISP is doing use this at the end:

 

(princ "\n") ; newline
(princ P1)
(princ "\n")
(princ P2)
(princ "\n")
(princ XY)

 

Might give you a hint what isn't quite right. Noting that in the command line something like ( x y z) could be a point, something like 575 is a number, probably not a point

 

Though on my test it did make a point

(4396.89 2058.79 0.0)
(4496.89 2058.79 0.0)
4421.8855,2058.7864"4421.8855,2058.7864"
 

Posted
4 hours ago, MUTHUKUMAR1983 said:

error: too few arguments in SETQ: (SETQ P1 (GETPOINT "\n Pick Start Point :") P2 (GETPOINT P1 "\n Pick End Point :") EV (GETREAL "\n Enter Distance :") (SETQ XY (MAPCAR (QUOTE +) (LIST EV 0 0) P1)))

 

I've edited the code above, should be fine now

Posted
4 hours ago, MUTHUKUMAR1983 said:

(4396.89 2058.79 0.0)
(4496.89 2058.79 0.0)
4421.8855,2058.7864"4421.8855,2058.7864"
 

 

So the point XY looks very different to the other points.... now you can see where the error is you can work out how to fix it, to make a list and not a string (4421.8855,2058.7864 ) ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...