Results 1 to 9 of 9

Thread: Help with plot-to-file lisp please.

  1. #1
    Member
    Join Date
    2012-07
    Posts
    5

    Default Help with plot-to-file lisp please.

    Hi. I am trying to construct a lisp routine for printing .DWG to .tif files.
    With my current code I manage to print out a .tif file to the dwg directory.
    My problem is that the lines are printed i in gray shades. I need it to be black and white.
    I want it to use monochrome.ctb but i don know how to implement it to my routine.

    Code:
     (defun f:printtotif(/ acadObject objDoc objPlot sFile sDwgPlotter err) (vl-load-com)
     (setq acadObject (vlax-get-acad-object))
     (Setq objDoc (vla-get-activedocument acadobject))
     (Setq objPlot (vla-get-plot objDoc))
     (Setq sFile (Substr (vla-get-fullname objdoc) 1 (- (Strlen (vla-get-fullname objdoc)) 4)) )
     (Setq sFile (strcat sfile ".tif") )
     (Setq sDwgPlotter "Microsoft Office Document Image Writer.pc3")
     (Setq err (vla-plottofile objPlot sFile sDwgPlotter))
    )
    
    (f:printtotif)
    If somone could help me I would be very grateful!

    /Samuel
    Last edited by bjornkvist_88615495; 2012-07-26 at 11:54 AM.

  2. #2
    Active Member
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    83

    Default Re: Help with plot-to-file lisp please.

    You would need to assign monochrome.ctb as the plot style table for the layout which is being printed. Before calling vla-plottofile;

    1) Obtain a reference to the active layout...
    Code:
    (setq objLayout (vla-get-activelayout objDoc))
    2) Assign monochrome.ctb to it...
    Code:
    (vl-catch-all-apply 'vla-put-stylesheet (list objLayout "monochrome.ctb"))
    ...Then proceed with plotting.
    Note that the above assumes the drawing is set for colour-based plotting, rather than style-based (otherwise, you would be using monochrome.stb). Also, you would probably want to include the above in an undo group, and have a call to the Undo command at the end of your function, so that the original plot style would be restored.

  3. #3
    Member
    Join Date
    2012-07
    Posts
    5

    Default Re: Help with plot-to-file lisp please.

    Hi. Thank you very much! It did the trick.

    Is there a similar way to get it to print in landscape?

    Thanks for the help.

  4. #4
    Active Member
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    83

    Default Re: Help with plot-to-file lisp please.

    Quote Originally Posted by bjornkvist_88615495 View Post

    Is there a similar way to get it to print in landscape?
    I believe that would come down to the "Plotrotation" property of the layout object, so that...

    Code:
    (vla-put-plotrotation objLayout ac90degrees)
    ...should set it to landscape.

    Per the help documentation, the constants relating to this property are:
    ac0degrees
    ac90degrees
    ac180degrees
    ac270degrees

    Also, per the help docs, a regen of the document is required for a change to this property to take effect.

  5. #5
    Member
    Join Date
    2012-07
    Posts
    5

    Default Re: Help with plot-to-file lisp please.

    Should i put it together like this?
    I am quite new to this programinglanguage, so thanks again!

    (defun f:printtotif(/ acadObject objDoc objPlot sFile sDwgPlotter err) (vl-load-com)
    (setq acadObject (vlax-get-acad-object))
    (Setq objDoc (vla-get-activedocument acadobject))
    (Setq objPlot (vla-get-plot objDoc))
    (Setq sFile (Substr (vla-get-fullname objdoc) 1 (- (Strlen (vla-get-fullname objdoc)) 4)) )
    (Setq sFile (strcat sfile ".tif") )


    (setq objLayout (vla-get-activelayout objDoc))
    (vl-catch-all-apply 'vla-put-stylesheet (list objLayout "monochrome.ctb"))
    (vla-put-plotrotation objLayout ac90degrees)

    (Setq sDwgPlotter "Microsoft Office Document Image Writer.pc3")
    (Setq err (vla-plottofile objPlot sFile sDwgPlotter))
    )

    (command "regen")


    (f:printtotif)

  6. #6
    Active Member
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    83

    Default Re: Help with plot-to-file lisp please.

    Based on what is noted in the help file, I would suggest calling the "regen" command after assigning the rotation value, and before actually calling plottofile.

    Note that there are many possible ways that your drawings might be set up, so I cannot be sure that the rotation property alone will produce satisfactory results. Having your plots set to "Fit The Paper" and "Center The Plot", for instance, may simplify things when changing the default orientation.

  7. #7
    Member
    Join Date
    2012-07
    Posts
    5

    Default Re: Help with plot-to-file lisp please.

    I implemented the blue code and it still won't rotate to "landscape". I am clearly doing something wrong..?
    Help please.

    Thanks
    /Samuel

    Code:
    (defun f:printtotif(/ acadObject objDoc objPlot sFile sDwgPlotter objLayout err)
    
    	(vl-load-com)
    	(setq acadObject (vlax-get-acad-object))
    	(Setq objDoc (vla-get-activedocument acadobject))
    	(Setq objPlot (vla-get-plot objDoc))
    
    	(Setq sFile (Substr (vla-get-fullname objdoc) 1 (- (Strlen (vla-get-fullname objdoc)) 4)) )
      	(Setq sFile (strcat sfile ".tif") )
    	
    	(Setq sDwgPlotter "Microsoft Office Document Image Writer.pc3")
    	
    	(setq objLayout (vla-get-activelayout objDoc))
    	(vl-catch-all-apply 'vla-put-stylesheet (list objLayout "monochrome.ctb"))
    	(vlax-put-property objLayout 'Plotrotation ac90degrees)
    	(vlax-put-property objLayout 'PlotType acExtents)
    	(vlax-put-property objLayout 'CenterPlot :vlax-true)
    	(vlax-put-property objLayout 'StandardScale acVpScaleToFit)
    	(command "regen")
    	
      	(Setq err (vla-plottofile objPlot sFile sDwgPlotter))
    )
    
    
    (f:printtotif)
    Last edited by bjornkvist_88615495; 2012-07-27 at 09:10 AM.

  8. #8
    Active Member
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    83

    Default Re: Help with plot-to-file lisp please.

    I am unable to test this code exactly as-is, since I don't have "Microsoft Office Document Image Writer.pc3", but I substituted "PublishToWeb PNG.pc3" and it worked as expected for me.

  9. #9
    Member
    Join Date
    2012-07
    Posts
    5

    Default Re: Help with plot-to-file lisp please.

    Hi again.

    Now I'm able to rotate the plot to landscape. Though one prolem appears.
    The center command doesen't work. Is there anything wrong with it?


    Code:
    	(vlax-put-property objLayout 'PlotType acExtents)
    	(vlax-put-property objLayout 'CenterPlot :vlax-true)	
    	(vlax-put-property objLayout 'StandardScale acVpScaleToFit)
    Thanks!
    Samuel

Similar Threads

  1. PDF plot w/lisp and script
    By jeff.smith in forum AutoCAD Plotting
    Replies: 2
    Last Post: 2008-12-18, 06:34 AM
  2. PDF plot w/lisp and script
    By jeff.smith in forum AutoCAD General
    Replies: 4
    Last Post: 2008-04-12, 06:54 AM
  3. Replies: 0
    Last Post: 2007-04-30, 05:05 PM
  4. Plot to File- Standard file navigation dialog box
    By mcharper in forum AutoCAD Plotting
    Replies: 7
    Last Post: 2006-05-10, 01:07 AM
  5. Plot / Plot to file freezes
    By billjones in forum AutoCAD Plotting
    Replies: 5
    Last Post: 2004-10-11, 03:12 PM

Posting Permissions

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