Author Topic: Change plotter name in page setups  (Read 2016 times)

0 Members and 1 Guest are viewing this topic.

Dave M

  • Newt
  • Posts: 196
Change plotter name in page setups
« on: April 26, 2012, 01:06:43 PM »
We recently renamed the server where our plotters reside.  Is it possible with AutoLISP to create a find and replace so that the plotter name could be updated without manually modifying each page setup?

Thanks,

Dave
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Change plotter name in page setups
« Reply #1 on: April 26, 2012, 01:26:59 PM »
Not tested, but something like this should work:

Code: [Select]
(defun foo (name)
  (vlax-map-collection
    (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
    '(lambda (x) (vla-put-configname x name))
  )
)
(foo "xxx.pc3")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Change plotter name in page setups
« Reply #2 on: April 26, 2012, 02:19:51 PM »
Here's a better solution  8-). As long as your printer names are the same as before, this should update the paths accordingly. I tested it very little...
Code: [Select]
(defun c:fixprinterserverlocation (/ _stripath _getnetworkprinters name printers)
  (defun _stripath (path / n )
    (if (setq n (vl-string-position (ascii "\\") path 0 t))
      (strcase (substr path (+ 2 n)))
      path
    )
  )
  (defun _getnetworkprinters (/ i name out p ws)
    (if (and (setq ws (vlax-get-or-create-object "WScript.Network"))
     (setq p (vlax-invoke ws 'enumprinterconnections))
     (setq i (vlax-invoke p 'count))
)
      (repeat i
(if (wcmatch (setq name (vla-item p (setq i (1- i)))) "\\\\*")
  (setq out (cons (cons (_stripath name) name) out))
)
      )
    )
    out
  )
  (_getnetworkprinters)
  (if (setq printers (_getnetworkprinters))
    (vlax-for x (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
      (if (setq name (cdr (assoc (_stripath (vla-get-configname x)) printers)))
(vla-put-configname x name)
      )
    )
  )
  (princ)
)
(c:fixprinterserverlocation)

*Updated code above ... some typos and localized variables  :oops:
« Last Edit: April 30, 2012, 09:15:11 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Dave M

  • Newt
  • Posts: 196
Re: Change plotter name in page setups
« Reply #3 on: April 26, 2012, 04:14:34 PM »
Thanks ronjop,

I will give it a try as soon as I get a chance

Dave
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

alloy mold design

  • Mosquito
  • Posts: 8
  • Automotive wheel mold design
Re: Change plotter name in page setups
« Reply #4 on: April 28, 2012, 10:08:33 AM »
it is wanderful!
m Foshan City, Guangdong Province, China, car wheels mold design

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Change plotter name in page setups
« Reply #5 on: April 30, 2012, 09:09:12 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC