vl-plotting?

Discussion in 'AutoCAD' started by mattis, Sep 14, 2004.

  1. mattis

    mattis Guest

    I have about 31,000 drawings that I want to convert to DWF. I have this list of file names in a text file. I can get each drawing to open up in read-only, and almost get it all to work (at least I think). When I go to run this, the drawing that opens gets activated, but the lisp halts until I switch back to the drawing I ran the lisp in. And when I do that, the main drawing is what prints, not the one that was opened. Can anyone point me in right direction?

    Here's my code so far:
    (defun c:dwfs (/ acadapp acaddocs inputfile eof line acaddoc base folder plotcfgs space plot)
    (vl-load-com)
    (setq acadapp (vlax-get-acad-object))
    (setq acaddocs (vla-get-documents acadapp))
    (setq inputfile (open "c:\\dwf.txt" "r"))
    (setq eof 1)
    (while (= eof 1)
    (setq line (read-line inputfile))
    (if line
    (progn
    (setq acaddoc (vla-open acaddocs line :vlax-true))
    (setq base (vl-filename-base (vla-get-name acaddoc)))
    (setq folder (substr (vl-filename-directory line) 4))
    (setq plotcfgs (vla-get-plotconfigurations acaddoc))
    (setq space (vla-get-activespace acaddoc))
    (if (= space 0)
    (setq plotcfg (vlax-invoke-method plotcfgs 'add "newcfg" :vlax-false))
    (setq plotcfg (vlax-invoke-method plotcfgs 'add "newcfg" :vlax-true))
    )
    (vlax-put-property plotcfg 'PlotType acExtents)
    (vlax-put-property plotcfg 'CenterPlot :vlax-true)
    (vlax-put-property plotcfg 'StandardScale acVpScaleToFit)
    (vlax-put-property plotcfg 'CanonicalMediaName "Letter")
    (setq plot (vla-get-plot acaddoc))
    (vlax-invoke plot 'setlayoutstoplot (list (vla-get-name (vla-get-activelayout acaddoc))))
    (vla-plottofile (vla-get-plot acaddoc) (strcat "w:\\wizard\\dwf\\" folder "\\" base ".dwf") "DWF6 ePlot.pc3")
    (vla-close acaddoc :vlax-false line)
    )
    (setq eof nil)
    )
    )
    (close inputfile)
    (princ)
    )
     
    mattis, Sep 14, 2004
    #1
  2. mattis

    Jeff Mishler Guest

    Either create a script to run or translate your code to VBA. Lisp can only
    run in the document it was called from, where VBA can be run across multiple
    documents.
     
    Jeff Mishler, Sep 14, 2004
    #2
  3. mattis

    Jeff Mishler Guest

    Drat!.....Hit the send button too soon.
    One other option would be to make sure you are in SDI=0 and use the ADD
    method on the Documents collection in place of OPEN. This will allow you to
    work with the drawing in the background (which is essentially what you are
    doing anyway).
     
    Jeff Mishler, Sep 14, 2004
    #3
  4. I once accomplished by creating a special acaddoc.lsp file with the
    instructions to -
    print the file
    open a number file (read mode) in txt format
    read the number "N" (first time number = 0)
    close number file
    add 1 to the number "N"
    open number (write mode)
    write new number to the number file
    close number file
    open list file (read format) in txt format - containing list of files to
    process
    perform "N" read-line's based on number from number file and save "file
    name"
    if "file name"
    open "file name" (save or not as required)
    else
    quit autocad
    endif

    Once the process is finished - rename acaddoc.lsp file
     
    Alan Henderson @ A'cad Solutions, Sep 14, 2004
    #4
  5. mattis

    John Schmidt Guest

    If you're open to a 3rd party routine, (I do exactly what you're doing,
    generate hundreds of .dwf files automatically), take a look at AutoM8 from
    www.m8tools.com . I'm not sure you could feed it a text list of the
    drawings, but it does allow you to select any/all drawings in any folders
    and automatically generate the .dwf files, (or do any other operation). You
    can also run pre-plot commands on everything - I have it do a zoom extents
    for every .dwf.

    John

    list of file names in a text file. I can get each drawing to open up in
    read-only, and almost get it all to work (at least I think). When I go to
    run this, the drawing that opens gets activated, but the lisp halts until I
    switch back to the drawing I ran the lisp in. And when I do that, the main
    drawing is what prints, not the one that was opened. Can anyone point me in
    right direction?
    (vla-get-activelayout acaddoc))))
    "\\" base ".dwf") "DWF6 ePlot.pc3")
     
    John Schmidt, Sep 15, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.