+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default PDF Printable Area LISP

    Registered forum members do not see this ad.

    Hello,
    A question about plotting to PDF and paper printable areas that I wonder if anyone can help with.


    I have a LISP routine that plots a PDF to the file where the original drawing is saved. This mostly works great for me.


    Our drawing standards are to use the default standard paper sizes printable area for a paper plot (so an A3 sheet might have 6mm left, 5m right, 18mm top and 17mm bottom margin to the plot), but for a PDF plot to use a modified standard paper size with a 0mm margin all round the printable area (so it plots full size).


    My LISP routine detects the current paper size then uses the modified paper size based on 'IF' commands (If papersize = A4 then use A4_0mm_margin type command). This is good for 3 or 4 paper types - any more and the code gets quite lengthy.


    My question is is there a better way? Is there a routine or command that will temporarily set the paper printable area to have a 0mm margin all round (or any other size I want), then do the plotting, and without changing anything or saving anything?


    Thanks for any help

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,366

    Default

    You could use a cond expression in place of your if statement to reduce the amount of expression nesting.

    It is difficult to advise without seeing your current code.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default

    Yup, I get the point of cond, it would make the code a bit shorter.


    If you don't mind and are gentle with me, then I can post the relevant LISP routines (I appreciate I am not the best at this and have taken a lot from forums like this!). Will take me a short while to get rid of the parts that aren't relevant and add some notes what I am hoping each part does

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,366

    Default

    Quote Originally Posted by Steven P View Post
    If you don't mind and are gentle with me, then I can post the relevant LISP routines (I appreciate I am not the best at this and have taken a lot from forums like this!).
    Don't worry, this is not that kind of forum

    Quote Originally Posted by Steven P View Post
    Will take me a short while to get rid of the parts that aren't relevant and add some notes what I am hoping each part does
    No problem.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default

    Hi sorry it took me a while, the LSP file I use had other things in it that aren't relevant, it took me a while to remove them and make sure I didn't take anything important out.
    Below is the LIPS routines that I use to make a PDF plot:


    Oh, just paranoid that you will all be rolling on the floor laughing at basic mistakes that all




    **EDITED TO PUT CODE IN CODE TAGS - SEE BELOW **
    Last edited by Steven P; 22nd Mar 2016 at 06:01 pm. Reason: Put code in Code Tags (I hope!)

  6. #6
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default

    I think the smiling faces should be : p (with no spaces)

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,366

    Default

    See here for how to post your code within a code pane: Code Posting Guidelines
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default

    Many apologies - I hadn't read that

  9. #9
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    1,232

    Default

    Now that you read it, you could edit your post...

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  10. #10
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2015
    Posts
    74

    Default

    Registered forum members do not see this ad.

    My code so far:


    (defun c:currentpapersize()
    ;;This part looks at the page setup and returns simple paper size
    ;;e.g A0P (A0 size, portrait orientation)
    ;;
    ;;This seperate because it is also used in other LISP routines elsewhere
    ;;
    (setq plotsize (vla-get-canonicalmedianame
    (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'ctab))
    ))
    (setq aplotsize "")
    (if (= plotsize "User622")(setq aplotsize "A0P"))
    (if (= "A0" plotsize)(setq aplotsize "A0L"))
    (if (= plotsize "User622")(setq aplotsize "A0L"))
    (if (= plotsize "User271")(setq aplotsize "A1P"))
    (if (= "A1" plotsize)(setq aplotsize "A1L"))
    (if (= plotsize "User1645")(setq aplotsize "A1L"))
    (if (= plotsize "User270")(setq aplotsize "A2P"))
    (if (> (vl-string-search "A2_(420" plotsize) 1)(setq aplotsize "A2P"))
    (if (= "A2" plotsize)(setq aplotsize "A2L"))
    (if (= plotsize "User1644")(setq aplotsize "A2L"))
    ;;hope you get the idea here - this could be a long list to work out each paper
    ;;size for eat plotter we use
    (if (= plotsize "User269")(setq aplotsize "A3P"))
    (if (= plotsize "User1292")(setq aplotsize "A3L"))
    (if (= plotsize "User618")(setq aplotsize "A4P"))
    (if (= plotsize "User1291")(setq aplotsize "A4L"))
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;
    (defun c:modelorpaper()
    ;;This detects whether the view is Model or Paperspace.
    ;;If Modelspace it will ask if you want to continue with the plot
    ;;If you don't want to continue then it sets stopfunc to No
    ;;to cancel the plot later.
    ;;
    (cond
    ((= (getvar "TILEMODE") 1)
    (cond ((=
    (LMopup "Model space plotting" "Plot this model space display?" (+ 1 256)) 1)
    (setq stopfunc "Yes")
    )
    (T (setq stopfunc "No") )
    )
    )
    (T (setq stopfunc "Yes") )
    )
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;
    (defun cDFplot()
    ;;Function to plot to a PDF
    ;;
    ;;This first bit works out if the PDF is Model and Paperspace plot
    ;;It needs tidying up but it works and not really what I am asking
    ;;about.
    (setq orientation "Landscape") ;;there is more to this function to set orientation to Portrait
    (Setq PDFPLOTTER "DWG to PDF.pc3") ;;plotter name
    (setq directoryname (getvar "dwgprefix"))
    (setq filename (vl-filename-base (getvar 'dwgname)))
    (setq fullpath (strcat directoryname filename ""))
    ;;works out if plotting modelspace or aperspace plot
    (c:modelorpaper)
    ;;Condition statement if modelspace plotting - to be tidied up later, ignore this for now
    (cond
    ((= (getvar "TILEMODE") 1)
    (command "-plot" "Yes" "Model" PDFPLOTTER "" "" orientation "No" "Display" "Fit" "Center" "No"
    "" "Yes" "As Displayed" fullpath "No" "Yes")
    )
    ((> (getvar "CVPORT") 1)
    (command "_.pspace")
    (c:pdfplotting)
    )
    (T
    (c:pdfplotting)
    )
    )
    (princ))


    ;;The function to do the plotting that I am looking at changing about.
    ;;This is called from PDFPLOT above.
    ;;This but plots paperspace drawing
    (defun c:pdfplotting()
    (command "zoom" "all")
    ;;Change current paper size to expanded (0mm border) for standard paper sizes
    (setq papersize "")
    (setq aplotsize "")
    ;;calls function currentpapersize to get the current paper size as e.g.A0P
    ;;(For A0 Portrait plot)
    ;;Uses if statements to set the papersize to the equivalent print area with
    ;;a 0mm border.
    ;;This is the but I want to tidy up this week.
    ;;
    (c:currentpapersize)
    ;;Landscape layouts
    (if (= aplotsize "A0L")(setq papersize "ISO expand A0 (841.00 x 1189.00 MM)"))
    (if (= aplotsize "A1L")(setq papersize "ISO expand A1 (841.00 x 594.00 MM)"))
    (if (= aplotsize "A2L")(setq papersize "ISO expand A2 (594.00 x 420.00 MM)"))
    (if (= aplotsize "A3L")(setq papersize "ISO expand A3 (420.00 x 297.00 MM)"))
    (if (= aplotsize "A4L")(setq papersize "ISO expand A4 (297.00 x 210.00 MM)"))
    ;;Portrait layouts
    (if (= aplotsize "A0P")(setq papersize "ISO expand A0 (841.00 x 1189.00 MM)"))
    (if (= aplotsize "A1P")(setq papersize "ISO expand A1 (594.00 x 841.00 MM)"))
    (if (= aplotsize "A2P")(setq papersize "ISO expand A2 (420.00 x 594.00 MM)"))
    (if (= aplotsize "A3P")(setq papersize "ISO expand A3 (297.00 x 420.00 MM)"))
    (if (= aplotsize "A4P")(setq papersize "ISO expand A4 (210.00 x 297.00 MM)"))
    ;;how do I remove the need to use currentpapersize function and these if statements
    ;;in a better way
    (if (= papersize "")( (setq papersize (vla-get-canonicalmedianame
    (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'ctab))
    )) ))
    (command "-plot" "Yes" "" PDFPLOTTER papersize "" orientation "No" "" "Fit" "Center" "No" ""
    "Yes" "Yes" "No" "No" fullpath "No" "Yes")
    (princ))

Similar Threads

  1. Problem with printable area
    By myself in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 23rd Nov 2016, 06:56 pm
  2. Printable Area
    By donz67z in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 17th Jan 2013, 10:41 am
  3. Printable area for DWG to PDF?
    By byk3bep in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 17th Nov 2012, 01:00 pm
  4. about .pc3 and printable area
    By copernico84 in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 10th May 2007, 04:03 am
  5. Printable area x paper area
    By fabriciofontolan in forum AutoCAD General
    Replies: 1
    Last Post: 8th Aug 2003, 06:43 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts