Jump to content

'Put' pc3 file to all tabs


Small Fish

Recommended Posts

Almost there with what I am trying to achieve.

I would like to assign all layout tabs with the same pc3 picked by the user. How would that be done? Is there a function floating around that does that?

thanks for any help!

 

note: using a Dos_Lib function

 

 
;some parts by Lee Mac 
(defun C:SetPC3 (/ doc Pc3Files pc3)
 (vl-load-com)
 (vla-RefreshPlotDeviceInfo
   (vla-get-ActiveLayout
     (setq doc
     (vla-get-activedocument
       (vlax-get-acad-object)))))
 (setq Pc3Files (vl-remove-if-not
    (function
      (lambda (x) (wcmatch x "*.pc3")))
    (vlax-invoke
      (vla-item (vla-get-layouts doc) "Model")
      'GetPlotDeviceNames)))
 (setq pc3 (dos_listbox
      "Assign pc3 file to all tabs"
      "Select a pc3 file to assign  to all tab layouts"
      Pc3Files  ""  ))
 (foreach x
     (vl-remove "Model" (layoutlist))
   (putPc3 x Pc3Files);do I need a function - putPc3 
        ;or a few lines of extra code?
 );foreach
 );defun

Link to comment
Share on other sites

  (vlax-for x (vla-get-layouts doc)
   (or (eq (vla-get-name x) "Model")
       (vl-catch-all-apply (function vla-put-configname) (list x pc3))
   )
 )

However, your code could use a little house cleaning (since it will call the layouts multiple times, etc.).

 

For the record (layoutlist) does not include "Model".

Link to comment
Share on other sites

thanks Alan

but I am not sure whether I should make it a function or where to add it to my above code?

 

and yes you are correct re: (layoutlist) does not include "Model".

Link to comment
Share on other sites

thanks Alan

but I am not sure whether I should make it a function or where to add it to my above code?

 

and yes you are correct re: (layoutlist) does not include "Model".

Remove all that foreach crap at the bottom and add (if (setq pc3.....) add what I posted here )

 

 

(if (setq pc3 (dos_listbox
               "Assign pc3 file to all tabs"
               "Select a pc3 file to assign  to all tab layouts"
               Pc3Files
               ""
             )
   )
 (vlax-for x (vla-get-layouts doc)
   (or (eq (vla-get-name x) "Model")
       (vl-catch-all-apply (function vla-put-configname) (list x pc3))
   )
 )
)

Link to comment
Share on other sites

thanks Alan - but I can not get it to work with what you suggested

 ;some parts by Lee Mac 
(defun C:SetPC3 (/ doc Pc3Files pc3)
 (vl-load-com)
 (vla-RefreshPlotDeviceInfo
   (vla-get-ActiveLayout
     (setq doc
            (vla-get-activedocument
              (vlax-get-acad-object)
            )
     )
   )
 )
 (if (and (setq Pc3Files (vl-remove-if-not
                           (function
                             (lambda (x) (wcmatch x "*.pc3"))
                           )
                           (vlax-invoke
                             (vla-item (vla-get-layouts doc) "Model")
                             'GetPlotDeviceNames
                           )
                         )
          )
          (setq pc3 (dos_listbox
                      "Assign pc3 file to all tabs"
                      "Select a pc3 file to assign  to all tab layouts"
                      Pc3Files
                      ""
                    )
          )
     )
   (vlax-for x (vla-get-layouts doc)
     (or (eq (vla-get-name x) "Model")
         (vl-catch-all-apply (function vla-put-configname) (list x pc3))
     )
   )
 )
 (princ)
) ;defun

Link to comment
Share on other sites

I'm not sure why you are refreshing the plotter devices to the active layout, but 'get'ing the plotter devices from model. What if you are not in model. Why not just take them from the active layout that you've already defined?

Link to comment
Share on other sites

Hey Alan that works brilliant - and I learned something new

 

I suppose you meant :

 
             (vlax-for x (vla-get-layouts doc)
should be: (vlax-for x (vla-get-layouts *AcadDoc )

just testing me I guess?:wink:

 

cheers SF

Link to comment
Share on other sites

Hey Alan that works brilliant - and I learned something new

 

I suppose you meant :

 
             (vlax-for x (vla-get-layouts doc)
should be: (vlax-for x (vla-get-layouts *AcadDoc )

just testing me I guess?:wink:

 

cheers SF

Huh? At the beginning of the routine, you defined the active document as doc.

Am I missing something?

Link to comment
Share on other sites

Keep in mind that, while you've successfully assigned a plotter to each layout, nothing else is set properly (sheet size, ctb, etc.). You should really look into using PageSetups. This will avoid a lot of legwork.

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