Print Page | Close Window

Polygcode.lsp

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=13765
Printed Date: 31.May.2026 at 21:19


Topic: Polygcode.lsp
Posted By: r.b.hughes
Subject: Polygcode.lsp
Date Posted: 07.Oct.2022 at 17:59
I have been using this .lsp file (downloaded from this site) for students to extract XYZ coordinates to be used in a CNC.program. I am trying to adapt the program to extract XZ coordinates for programs for a CNC lathe. The problem I am having is that the X values I get are radius, and I need diameter. I have not been able to find out how to multiply the polyline point value by 2.

Here is a clip of the section of the script

   (foreach PT1 listCOORDINATES ;all vertices
    (princ (strcat "\n" "X" (rtos (cadr PT1) 2 __PV_DP) __PV_Delimiter
                        "Z" (rtos (car PT1) 2 __PV_DP) )) ; display XY

For simplicity, the Y coordinate (cadr) is the X axis, and the X coordinate (car) is the Z axis.

I need the value of the Y coordinate to be multiplied by 2. Can anyone suggest how to do this?

Many thanks.



Replies:
Posted By: Kent Cooper
Date Posted: 10.Oct.2022 at 14:23
Very basic AutoLisp multiplication:
....
(princ (strcat "\n" "X" (rtos (* (cadr PT1) 2) 2 __PV_DP) __PV_Delimiter
....


Posted By: r.b.hughes
Date Posted: 10.Oct.2022 at 21:43
Thanks for the help.

I am not a LISP user. My mistake was not putting "cadr PT1" in brackets.



Print Page | Close Window