Help with Lisp for plotting in PDF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone!
I try to write a lisp that does the following:
- asks the user to select the opposite corners of a window in the layout space
- uses these coordinates to calculate the size of the paper needed to plot (x and y)
- depending on the size it chooses between some already existing paper sizes (eg 1000x1000 in this case)
- plots (preview) the selected window in the paper
Unfortunately it doesn't work for some reason.. Can anyone help me in this? Is it a syntax error? Is it about the type (float) of the variables? Something else?
(DEFUN C:PDF (/ x1 x2 y1 y2 x y p1 p2)
;get the coordinates of the 2 opposite corners of the window
(setq p1 (getpoint "\nPick first corner of window: \n"))
(setq p2 (getcorner p1 "\nPick opposite corner of window: \n"))
;isolate x and y coordinates
(setq x1 (float(car p1)))
(setq y1 (float(cadr p1)))
(setq x2 (float(car p2)))
(setq y2 (float(cadr p2)))
;calculate paper size needed
(setq x (- x2 x1))
(setq y (- y2 y1))
;if lets say x=1000mm plot preview in paper size 1000x1000 (etc)
(IF (= x 1000.0)
(COMMAND "-PAGESETUP" "AutoCAD PDF (High Quality Print).pc3" "User 1 (1000.00 x 1000.00 MM)" "M" "P" "N" "W" p1 p2 "1=1" "C" "Y" "acad.ctb" "Y" "N" "N" "N")
(COMMAND "PREVIEW")
); end IF
);end DEFUN