Author Topic: Help needed with Plot Command & PDF file name in a Lisp...  (Read 3411 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
Help needed with Plot Command & PDF file name in a Lisp...
« on: December 03, 2007, 03:04:08 AM »
I am creating a routine that must be able to do the following.
I want the select views (this part is working) and create a pdf with the name of the view(this part is not).
How can this be done.?

Update...
I found a way to name pdf file the same as view, but how can i make
it to use and write it into the current project directory (dwgprefix).?

Code: [Select]
(defun getnames (tablename / data result)
  (while (setq data (tblnext tablename (null data)))
    (setq result (cons (list (cdr (assoc 2 data))
                             (cdr (assoc 40 data))
                             (cdr (assoc 41 data))
                       ) ;_ end of LIST
                       result
                 ) ;_ end of CONS
    ) ;_ end of SETQ
  ) ;_ end of WHILE
) ;_ end of DEFUN

  ;;--------------------------------------------------------------------
  ;help message for dialog box.
  (defun txtbox_infohelp ()
    (alert
      (strcat
        "Klik op OK om dit venster te sluiten.\n\n"
       )
    )
  )
  ;;--------------------------------------------------------------------

;Start routine
(defun c:view2pdf (/           ocmd        ocmddia     oexpert
                    oosmode     viewlijst   dianummer   viewselect
                    papierformaat           teller      item
                    orientatie  viewnaam    hoogte      breedte
                   ) ;Save values of variables to change

;;(setvar "cmdecho" 0)
(setvar "filedia" 0)


  (setq viewlijst ;Get list of views and sort it
         (vl-sort (getnames "view")
                  (function (lambda (a b) (< (nth 0 a) (nth 0 b))))
         ) ;_ end of VL-SORT
  ) ;_ end of SETQ
 
  (setq dianummer (load_dialog "view2pdf.DCL")) ;Start dialog to select views
  (new_dialog "view2pdf" dianummer)
  (setq teller 0)

(setq schaall (rtos(getvar "userr1")))
  (start_list "viewbox")
  (repeat (length viewlijst)
    (add_list (car (nth teller viewlijst)))
    (setq teller (+ 1 teller))
  ) ;_ end of REPEAT
  (end_list)

(setq printschaallijst(list  "1:1" "1:2" "1:5" "1:10" "1:20" "1:50" "1:100" "1:200" "1:500" "1:1000"))
(start_list "printschaallijst")
(mapcar 'add_list printschaallijst)
(end_list)


(setq printstijlctb (list
"Plotter Dun.ctb"
"Plotter Middel.ctb"
"Plotter Normaal.ctb"))
(start_list "printstijlctb")
(mapcar 'add_list printstijlctb)
(end_list)

(setq papierformaatlijst (list
"ISO A4 (210.00 x 297.00 MM)"
"ISO A3 (297.00 x 420.00 MM)"
))

  (start_list "papierformaatlijst")
(mapcar 'add_list papierformaatlijst)
(end_list)
 
  (action_tile
    "accept"
    "(progn
     (setq viewselect (get_tile \"viewbox\"))
     (setq papierformaat (get_tile \"papierformaatlijst\"))
     (setq printschaal (get_tile \"printschaallijst\"))
     (setq printctb (get_tile \"printstijlctb\"))
     (done_dialog)
    )"
    )

 
;;  ) ;_ end of ACTION_TILE


  ;;  CAB start
  (setq schaal (rtos(getvar "userr1")))
(setq dwgsch (strcat  "1:" schaal))
 
  (set_tile "viewbox" (if viewselect viewselect "")) ; default to none selected
  (action_tile "selall" "(select_all)")
  (action_tile "clrall" "(set_tile \"viewbox\" \"\")")
(defun select_all (/ sel cnt)
    (setq cnt 0
  sel ""
    )
    (repeat (length viewlijst)
      (setq sel (strcat sel (itoa cnt) " "))
      (setq cnt (1+ cnt))
    )
    (set_tile "viewbox" sel)
  )
  ;;  CAB end vl-list



(set_tile "papierformaatlijst" "1")
(set_tile "printstijlctb" "2")
(set_tile "printschaallijst" "2")
(set_tile "schaall" dwgsch)
(action_tile "fit" "(mode_tile \"printschaallijst\" (if (setq fitflag (= $value \"1\")) 1 0))")
(action_tile "cancel" "(setq viewselect \"\")(done_dialog)")
(action_tile "help" "(txtbox_infohelp)")
  (start_dialog)
  (unload_dialog dianummer) ;If a view is selected, then print it
  (if (/= viewselect "")
    (progn
      (setq viewselect (read (strcat "(" viewselect ")"))) ;Convert string to list
           (setq teller 0)
           (repeat (length viewselect) ;Loop to process all selected views
             (setq item     (nth teller viewselect)
                   viewnaam (car (nth item viewlijst)) ; Name of view
                   hoogte   (cadr (nth item viewlijst)) ; Height of view
                   breedte  (car (cddr (nth item viewlijst))) ; Width of view
             ) ;_ end of SETQ
             (if (< breedte hoogte) ;Set paperorientation according to height/width
               (setq orientatie "Portrait")
               (setq orientatie "Landscape")
            ) ;_ end of IF


     
(command "-plot" ; Print view
                    "yes" ;Detailed plot configuration? [Yes/No] <No>
                  "Model" ;Enter a layout name or [?] <Model>
         "DWG To PDF.pc3" ;Enter an output device name
(nth (atoi papierformaat) papierformaatlijst);Enter paper size:
      "M" ;Inches/milimeters
               orientatie ;Enter drawing orientation:
                      "n" ;Plot upside down:
                   "view" ;Enter plot area:
                  viewnaam ;Enter view name:
(if fitflag "Fit" (vl-string-translate ":" "=" (nth (atoi printschaal) printschaallijst))) ;Enter plot scale
                 "Center" ;Enter plot offset
                      "y" ;Plot with plot styles:
(nth (atoi printctb) printstijlctb) ;Enter plot style table name
                      "y" ;Plot with lineweights:
                      "n" ;Remove hidden lines
vienaam ;enter file name name of view.!!use fwgprefix for dir.
                      "n" ;save changes to  page setup [Yes/No] <No>
                      "y" ;Proceed with plot [Yes/No] <Y>:
             ) ;_ end of COMMAND

             (setq teller (+ 1 teller))
           ) ;_ end of REPEAT
    ) ;_ end of PROGN
  (princ "\nJe hebt geen views geselecteerd en er is dus ook niets geprint.....!")
  ) ;_ end of IF
(setvar "filedia" 1)
(setvar "cmdecho" 1)
  (princ)
) ;_ end of DEFUN
;|«Visual LISP© Format Options»
(72 2 1 2 T "end of " 60 9 1 1 0 T nil T T)
;*** DO NOT add text below the comment! ***|;
;;;; end routine;;;;;;;;
« Last Edit: December 03, 2007, 08:23:59 AM by CAB »

Amsterdammed

  • Guest
Re: Help needed...
« Reply #1 on: December 03, 2007, 07:12:48 AM »
Hi
something like
Code: [Select]
(setq filenaam (strcat (getvar 'dwgprefix)(vl-filename-base(getvar'dwgname))"-"  viewnaam  ".pdf"))
?


MvdP

  • Guest
Re: Help needed...
« Reply #2 on: December 03, 2007, 07:47:24 AM »
Hi Amsterdammed
And where should i put this line.?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #3 on: December 03, 2007, 08:40:28 AM »
MvdP
I think you will need to change the settings in your Adobe Driver.
http://www.theswamp.org/index.php?topic=5274.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #4 on: December 03, 2007, 08:45:55 AM »
I also found this:
http://tinyurl.com/3ytmak

Here is the full thread:
http://tinyurl.com/323wyc
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MvdP

  • Guest
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #5 on: December 03, 2007, 10:12:41 AM »
CAB Thanks for the links but i am not using an adobe driver but the one that is  installed with AutoCAD 2008.
DWg to PDF.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #6 on: December 03, 2007, 12:42:33 PM »
If I am understanding you correctly
Portions of what I use to plot pdfs semi-autonomously with just typing "PDF" at the command line.
Very infantile coding and organsization but it gets the job done.  :wink:
This places the pdf file in a adjacent folder to the my drawing file folder.


Code: [Select]
  ;;Start of StrPath defun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ;;Replaces "Drawings" folder with a "Transfer-OutGoing" folder
  (defun StrPath (/ OldName OldPath)
    ;;define the function and declare all variabled local

    (setq OldName (getvar "dwgname")) ;Extracts the Drawing File Name
    (setq OldPath (getvar "dwgprefix")) ;Extracts the Drawing Location
    (setq NewPath (vl-string-subst ; Swaps folders from teh existing path
    "\\Transfer-Outgoing\\"
    "\\Drawings\\"
    OldPath
  )
    )
    (setq NewFile (strcat NewPath Dates dwg#))
; Text String for New File
    (princ)
  ) ;End of StrPath defun

and then I feed it to the Main App.

Code: [Select]
;;; Main Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;;; PLOTS THE DRAWING TO A PDF FILE WITH THE CURRENT LAYOUT..
  (DWG-NUMB)
  (today)
  (StrPath)

  (vl-mkdir NewPath)

  (setq plotter (strcat "CWSs DWG To PDF.pc3"))
  (vl-cmdf "-PLOT" "NO" "" "PDF_ARCH-D" plotter NewFile "n" "y")
; End of Main App

I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

KewlToyZ

  • Guest
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #7 on: December 03, 2007, 10:53:09 PM »
Be careful with the 2008 dwg to pdf conversion.
I keep finding client files built with it end up having bugs in the XREF's.
They look fine in displaying virtually but when they are published using Adobe 8 the XREF's can publish way out of alignment. The only work around I found publishing them is using Brava Reader. Apparently they may share the same bug in pdf interpretation. Also your pdf files will be much larger with less quality than products like AcroPlot etc..

MvdP

  • Guest
Re: Help needed with Plot Command & PDF file name in a Lisp...
« Reply #8 on: December 04, 2007, 01:54:21 AM »
Thanks Amsterdammed
Finally got it figured out.Got it working the way i want it to work now.
And thanks  KewlToyZ for mentioning the possible error using the dwg to pdf.I haven't got any errors yet.