Jump to content

Publishin and xref managment with lisp function


Recommended Posts

Posted

Im making some scripts to make as more work as possibile unnatended. I want to make a couple of lisps but i dont know how to break down such complex functions and its variables. The first one is for publishing. I want to publish all layouts in opened drawing with all the settings defined in lisp. The other is for xref mangment. First variation is to detach all xrefs in a drawing, and the other one is to detach only unloaded ones.

Thanks in advance.

Posted

I'm sure there's already some lisps like these. Doing google: http://www.theswamp.org/index.php?topic=4103.15 seems a way of detaching xrefs.

 

Regarding publish multiple DWGs & Layouts ... doesn't publish already do that? If you want to (for some reason) run such through lisp, I think it would be easier to plot from lisp instead of publish.

 

Then to have all these work on multiple drawings, look into using scripting. There's quite a few posts here (and elsewhere) about how to do such.

Posted

Then to have all these work on multiple drawings, look into using scripting. There's quite a few posts here (and elsewhere) about how to do such.

My idea was to call a lisp with a script in a batch of files. I know how to that, but the lisps are a bit of a problem.

Regarding publish multiple DWGs & Layouts ... doesn't publish already do that? If you want to (for some reason) run such through lisp, I think it would be easier to plot from lisp instead of publish.

I want to publish same drawings with a 3D model in it. When i put 15 or 20 DWGs for publishing im not sure if the publishing will ever finish. My idea was to use a script to open, detach unnecessary xrefs, audit, purge, save and while im at it publish. Basicaly one file at the time which is ok for me.

Posted

Well, publish does have a command line version -PUBLISH, but then you need to have a DSD file as saved from the publish dialog. I think the most difficult part of that would be to modify such file so it works on another DWG & layout set. Not to mention, you'll need to figure out what to change if your page sizes vary.

 

BTW, you can turn off background publishing in the Options dialog (Plot and Publish tab, Background processing options - about halfway down the left). This should allow you to "see" how far publish has gotten through its list of DWGs and tabs. It also works a lot more like when you do a script, i.e. opening each DWG in turn then performing the "plot" on it.

 

About the 3d model, are you referring to export to 3d DWF(x)? Even though the -EXPORT command uses command line switches I'm unsure if it can save as a 3D model when doing this

Posted

To address an issue our office was having publishing to a PDF with AutoCAD 2009 I wrote a lisp that creates a DSD file then publishes it to the specified output device. You will have to modify it to suit your own needs of course.

 

