Jump to content

Plotting Lisp and Multiple Routines in one file


nlao

Recommended Posts

Hi everyone!

 

You guys have been very helpful in the past so I thnak you in advance for putting up with my questions!

 

I am attempting to write a set of LISP Routines to replace my scripts for plotting. Currently we have a custom ribbon with buttons to "quick plot" a tab. This saves opening the plot dialog box manually and setting each bit (we now have page setups but this does not help old files without them). The buttons were a quick and easy way of allowing someone to plot fast.

 

Whilst these work great the problem is that CutePDF produces relatively large PDFs, especially when compared to the 2011 DWG to PDF printer. So the guys on 2011 want to use the DWGtoPDF printer as it produces tiny files. However as the plotter is an internal autocad command no save dialog comes up when using the script (below).

 

^C^Cz;e;-plot;y;;DWG To PDF.pc3;ISO A3 (420.00 x 297.00 MM);M;L;N;E;1:1;c;y;monochrome.ctb;y;N;N;N;;N;Y;

 

So.....

 

I decided to change it all to a LISP. (Mammoth task, as I don't - didn't- know any LISP). My code thus far is as follows:

 

(DEFUN C:WAA3LPDF ()
 (SETVAR "CMDECHO" 0)
 (COMMAND "-PLOT"
   "Y"
   ""
   "DWG TO PDF.PC3"
   "ISO EXPAND A3 (420.00 x 297.00 MM)"
   "M"
   "L"
   "N"
   "E"
   "1:1"
   "CEN"
   "Y"
   "monochrome.ctb"
   "Y"
   "N"
   "N"
   "N"
   (getfiled "Save File as..."
      (strcat
 "(getenv "username")\\desktop"
 (vl-filename-base(getvar "DWGNAME")
   )
 )
      "pdf"
      5
   )
   "N"
   "Y"
 )
 (SETVAR "CMDECHO" 1)
 (PRINC)
)

 

My two questions are:

 

1) I am trying to get the default location for the file dialog to be the Desktop. I am not sure how the getenv works with the strcat commands but it currently doesn't work right!

 

2) There are currenly 5 variations for this, landscape, portrait for A1 and A3 and A1 at A3 landscape in the scripts. Do I need seperate LISPs for these or can I merge them all into all file and call each LISP from a button?

 

Thanks for your time!

 

Adam

Link to comment
Share on other sites

Q1 Theres some problems passing filename to pdf check posts here awaiting a solution.

 

Q2 you can make your button ask which style of plot then set variables ( setq scale "1:1") and replace "1:1" with scale also "P" or "L" with (setq orient "P")

 

something like

(setq choose ("\ngetstring "choose A1P A3P....."))

(cond

((= choose A1P) (setq scale "1:1")(setq orient "P"))

((= choose A1L..................

 

"M"

orient

"N"

"E"

scale

Edited by BIGAL
Link to comment
Share on other sites

Adam,

 

I think you've made a wise decision to use the button to call a LISP routine instead of using a macro.

 

This option provides an easier means for you (or someone else) to maintain the code if/when changes occur in the future, and allows for *error* checking etc. Most of the toolbar buttons, menus, and ribbon components I provide my users call/execute LISP.

 

1) I am trying to get the default location for the file dialog to be the Desktop. I am not sure how the getenv works with the strcat commands but it currently doesn't work right!

 

Look into the getfiled LISP function... I believe there's a bit code for creating a new file. Additionally, this gives the user a dialog from which to graphically select the destination, and allows you (the developer) to specify a start location (i.e., the user's desktop), and file format (i.e., .DWG).

 

2) There are currenly 5 variations for this, landscape, portrait for A1 and A3 and A1 at A3 landscape in the scripts. Do I need seperate LISPs for these or can I merge them all into all file and call each LISP from a button?

 

Bigal provided you one option, another might be:

 

(initget 7 "Landscape_a1 Portrait_a1 lAndscape_a1 pOrtrait_a3")
(cond ((= "Landscape_a1"
  (setq printLayout (getkword "\nEnter the desired print layout [Landscape_a1/Portrait_a1/lAndscape_a1/pOrtrait_a3]: ")))
 ;;<- Do this
 ) 
 ((= "Portrait_a1" printLayout)
 ;;<- Do this
 ) 
 ((= "lAndscape_a1" printLayout)
 ;;<- Do this
 ) 
 ((= "pOrtrait_a3" printLayout)
 ;;<- Do this
 ))

 

Hope this helps!

Link to comment
Share on other sites

  • 1 month later...

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...