How true.
I have a bunch of file from a GC which he wants modified. They are all CTB & I want to use STB.
I am not plotting them yet just trying to update the plot style names for the layer in the list.
This is what I am playing with. I took a routine by Tim & modified it for this usage.
The PlotStyleUpdate is what I threw together and works fine on a single drawing.
So I though with 12 drawing to go why not try to do it with DBX as this is not the first & surly not
the last time I have to do this.
Well, I can't seem to "SaveAs' without an error and then there is this problem testing for CTB files.
I have the CTB licked for the moment.
Any reason why I can't 'SaveAs' ? I am suspecting that it's ACAD2000. I'll try it on 2004 tomorrow.
Too tired to fight it anymore tonight.
;;;by Tim Willey 8/29/06
;;; modified by CAB 01/03/2007
(defun C:Test (/ DirPath odbx FullPath fname usrdmd)
(setq *acad (vlax-get-acad-object))
(if
(and
(setq DirPath (getfolder))
(setq odbx
(if (< (atoi (substr (getvar "acadver") 1 2)) 16)
(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument.16")
)
)
)
(progn
(setq usrdmd (getvar "demandload"))
(setvar "demandload" 0)
(foreach Dwg (vl-directory-files DirPath "*.dwg" 1)
(setq FullPath (strcat DirPath "\\" Dwg))
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Open (list odbx FullPath)))
(prompt (strcat "\n ++ Couldn't open drawing \"" FullPath "\""))
(progn
(prompt (strcat "\n - Processing - " FullPath))
(if (PlotStyleUpdate odbx)
(progn
;; CAB having trouble saving in ACAD2000
(setq fname (vl-string-subst "\\" "\\\\" (vla-get-Name odbx))) ; CAB
;;(setq fname (vl-string-subst (strcat (vl-filename-base fname)"-1") (vl-filename-base fname) fname))
;;(vla-SaveAs odbx fname)
(vl-catch-all-apply 'vla-saveas (list odbx fname)) ; CAB
)
)
)
)
)
(setvar "demandload" usrdmd)
)
)
(and odbx (vlax-release-object odbx))
(setq odbx nil)
(princ)
)
(defun GetFolder ( / DirPat)
(and (setq DirPat (getfiled "Browse for folder"
"Open a folder and click on SAVE" " " 1))
(setq DirPat (substr DirPat 1 (- (strlen DirPat) 31)))
)
DirPat
)
;; CAB 01/06/2007
;; Update the plot style name in layers of XXXXXX Drawing
;; command line entry
(defun c:LFPU() (PlotStyleUpdate (vla-get-activedocument (vlax-get-acad-object))))
;; ObjectDBX entry
;; returns true if successful
(defun PlotStyleUpdate (doc / lays LayersLocked)
(if (= (substr (vla-get-PlotStyleName (vla-item (vla-get-layers doc)"0")) 1 5) "Color")
(prompt (strcat "\nThis is a CTB DWG, can not proceed \n " (vl-filename-base (vla-get-name doc))))
(progn
(princ (strcat "\nUpdating " (vl-filename-base (vla-get-name doc))))
(setq lays (vla-get-layers doc))
;; unlock and make list of layers changed
(vlax-for lay lays
(if (eq (vla-get-lock lay) :vlax-true)
(progn
(setq LayersLocked (cons lay LayersLocked))
(vla-put-lock lay :vlax-false)
)
)
)
;; update each layer in the dwg found in the list
(foreach lay (GetLayersToChange)
(vl-catch-all-apply '(lambda(lay)
(vla-put-plotstylename (vla-item lays (car lay)) (cadr lay)))
(list lay)
)
)
(mapcar '(lambda (x) (vla-put-lock x :vlax-true)) LayersLocked)
t
)
)
)
(defun GetLayersToChange()
'( ; (LayerName PlotStyle)
("0" "Light")
("1-TITLEBLK" "Medium")
("A-COPYRIGHT" "Light")
("A-TEXT2" "Light")
("anno-appl" "Light")
("anno-clg" "Light")
("anno-clg-dims" "Light")
("anno-dims" "Light")
("anno-legn" "Light")
("anno-legn-bord" "Light")
("anno-legn-text" "Light")
("anno-notes" "Light")
("anno-plumb" "Light")
("anno-rev" "Light")
("anno-rmname" "Light")
("anno-rmsize" "Light")
("anno-tags" "Light")
("anno-ttl" "Light")
("anno-ttlblk" "Light")
("appliance" "Light")
("area" "Light")
("area3" "Light")
("beam-abv" "Light")
("case-abv" "Light")
("casework" "Light")
("clg-abv" "Light")
("column" "Light")
("column-blw" "Light")
("column-int" "Light")
("door" "Light")
("door-frame" "Light")
("door-panel" "Light")
("door-stop" "Light")
("door-swing" "Light")
("door-thresh" "Light")
("door-trshld" "Light")
("electric" "Light")
("elevator" "Light")
("equip-abv" "Light")
("equipment" "Light")
("f1" "Light")
("hatching" "Light")
("hose-bib" "Light")
("insulat" "Light")
("plumbing" "Light")
("railing" "Light")
("site-fence2" "Light")
("slab" "Light")
("slab-deck" "Light")
("stairs" "Light")
("TBLK BOLD" "Heavy")
("TBLK GREY" "Light")
("TBLK HEAVY" "Heavy")
("TBLK LIGHT" "Light")
("TBLK MEDIUM" "Medium")
("TBLK NAME" "Light")
("wall" "Heavy")
("wall-glass" "Light")
("wall-int-abv" "Light")
("wall-int-blw" "Light")
("wall-int-fin" "Heavy")
("wall-int-hat" "Light")
("wall-msn-abv" "Light")
("wall-msn-blw" "Light")
("wall-msn-fin" "Heavy")
("wall-msn-hat" "Light")
("wall-open" "Light")
("wall-open-above" "Light")
("wall-plumb" "Light")
("wall-pres-fil" "Light")
("wind-frame" "xLight")
("wind-glass" "xLight")
("wind-sash" "xLight")
("window" "Light")
("Z-TITLE-TEXT" "Light")))