(defun c:dsd (/ dpath dname fname dir oldFileDia oldBGP xtime nLAY PDFlist nPDF
 sbat sstr pname bpath batch pdf rotpdf PDFpath PDFcount copyPDF
 copyPDFcount)
 ;; Set variables
 (setvar "cmdecho" 0)
 (setq oldFileDia (getvar "filedia"))
 (setq oldBGP (getvar "backgroundplot"))
 (setvar "filedia" 0)
 (setvar "backgroundplot" 0)
 (setq dpath (getvar "dwgprefix"))
 (setq dname (getvar "dwgname"))
 (setq dir "c:/Windows/Temp/CSC/")
 (setq bname (vl-filename-base dname))

 ;; Import PDF Page Setup
 ;; Author: Wizman
 ;; url: [url]http://www.cadtutor.net/forum/showthread.php?31502-Lisp-to-import-page-setup&p=204633&viewfull=1#post204633[/url]
 (defun psetupexist-p  (psetup / pc psetupflag)
   (vl-load-com)
   (vlax-for
            pc
              (vla-get-plotconfigurations
                (vla-get-ActiveDocument (vlax-get-acad-object)))
     (if (= (strcase (vla-get-name pc)) (strcase psetup))
       (setq psetupflag T))
     )
   psetupflag
   )
 (if (= (psetupexist-p "PDF") T)
   (command "._-PSETUPIN" "msc_elec.dwt" "PDF" "Y")
   (command "._-PSETUPIN" "msc_elec.dwt" "PDF")
 )

 ;; Build DSD file
 (setq fname (open "c:/Windows/Temp/CSC/temp.dsd" "w"))
 (write-line "[DWF6Version]" fname)
 (write-line "Ver=1" fname)
 (write-line "[DWF6MinorVersion]" fname)
 (write-line "MinorVer=1" fname)
 (foreach lay (layoutlist)
   (setvar "CTAB" lay)
   (setq lname (getvar "ctab"))
   (setq temp1 (strcat "[DWF6Sheet:" bname "-" lname "]"))
   (setq temp2 (strcat "DWG=" dpath dname))
   (setq temp3 (strcat "Layout=" lname))
   (setq temp4 (strcat "OriginalSheetPath=" dpath dname))
   (write-line temp1 fname)
   (write-line temp2 fname)
   (write-line temp3 fname)
   (write-line "Setup=PDF" fname)
   (write-line temp4 fname)
   (write-line "Has Plot Port=0" fname)
   (write-line "Has3DDWF=0" fname)
 )
 (write-line "[Target]" fname)
 (write-line "Type=2" fname)
 (write-line "DWF=C:/Windows/Temp/CSC/Drawing2.dwf" fname)
 (write-line "OUT=C:/Windows/Temp/CSC" fname)
 (write-line "PWD=" fname)
 (write-line "[AutoCAD Block Data]" fname)
 (write-line "IncludeBlockInfo=0" fname)
 (write-line "BlockTmplFilePath=" fname)
 (write-line "[sheetSet Properties]" fname)
 (write-line "IsSheetSet=FALSE" fname)
 (write-line "IsHomogeneous=FALSE" fname)
 (write-line "SheetSet Name=" fname)
 (write-line "NoOfCopies=1" fname)
 (write-line "PlotStampOn=FALSE" fname)
 (write-line "JobID=0" fname)
 (write-line "SelectionSetName=" fname)
 (write-line "AcadProfile=<<Unnamed Profile>>" fname)
 (write-line "CategoryName=" fname)
 (write-line "LogFilePath=" fname)
 (write-line "IncludeLayer=FALSE" fname)
 (write-line "PromptForDwfName=TRUE" fname)
 (write-line "PwdProtectPublishedDWF=FALSE" fname)
 (write-line "PromptForPwd=FALSE" fname)
 (write-line "RepublishingMarkups=FALSE" fname)
 (write-line "PublishSheetSetMetadata=FALSE" fname)
 (write-line "PublishSheetMetadata=FALSE" fname)
 (write-line "3DDWFOptions=0 0" fname)
 (close fname)

 ;; Publish PDFs using temp.dsd file just created
 (command "-PUBLISH" "c:/Windows/Temp/CSC/temp.dsd")

 ;; Reset variables
 (setvar "filedia" oldFileDia)
 (setvar "backgroundplot" oldBGP)
 (setvar "ctab" (car (layoutlist)))
 (setvar "cmdecho" 1)
 (princ)
)

Posted

To address an issue our office was having publishing to a PDF with AutoCAD 2009 I wrote a lisp that creates a DSD file then publishes it to the specified output device. You will have to modify it to suit your own needs of course.

I tried it out and it reports an error. Why is this runiing through dwf? Do i need to make a drawing2.dwf or the lisp makes it?

Thank you anyway!

Posted

It doesn't really do anything with the DWF, I think it just has to be included in the DSD file. What I did was publish a drawing then went and looked at how the DSD file was constructed and the DWF section was included even though I had checked "Plotter named in Page Setup" for what to publish to.

 

What error are you getting?

Posted

What error are you getting?

I mannaged to make it work. Interesting lisp. Thanks a lot. Im now having a problem with a script that is using this lisp because it gets interupted. But thats another story. Again, thanks a lot.

  • 1 year later...
Posted (edited)

Hi,

Thanks for the script , lfe011969

 

Stupid question, I try to use it with PUBLISHCOLLATE to 1 and it doesn't work. I have a lot of files and I would like to have juste one file with severales pages.

 

No idea why?

 

If you have any suggestion.

 

Aze

Edited by totolisp
Posted

Q1 theres lots of examples here for lisp plotting I know I have PDF TIFF LASER & Plotter. Plots all layouts automatically do a search for "plot" it will be a long list but there are working examples of the required code. For others yeah could use publish but just click on menu button. Code is about 1/2 of above

 

heres on to start http://www.cadtutor.net/forum/showthread.php?21460-Plot-PDF-layout-name&highlight=plot+pdf

 

Q2 thanks guys for a different problem solution above

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