'Put' pc3 file to al
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 assignto 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 (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". 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 assignto 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)) ) )) 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 assignto 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 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? 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? 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.
页:
[1]