How to continue a lisp routine after user selection?

How to continue a lisp routine after user selection?

Jason.Rugg
Collaborator Collaborator
1,402 Views
5 Replies
Message 1 of 6

How to continue a lisp routine after user selection?

Jason.Rugg
Collaborator
Collaborator

I have a very simple lisp routine that uses the -PLOT command, currently it is set to print extents. I am trying to make a modified version that prints a window. It works through the point of selecting the print window and then I have to finish out the command via command line instead of the lisp picking back up after the window selection.

 

Is there someway to get the lisp to continue on its own after the window selection?

0 Likes
Accepted solutions (2)
1,403 Views
5 Replies
Replies (5)
Message 2 of 6

rkmcswain
Mentor
Mentor

Have your tried asking the user for the window corners first and then plug in the result when the command string needs it.

(setq a (getpoint "\nPick first corner: "))
(setq b (getcorner a "\nPick other corner: "))
(vl-cmdf "-plot" blah blah blah a b blah blah....)
R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 6

Jason.Rugg
Collaborator
Collaborator

@rkmcswain I think this will eventually do it. Here is my actual lisp and how I implemented what you suggested. When I run the lisp I have to pick my window points twice and then it tells me the points are invalid and from the command line I have to manually start selecting "fit" and so on.

 

(defun c:MWBPDF nil
(setq a (getpoint "\nPick first corner: "))
(setq b (getcorner a "\nPick other corner: "))
(command "tilemode" "1")
(vl-cmdf "-plot" "Yes" "Model" "DWG To PDF.pc3" "ANSI expand B (11.00 x 17.00 Inches)" "Inches"
"Landscape" "No" "Window" "Fit" "Center" "Yes" "KCI-monochrome.ctb" "No" "A"
(strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".pdf") "No" "Yes")
(princ)
)

0 Likes
Message 4 of 6

rkmcswain
Mentor
Mentor
Accepted solution

This works for me, tested in 2019.

 

(defun c:FOO ( / a b)
  (setq a (getpoint "\nPick lower left corner: "))
  (setq b (getcorner a "\nPick upper right corner: "))
  (command "tilemode" "1")
  (vl-cmdf "-plot"
	   "Yes"
	   "Model"
	   "DWG To PDF.pc3"
	   "ANSI expand B (11.00 x 17.00 Inches)"
	   "Inches"
	   "Landscape"
	   "No"
	   "Window"
	   a
	   b
	   "Fit"
	   "Center"
	   "Yes"
	   "acad.ctb"
	   "No"
	   "A"
	   (strcat (getvar 'dwgprefix)
		   (vl-filename-base (getvar 'dwgname))
		   ".pdf"
	   )
	   "No"
	   "Yes"
  )
  (princ)
)
R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 5 of 6

scot-65
Advisor
Advisor
Ouch...

(if (and
(setq a (getpoint...
(setq b (getcorner...
);and
(progn
;bla bla bla...
);progn
);if

One forgot to test user input.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 6 of 6

Jason.Rugg
Collaborator
Collaborator
Accepted solution

Had to modify it slightly but here is what worked for me:

 

;(defun c:MWBPDF (/a b)
(setq a (getpoint "\nPick first corner: "))
(setq b (getcorner a "\nPick opposite corner: "))
(command "tilemode" "1")
(vl-cmdf "-plot"
"Yes"
"Model"
"DWG To PDF.pc3"
"ANSI expand B (11.00 x 17.00 Inches)"
"Inches"
"Landscape"
"No"
"Window"
a
b
"Fit"
"Center"
"Yes"
"KCI-monochrome.ctb"
"No"
"A"
(strcat (getvar 'dwgprefix)
(vl-filename-base (getvar 'dwgname))
".pdf"
)
"No"
"Yes"
)
(princ)
😉

0 Likes