Author Topic: Print Server Name Change?  (Read 16012 times)

0 Members and 1 Guest are viewing this topic.

SDETERS

  • Guest
Re: Print Server Name Change?
« Reply #15 on: February 09, 2010, 05:57:17 PM »
I get an error I checked this a couple of times error: Automation Error. Invalid input

This is how I have the code at the current time.  I am missing something  Once again thanks for the help

Code: [Select]
(vla-put-configname
  (vla-get-layout
    (vla-get-PaperSpace
      (vla-get-ActiveDocument
(vlax-get-object "AutoCAD.Application")
      )
    )
  )
  "ME Assembly.pc3"
)
;; or
(vla-put-configname
  (vla-get-layout
    (vla-get-PaperSpace
      (vla-get-ActiveDocument
(vlax-get-object "AutoCAD.Application")
      )
    )
  )
  "None"
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Print Server Name Change?
« Reply #16 on: February 09, 2010, 06:06:18 PM »

Shane,
Are you running this after importing the PageSetups from your template ?

Can you post(attach to post) the drawing after you've imported the Page Setups ?

Which code are you importing the PageSetups with ?
and what is the qualified filename for your template with the correct PageSetups?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #17 on: February 09, 2010, 08:58:20 PM »
I get an error I checked this a couple of times error: Automation Error. Invalid input
<snip>
*humm?*

I'm interested in the answer to Kerry's questions too.



This is how I have the code at the current time.  I am missing something  Once again thanks for the help

Code: [Select]
(vla-put-configname
      ;<snip>
  "ME Assembly.pc3"
)
;; or
(vla-put-configname
       ;<snip>
  "None"
)


Oh no problem at all; im just sorry I cant help more.

If youre running the code exactly as you show it, then we need to make at least one change.
Could you in addition to Kerry's questions could you run this snip of code for me please and let me know if you get the Automation Error again.
Code: [Select]
(vla-put-configname
  (vla-get-layout
    (vla-get-PaperSpace
      (vla-get-ActiveDocument
(vlax-get-object "AutoCAD.Application")
      )
    )
  )
  "ME Assembly.pc3"
)



Kerry, do you think the space in the driver name would cause that error?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Print Server Name Change?
« Reply #18 on: February 09, 2010, 09:03:47 PM »
< ... >

Kerry, do you think the space in the driver name would cause that error?

Hi John,

Thats one of the things I wanted to check when I got Shane's files .. I don't recall ever using a space in the name myself.
.. but AutoCAD does use spaces, SO probably not.


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #19 on: February 09, 2010, 09:16:12 PM »
w00t! I'm bookmarking this thread baby! The first time my mind was great. ...*blink* *gulp* dang, i hope it aint just statistics?!

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SDETERS

  • Guest
Re: Print Server Name Change?
« Reply #20 on: February 10, 2010, 08:51:30 AM »
Answers to Kerry questions.

Shane,
Are you running this after importing the PageSetups from your template ?

I am running this before.  SHould I be running it after?

Can you post(attach to post) the drawing after you've imported the Page Setups ?

I am attaching both files my template and a sample drawing.

Which code are you importing the PageSetups with ?

The one that se7en suggested.  Maybe I need some step by step instructions.  Dang I am a noob when it come to this lisp stuff sorry

and what is the qualified filename for your template with the correct PageSetups?

the name for the template file is "HG ME Template.dwt"

The example file that I am messing with is named EDST4_PART001.dwg

These will be both attached.  Um would it be better and or make life easier if there was no spaces in the file name?  I hoped I answered all of the questions.  Off to try se7en code

Once again thanks for the help.  I also attached a jpeg of the warning box I do not want showing up.  Our print named changed from hgrps1 to hgrps2
« Last Edit: February 10, 2010, 09:03:40 AM by SDETERS »

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #21 on: February 10, 2010, 08:58:24 AM »
after.  Let me assemble one piece of code for you to run before i start downloading your files.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #22 on: February 10, 2010, 09:07:49 AM »
I gotta run, I got a fire here i have to put out. Run this and see what you get.

Code: [Select]
(defun c:psetup-test ( / )
   (setq *acad* (vlax-get-acad-object))
   (setq *active-document* (vla-get-activedocument *acad*))
   
       (defun copy_page-setup (DwgName / psetups $acadver$ $typelib$ $classname$ $dbxDoc$)
           (setq $AcadVer$  (atoi (getvar "acadver"))
                 $TypeLib$   (findfile "AxDb.dll")
                 $ClassName$ (strcat "ObjectDBX.AxDbDocument" "." (itoa $AcadVer$))
                 $dbxdoc$   (vla-GetInterfaceObject (vlax-get-acad-object) $ClassName$))
         
           (setq psetups (vla-get-plotconfigurations *active-document*))
         
           (vla-open $dbxdoc$ DwgName)
         
           (vlax-for x
                     (setq dbxdoc-collection (vla-get-plotconfigurations $dbxdoc$))
                     (setq name (vla-get-name x))
                     (vla-copyobjects
                       $dbxdoc$
                       (vlax-safearray-fill
                         (vlax-make-safearray vlax-vbobject '(0 . 0))
                         (list (vla-item dbxdoc-collection name)))
                       psetups ))
         
           (vlax-release-object $dbxdoc$)
           (princ)
           )
   ;;
   ;; delete existing pagesetups
   (vlax-map-collection (vla-get-plotconfigurations *active-document*) 'vla-delete)

   ;;
   ;; import the new ones
   (copy_page-setup "C:\\HG ME Template.dwt")

   (vla-put-configname
     (vla-get-layout
       (vla-get-PaperSpace
         (vla-get-ActiveDocument
    (vlax-get-object "AutoCAD.Application")
         )
       )
     )
     "ME Assembly.pc3"
   )

  (princ "\nType \"Psetup-test\" for the test.")
  (princ)
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #23 on: February 10, 2010, 09:08:50 AM »
oh and note the path to your template, fix if you need to.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SDETERS

  • Guest
Re: Print Server Name Change?
« Reply #24 on: February 10, 2010, 09:28:51 AM »
Ok ran the code

It ran just fine.

I still get that JPEG error box I have attached in the previous post when I go to plot. 


JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #25 on: February 10, 2010, 09:58:25 AM »
Ok, i think i'm almost got this figured out. If im correct then all that is left is just a little bit of code.

Run this line please.
Code: [Select]
(vlax-map-collection (vla-get-layouts *active-document*) '(lambda ( x ) (vla-put-configname x "None")))
Try to plot.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SDETERS

  • Guest
Re: Print Server Name Change?
« Reply #26 on: February 10, 2010, 10:56:02 AM »
I ran the psetup-test then I ran your small line of code in your previous post.

This now sets my printer to none.  Great This eliminates my jpeg warning

What would be even better would be to set my Printer to the appropriate network printer. 

Could this be done by changing none to the printer name? 

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #27 on: February 10, 2010, 11:00:17 AM »
lol we are on the same page my friend.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10642
Re: Print Server Name Change?
« Reply #28 on: February 10, 2010, 11:18:25 AM »
Here ya go.

Replace/fix the two lines as you need to.

Call the command from the command line like: psetup-reset
or
Call the command from a button or another lisp like: (c:psetup-reset)

Code: [Select]
(defun c:psetup-reset ( / )
   (setq *acad* (vlax-get-acad-object))
   (setq *active-document* (vla-get-activedocument *acad*))
   
       (defun copy_page-setup (DwgName / psetups $acadver$ $typelib$ $classname$ $dbxDoc$)
           (setq $AcadVer$  (atoi (getvar "acadver"))
                 $TypeLib$   (findfile "AxDb.dll")
                 $ClassName$ (strcat "ObjectDBX.AxDbDocument" "." (itoa $AcadVer$))
                 $dbxdoc$   (vla-GetInterfaceObject (vlax-get-acad-object) $ClassName$))
         
           (setq psetups (vla-get-plotconfigurations *active-document*))
         
           (vla-open $dbxdoc$ DwgName)
         
           (vlax-for x
                     (setq dbxdoc-collection (vla-get-plotconfigurations $dbxdoc$))
                     (setq name (vla-get-name x))
                     (vla-copyobjects
                       $dbxdoc$
                       (vlax-safearray-fill
                         (vlax-make-safearray vlax-vbobject '(0 . 0))
                         (list (vla-item dbxdoc-collection name)))
                       psetups ))
         
           (vlax-release-object $dbxdoc$)
           (princ)
           )
 
   ;;
   ;; delete existing pagesetups
   (vlax-map-collection (vla-get-plotconfigurations *active-document*) 'vla-delete)

   ;;
   ;; import the new ones
   (copy_page-setup "C:\\HG ME Template.dwt")

   ;;
   ;; apply the default printer driver to all the layouts
   (vlax-map-collection
     (vla-get-layouts *active-document*)
     '(lambda ( x ) (vla-put-configname x "ME Assembly.pc3")))

  ;;
  ;; release the obj's
  (mapcar 'vlax-release-object (list *acad* *active-document*))
 
  (princ)
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SDETERS

  • Guest
Re: Print Server Name Change?
« Reply #29 on: February 10, 2010, 11:31:33 AM »
Great I think this will work.  Please stay tuned I may have a question about *.pc3 files.  Thanks again  This is great