I KNOW how to set the penstyle for the ACTIVE page setup--but I need to change the penstyle for ALL page setups. Does anyone know the best way to do this? TIA
Yep In this instance, I've got a CTB file (0453.ctb) and 25 dwg files--each with 2 page setups (one full size and one half size). The following will assign the CTB file to the ACTIVE plot settings--but not the page setup. I've got a routine that applies this CTB file upon opening the DWG file then saves and closes.the DWG file. This means that I can just open all the files and they're taken care of. I'd like to make it so that the CTB file is assigned to ALL pagesetups in the DWG file. Thx. (pstyle "0453.ctb") (defun PStyle (ctbFile / lay err) (vl-load-com) (setq lay (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object) ) ) ) (setq err (vl-catch-all-apply 'vla-put-stylesheet (list lay ctbFile) ) ) (if (vl-catch-all-error-p err) (princ (vl-catch-all-error-message err)) ) (princ) )
How about something like this? (putPlotConfigurationCTB (vla-get-activedocument (vlax-get-acad-object)) "*" "my.ctb" ) ; function to apply a ctb file to a plot configuration ; Arguments: ; [document] - vla-object, document object ; [plotConfigName] - string, pagesetup name (wildcards allowed) ; [ctbName] - string, ctb file to apply ; returns message if an error occured (defun putPlotConfigurationCTB (document plotConfigName ctbName / result) (if (vl-catch-all-error-p (setq result (vl-catch-all-apply '(lambda () (setq plotConfigName (strcase plotConfigName)) (vlax-for item (vla-get-plotconfigurations document) (if (wcmatch (strcase (vla-get-name item)) plotConfigName) (vla-put-stylesheet item ctbName))) ) ) ) ) (vl-catch-all-error-message result) ) )
Glad it worked for you. Calling vla-refreshplotdeviceinfo might be required, just something keep in mind.
What's that do? I ran your code on one my files--putting in a pentable I did NOT want to use--then checked the plot dialog box. Both setups were set to use that pentable. Then I ran your code again--this time putting in the pentable I DID want to use--and checked the plot dialog again. It showed the good CTB file this time around.
The couple of quick test I did when penning that function I noticed the pagesetup didn't always reflect the changes. Example: Pagesetup "ABC" was current, I ran the code and the new .ctb file wasn't listed until I applied that pagesetup again. Using vla-refreshplotdeviceinfo should take care of that problem.