Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lisp to define points for cnc path

Status
Not open for further replies.

11991

Mechanical
Dec 28, 2004
57
How do I change the following Lisp program so that the first number is the x-value and the second is y-value but shows as 2X the value(is diameter instead of radius)?

(DEFUN C:pTT (/ osm p1 x y s p2) ; ID a point, place coordinates text
(graphscr)
(setq osm (getvar "osmode"))
(command "osmode" 53)
(setq p1 (getpoint "\nSNAP to point to be ID'd: ")
x (car p1)
y (cadr p1)
s (strcat "(" (rtos x) "," (rtos y) ")")
)
(command "osmode" 0)
(setq p2 (getpoint p1 "\nPick point for end of Leader: "))
(COMMAND "DIM1" "LE" p1 p2 "" s)
(command "osmode" osm)
(princ)
)


Thank You
 
Replies continue below

Recommended for you

So you want the y value to actually report as 2xy? (not sure how this works for labelling a radius though...)
Then this:

Code:
(DEFUN C:PTT (/ osm p1 x y s p2) ; ID a point, place coordinates text
 (graphscr)
 (setq osm (getvar "osmode"))
 (command "osmode" 53)
 (setq p1 (getpoint "\nSNAP to point to be ID'd: ")
        x (car p1)
        y (cadr p1)
        2y (* 2 y);;added this line
        s (strcat "(" (rtos x) "," (rtos 2y) ")")
  )
 (command "osmode" 0)
 (setq p2 (getpoint p1 "\nPick point for end of Leader: "))
 (COMMAND "DIM1" "LE" p1 p2 "" s)
 (command "osmode" osm)
 (princ)
)


 
I don't think I explained the problem well.
We want to define the contour of a formed Roll from a "zero" point. This "zero" point is on the centerline axis and on one face of the Roll. We need all tangent points of the contour so that we can write a CNC program from these points. Each point is a distance from the "zero face" and on a radius(but the program needs the Diameter-therefore 2 times y value).
I hope this clears up the question.
TIA
11991
 
Nope, not clear to me. I think I'll need a sketch. Maybe because the CNC process is not clear to me. The main thing I'm not grasping is the reference to "y" as a radius. The first routine merely labels the x & y coordinates of a picked point. My editited routine used 2*y in place of y. If not a sketch maybe an example describing a point and coordinates, and how it should be labeled.
 
While diameter would be plus and minus y
I do not understand why 2y would define the
diameter from the zero axis. If your input
is the diameter instead of the radius, then
you want to define y as the diameter divided
by 2 or diameter times 0.50 for the y value.
 
I had problems with the link, couldn't download.

And a question for you- did you try the lisp routine I posted? It did incorporate the "y=2*y" you keep mentioning. :)
 
I can not get it to load. It shows it loads but does not work. I look at the Load Applications function and it is not there, however it is in the Startup Suite and the Support File Search Path.
I also tried altering the PPP Lisp from above with your changes with no luck. I only get the (x,y) values.
 
I think the problem is in how you are saving the file or loading it. If I copy and paste the above code into AutoCAD's command line (a shortcut way of loading code), then type PTT, it labels points with 2 times the y value. Try pasting the above code into notepad, save with a ".lsp" extension. Remove other routine from startup suite. Load this new routine. Should work.
 
Oh yeah, if you just want to edit yours with my changes, I didn't flag an important item you might have missed:

s (strcat "(" (rtos x) "," (rtos 2y) ")")

 
Thank you, CarlB. It works as you said.
11991
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor