Jump to content

Recommended Posts

Posted (edited)

Hey everyone, I am new to this whole forum thing, so I apologize if I should be starting a new thread but I do have a question related to this that I was hoping you could help with.

 

 

I have been trying to automate my plotting process using MColor 9 which is a extension to CAD for color renderings. The issue is I am trying to plot multiple tabs at once, or back to back automatically. The command for plotting with Mcolor is "MCO_PLOT", but it will only do one tab at a time. I have created a LISP that has gotten me really close to where I want to be, which is:

 

(defun C:mco-plot ()
 (foreach lay (layoutlist)
   (setvar 'ctab lay)
   (command "_mco_plot")
 ); end foreach
); end defun

 

 

 

*I changed the new command from "mco_plot" to "mco-plot" so it did not conflict.

 

 

This LISP will automatically plot each tab back to back, but the hang up is that on each tab it asks me where I want to save the PDF. What I really need is something to add to this LISP function that will either have the PDF automatically save to the current drawings folder, or just have me specify the location once and save the PDF's for all the tabs in that location. I know this is unique because not everyone has MColor 9, I hadn't even heard of it before until my current job. However, I think there must be a solution out there since the only part I need now is a way to specify the saving location one time (one time per project) and then I would be good to go.

 

 

Thank you for your time!

Edited by rkmcswain
added [CODE] tags
  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • BIGAL

    9

  • GreenLA

    5

  • masterfal

    4

  • Roy_043

    2

Posted

If MCO-PLOT is say compiled as a FAS or a .net then you probably can not change it. Some software has extensions to do what you want when running the command. Trying to find info on Mcolor 9 ?

Posted

BIGAL,

 

 

I am not sure if MCO-PLOT is compiled as a FAS or a .net. I'm not really even sure it is truly an extension or not, it was already loaded on my computer at work and they have been using it for several years. It might be a separate program that is linked to CAD, but I am not sure. The code that I posted does already work though as far as repeating the MCO-PLOT command for each tab, but it is prompting me to select a location to save the pdf for each tab(for example, if I run the command, it asks to save the first tab, then it plots it to PDF and then it asks to save the next tab and so on. Even if I hit cancel it still cycles through all the tabs with a saving location prompt). The saving part is what I am trying to automate... I have reached out to the Mcolor support staff and they did say that they could do batch plotting, but I couldn't get it to work and it seemed just as tedious as plotting individually.

Posted

When you run the MCO-plot does it ask the questions at the command line or does it use a Dialouge box. If its command line then you should be able to supply filename etc

 

Search your pc for MCO* and look at file type is it lsp fas dvb exe dll arx etc

Posted

BIGAL,

 

 

I created the MCO-PLOT lisp command, so it is a lsp file. I searched the computer like you said and that was the only thing that came up. Mcolor seems to be an exe file type. When I run the MCO-PLOT, I type the command and then it comes up with a dialogue box that asks where I would like to save the file. It does that for each tab automatically because of the way I set the lisp function up, but I would like it to save automatically too without prompting me on each tab.

Posted

Need you to post lisp, you added more info but did not supply a hint you say a dialouge comes up is that part of your lisp ?

 

A lot of software can be command line driven with extra settings, no extra info then dialouge box appears

 

Here is an example using lisp to write the command line with switches

;by Roy_043
(startapp (strcat gsExe " " "-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET  ""-sOutputFile=\"" trgFile "\" ""\"" (KGA_String_Join srcFileLst "\" \"") "\"" ))

Posted

Sorry, I'm confused. I posted the lisp in the first post. The dialogue box is not part of it.

Posted

This may work.

(defun C:mco-plot ()
 (if (= 1 (getvar 'dwgtitled))
   (foreach lay (layoutlist)
     (setvar 'ctab lay)
     (command "_mco_plot" (strcat (getvar 'dwgprefix) lay ".pdf"))
   )
 )
 (princ)
)

Posted

sorry to veer a little from the discussion, but i'm still searching for a way to set the default save location for published pdfs to be same location as the dwg.

needing to locate this folder every single time is such a waste of time...

if anyone can advise how this can be done it would be much appreciated

Posted

Once I thought this is a registry entry that needs to follo dwgprefix. But I didn't manage to get it to work.also looking for a solid solution..

Posted

i think i'm heading in right direction. but,

when i load it it asks me for start and end tab numbers.

after specifying that, it doesn't seem to function properly..

what am i doing wrong?

 

plotA3Pdfrange.lsp successfully loaded.

nil

Command: Regenerating model.

Regenerating layout.

Regenerating model.

Yes or No, please.

Function cancelledWrite the plot to a file [Yes/No] :

Posted (edited)

If you look carefully at the plotpdfrange it is hardcoded to put the pdfs' into a directory called pdf that exists below the dwg directory "design" this was a request from my co-workers. Its probably working but can not find this directory. The original verison put it in same location. Version 2 of this uses Ghost script and joins the created pdf's into one. Post if you want it.

 

\projects\1234\design\pdf

 

(setq pdfname (strcat (getvar "dwgprefix") "pdf\\" dwgname "-" (getvar "ctab"))) ; sub directory pdf

(setq pdfname (strcat (getvar "dwgprefix")  dwgname "-" (getvar "ctab"))) ; no pdf directory saved same as dwg

Edited by BIGAL
Posted

ok, so after a bit of testing i could not get the plotpdfrange lsp file to run properly.. i did manage to find an alternative that seems to work. It saves all the pdfs to the same location as dwg, but as individual sheets :(

BIGAL you mentioned theres a way to get these combined also?

 

;; Prints All Layout Tabs and names the new PDFs with the name of the
;; drawing followed by the layout tab name.
;;
;; Adjust the paper size and .ctb file as needed.
;;
;; The PDFs will be placed in the folder where the drawing resides
;;
(defun c:PA ()
(foreach lay (layoutlist)
 (setvar 'CTab lay)
 (COMMAND 	"-PLOT"
	"Y"
	""
	"DWG To PDF.pc3"
	"ANSI full bleed A (8.50 x 11.00 Inches)"
	"Inches"
	"PORTRAIT"
	"N"
	"E"
	"f"
	"C"
	"Y"
	"monochrome.ctb"
	"Y"
	"N"
	"N"
	"N"
	""; Name of file
	"N"
	"y"      )
   )
)

Posted

The only thing that should stop plotpdfrange from working is the pdf directory below the drawing location, change the code using the 2nd line in my previous post. And you will need the correct parameters size sheet etc. Like the code masterfal you posted there is lots of examples with very slight tweaks.

 

This is a merge pdf's lisp that uses ghostscript you need to down load seperately.

 

The version of plotpdf's does individuals and a single merged in one step.

 

Post edited above.

 

;MergePdfs
;Merges multiple pdf (or eps) files into one
;

; make a batch file ?
;gs -sDEVICE=pdfwrite \
;    -dNOPAUSE -dBATCH -dSAFER \
;    -sOutputFile=combined.pdf \
;    first.pdf \
;    second.pdf \
;    third.pdf [...]

;Ghostscript (http://www.ghostscript.com/) can be used to combine PDFs.

; Something like this should work: by Roy_043

(defun KGA_String_Join (strLst delim)
(if strLst
(apply
'strcat
(cons
(car strLst)
(mapcar '(lambda (a) (strcat delim a)) (cdr strLst))
)
)
""
)
)

; (CombinePdf 
 (setq gsexe "C:\\Program Files\\gs\\gs9.19\\bin\\gswin64c.exe")
; (setq srcFilelst  '("D:\\Tmp\\A.pdf" "D:\\Tmp\\B.pdf"))
; (setq trgfile "C:\\Acadtemp\\Total.pdf")
; )
; Note: Existing trgFile will be overwritten.
(defun CombinePdf (gsExe srcFileLst trgFile)
(startapp 
(strcat
gsExe " "
"-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET  "
"-sOutputFile=\"" trgFile "\" "
"\"" (KGA_String_Join srcFileLst "\" \"") "\""
)
)
)

 

plotA3Pdfrange2.lsp

Posted

yeh thats pretty much what i've done but still doesn't run properly.. i've amended so uses my plotter name/style. not sure what else i'm doing wrong?

 

;Plots layouts by range
; By Alan H Feb 2014
(defun AH:pltlays ( / lay numlay numend)
(SETVAR "PDMODE" 0)

(setvar "fillmode" 1)
(setvar "textfill" 1)

(if (not AH:getval2) (load "getvals"))
(ah:getval2 "Enter start tab number" 6 4 "Enter end tab number" 6 4)
(setq numlay (ATOI val1))
(setq numend (ATOI val2))

(setq len (+ (- numend numlay) 1))

(setq dwgname (GETVAR "dwgname"))
(setq lendwg (strlen dwgname))
(setq dwgname (substr dwgname 1 (- lendwg 4)))

(repeat len
(vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
(if (= numlay (vla-get-taborder lay))
 (setvar "ctab" (vla-get-name lay))
) ; if
(setq pdfname (strcat (getvar "dwgprefix")  dwgname "-" (getvar "ctab"))) ; no pdf directory saved same as dwg

) ; for
(setq lay nil)
(setvar "textfill" 1)
(setvar "fillmode" 1)
   (COMMAND "-PLOT"  "Y"  "" "adobe pdf"
       "A3" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
       "y" "EP Full Mono - NEW.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
   )
   
(setq numlay (+ numlay 1))
) ; end repeat
) ; defun

(AH:pltlays)

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