Jump to content

Changing Printers Names for multiple layouts


flexifloat

Recommended Posts

I have searched wide a long and have not found what I am looking for and I know you guys have the simple answer. We have changed our printer naming convention and I(we) need to update about 10,000 drawings. We have 4 default printer names and need to step through each layout and replace the old printer name with the new one.

I wasn’t to create a lsp routing that we can add/run at startup and just update all of the layouts as needed model included.

Eventually we will incorporate this into a script and parse all of the files in a directory an let them run.

For now we will settle for the manual process as we open existing drawings

Thanks for your help

Link to comment
Share on other sites

you could create a drawing with all your new printers set up as diferrent page set ups and then import those through the publish command, once you get all the drawings loaded into the publish dialog box hit the little arrow next to the default page set up under pagesetup/3d dwf and select import, then select your drawing that has all your new page set ups, it will load them all and then you just need to select the appropriate setup, if you have all the drawings selected it will apply that page setup to all the drawings that you are publishing, unfortunately it won't change the drawings default pagesetup for you though.

Link to comment
Share on other sites

Thanks for the help - I am not familar with the publish prcess, we do not use that here. I have started the lsp routine and this is where I am now.

 

I am new so here we go

 

 
(defun UpdatePlotDevice_AllLayouts (DvcNme)
; Created by C McMurtry & K Garcia
; 7/2011
(GETPLOTDEVICES) ;List layout and plot devices before update
(foreach lay (layoutlist) : Loop through Layout List
(setvar "CTAB" lay)
(command "psltscale" "0") ;Set PTSCALE REI Std
( If (= “Canon_PCL” DeviceName) ; Update Plotter Names
(Set Device Name = “Engineering Printer”))
( If (= “Xerox 8825” DeviceName)
(Set Device Name = “Engineering Wide Format Printer”))
( If (= “HP Laserjet 6P” “Local Printer”)
(Set Device Name = “Engineering Printer”))
( If (= “Canon_PCL” DeviceName)
(Set Device Name = “Engineering Printer”))
) ; End of Loop
(GETPLOTDEVICES) ;List layout and plot devices after update

(defun GetPlotDevices (/ dvc)
(vl-load-com)
;; Lee Mac ~ 26.02.10
(vlax-map-collection
(vla-get-layouts
(vla-get-ActiveDocument
(vlax-get-acad-object)))
(function
(lambda (layout)
(vla-RefreshPlotDeviceInfo layout)
(setq dvc
(cons
(cons
(vla-get-name layout)
(vla-get-ConfigName layout)) dvc)))))
(reverse dvc))

Link to comment
Share on other sites

Hi Flexifloat,

 

Give this a try:

 

(defun c:test ( / device )
 (vlax-for layout (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
   (vla-refreshplotdeviceinfo layout)
   (cond
     ( (member (setq device (strcase (vla-get-configname layout))) '("CANON_PCL" "HP LASERJET 6P"))
       (vla-put-configname layout "Engineering Printer")
     )
     ( (eq "XEROX 8825" device)
       (vla-put-configname layout "Engineering Wide Format Printer")
     )
   )
 )
 (princ)
)
(vl-load-com) (princ)

It assumes that the new device names are valid - if necessary you can get a list of available device names for a layout using the getplotdevicenames method.

 

I notice the symbols “ [ASCII 147] and ” [ASCII 148] appear in your code. These are not valid string tokens, and should be replaced with " (ASCII 34). I would strongly suggest you use the Visual LISP IDE provided with AutoCAD to write your code (or another code editor such as Notepad++) if you are not already doing so, since such editors will provide syntax highlighting, allowing you to easily spot the use of invalid characters as noted above.

 

Also, the Visual LISP IDE provides excellent debugging capabilities for LISP, and direct access to the Help Documentation. I have written a couple of short tutorials to get a beginner started, these can be found here.

 

I hope this helps,

 

Lee

Link to comment
Share on other sites

Thanks to all for your help.

 

I have modified/customized the code snipet from Lee Mac - it was a great help just as I expected.

 

Our next step will be to force this to run against a group of drawings in a directory - but that is a task for another day.

 

We have added this function to autoload when we open each drawing and run the GetPlotDevices to verify whether the drawing has been updated, if not then a simple UpdPlotStds will bring us to our current plotter/set standards.

 

Here is what we see at a drawing start up:

 

Loading Plot Update Routine UpdPlotStds.lsp . . .

UpdPlotStds Loaded

 

Application will load 2 modules

*** UpdPlotStds *** used to update plotter names and psltscale

*** GetPlotDevices *** used to list plotter names with layout tabs

 

(("Layout1" . "HP LaserJet 6P") ("Model" . "HP LaserJet 6P"))

Command: COMMANDLINE

Command:

Command:

 

 

 

I have also attached the modified script here wtih many thanks to all for your advice and help.

 

 

 
;*******************
;   Accaddoc.lsp   
;   Created 7/18/11   
;   Clark McMurtry & Krys Garcia 
;   Robishaw Engineering, inc.
;   Lee Mac ~ 7/16/11 Base Code Snipet 
;   
;   7/18/11 CAM - added UpdPlotStds to autoload with Accaddoc.lsp
;  
; *******************

(vl-load-com)
(princ)
(Princ "\n UpdPlotStds Loaded")
(Princ "\n")

(defun c:UpdPlotStds ( / device )
    ;; Lee Mac  ~  7/16/11 code base
    ;; C McMurtry/K Garcia 7/18/11  touch-up 
 (Princ "\nStarting Routine")
 (Princ "   List plotters assignments before update   ******************")
 (Princ "\n")

 (Print (c:GETPLOTDEVICES))

 (Princ "\n")
 (Princ "\n   Starting update \n")
 (vlax-for layout (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
   (vla-refreshplotdeviceinfo layout)
   (print (strcase (vla-get-name layout)))
   (setq device (strcase (vla-get-configname layout)))
   (cond

;;;      ( (member (setq device (strcase (vla-get-configname layout))) '("CANON_PCL" "HP LASERJET 6P"))
;;;        (vla-put-configname layout "Engineering Printer")
;;;      )
     ( (eq "HP 4ML" device)
        (vla-put-configname layout "Local Printer")
        (princ " - Updated 'HP 4ML' to 'Local Printer'   " )
        )

     ( (eq "HP LASERJET 6P" device)
       (vla-put-configname layout "Local Printer")
       (princ " - Updated 'HP Laserjet 6P' to 'Local Printer'   " )
       )

     ( (eq "HP LASERJET P3005 PCL 6" device)
       (vla-put-configname layout "Local Printer")
       (princ " - Updated 'HP Laserjet 6P' to 'Local Printer'   " )
       )

     ( (eq "HP 4MV" device)
       (vla-put-configname layout "Shop Office Printer")
       (princ " - Updated 'HP 4MV' to 'Shop Office Printer'    " )
       )

     ( (eq "HP BUSINESS INKJET 3000 PCL 6" device)
       (vla-put-configname layout "Main Color Printer")
       (princ " - Updated 'HP Business Inkjet 3000 PCL6' to 'Main Color Printer' " )
       )

     ( (eq "CANON_PCL" device)
       (vla-put-configname layout "Main Copier")
       (princ " - Updated 'Canon_PCL' to 'Main Copier'    " )
       )

     ( (eq "XEROX 8825" device)
       (vla-put-configname layout "Engineering Wide Format Printer")
       (princ " - Updated 'XEROX 8825' to 'Engineering Wide Format Printer'   " )
       )

     ( (eq "NONE" device)
       (vla-put-configname layout "Local Printer")
       (princ " - Updated 'None' to 'Local Printer'   " )
       )
   )
 )
 (princ "\n")
 (Princ "\n")
 (Princ "\nList plotters assignments after update    *******************")
 (Princ "\n")

 (Print (c:GetPlotdevices))
 (princ "\n")
 (princ "\n")

;; PSLTSCALE to 0 – for all layouts
 (Princ "\nReset PSLTSCALE to 0 all layouts   ***********************")
 (princ "\n")
 (princ "\n")
 (foreach lay (layoutlist)
    (setvar "CTAB" lay)
    (print (Getvar "CTAB"))
    (command "psltscale" "0")
    (command "regenall")
    (print)


 ) ;Cycles through all layouts to set psltscale.


 (Setvar "CTAB" "Model") ; reset dispaly to Model
 (print (Getvar "CTAB"))
 (command "psltscale" "0")
 (command "regenall")
 (princ "\n")
 (Princ "\n")

 (princ "\nFinsihed PSLTSCALE Updates resetting to model layout  ************")
 (princ "\n")
 (princ "\n")
;;;  (Command "QSAVE")
 (princ "\n")
 (princ "\n")
 (print "***********    End of routine ****************")
 (princ "\n")
 (princ "\n")
 (princ)
)


;;; Start udf support functions
(defun c:GetPlotDevices (/ dvc)
   (vl-load-com)
   ;; Lee Mac  ~  26.02.10
   (vlax-map-collection
     (vla-get-layouts
(vla-get-ActiveDocument
  (vlax-get-acad-object)
)
     )
     (function
(lambda (layout)
  (vla-RefreshPlotDeviceInfo layout)
  (setq dvc
  (cons
    (cons
      (vla-get-name layout)
      (vla-get-ConfigName layout)
    )
    dvc
  )
  )
)
     )
   )
   (reverse dvc)

 )

Link to comment
Share on other sites

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