Message 1 of 8
reload xref symbology

Not applicable
10-26-2003
05:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Following is my stab at reloading xref symbology, without effecting layer
on/off, freeze/thaw, locked/unlocked status in the active file. It makes three
lists. See below. It reloads the xref with visretain off. Then put things back
the way they were before with regard to the xref layers in question.
Comments, suggestions and spit-balls are more than welcome. 😉
BTW yes, my Microstation history is showing here. It was easy there. I don't
understand why this sort of thing isn't easy in A2kx.
Regards
Joe Burke
;; Joe Burke 10/26/2003
;; reload xref symbology (colors, linetypes etc.)
;; without effecting xref on/off, freeze/thaw,
;; locked/unlocked states in the active file
;; tested in model space only
(defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
ent xname onlst frzlst locklst )
(vl-load-com)
(defun *Error* (Msg)
(cond
((or (not Msg)
(member Msg '("console break"
"Function cancelled"
"quit / exit abort"))))
((princ (strcat "\nError: " Msg))))
(setvar "visretain" 1)
(vla-endundomark doc)
(princ)
) ;end
(setq acad (vlax-get-acad-object)
doc (vla-get-activedocument acad)
layers (vla-get-layers doc)
blocks (vla-get-blocks doc)
)
(vla-startundomark doc)
(setvar "visretain" 0)
(setq ent (car (entsel "\nSelect xref to reload symbology: ")))
(while (or (null ent) (not (is-xref ent)))
(setq ent (car (entsel "\nMissed pick or xref not selected, try again: ")))
)
(setq xname (cdr (assoc 2 (entget ent))))
(LayerState)
(vla-reload (vla-item blocks xname))
(foreach x onlst
(vla-put-layeron (vla-item layers (car x)) (cdr x)))
(foreach x frzlst
(vla-put-freeze (vla-item layers (car x)) (cdr x)))
(foreach x locklst
(vla-put-lock (vla-item layers (car x)) (cdr x)))
(princ (strcat "\nXref symbology reloaded from file: " xname))
(*Error* nil)
(princ)
) ;end
(defun LayerState ( / str pair )
(setq str (strcat xname "|"))
(vlax-for x layers
(if (vl-string-search str (vla-get-name x))
(setq pair (cons (vla-get-name x) (vla-get-freeze x))
frzlst (cons pair frzlst)
pair (cons (vla-get-name x) (vla-get-layeron x))
onlst (cons pair onlst)
pair (cons (vla-get-name x) (vla-get-lock x))
locklst (cons pair locklst)
)
)
)
) ;end
;is object an xref - returns T or nil
;arguments insrtObj - ename of an insert
(defun is-xref (insrtObj)
(if (= (type insrtObj) 'ENAME)
(vlax-Property-Available-p (vlax-ename->vla-object insrtObj) 'Path)
(vlax-Property-Available-p insrtObj 'Path)
)
) ;end
on/off, freeze/thaw, locked/unlocked status in the active file. It makes three
lists. See below. It reloads the xref with visretain off. Then put things back
the way they were before with regard to the xref layers in question.
Comments, suggestions and spit-balls are more than welcome. 😉
BTW yes, my Microstation history is showing here. It was easy there. I don't
understand why this sort of thing isn't easy in A2kx.
Regards
Joe Burke
;; Joe Burke 10/26/2003
;; reload xref symbology (colors, linetypes etc.)
;; without effecting xref on/off, freeze/thaw,
;; locked/unlocked states in the active file
;; tested in model space only
(defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
ent xname onlst frzlst locklst )
(vl-load-com)
(defun *Error* (Msg)
(cond
((or (not Msg)
(member Msg '("console break"
"Function cancelled"
"quit / exit abort"))))
((princ (strcat "\nError: " Msg))))
(setvar "visretain" 1)
(vla-endundomark doc)
(princ)
) ;end
(setq acad (vlax-get-acad-object)
doc (vla-get-activedocument acad)
layers (vla-get-layers doc)
blocks (vla-get-blocks doc)
)
(vla-startundomark doc)
(setvar "visretain" 0)
(setq ent (car (entsel "\nSelect xref to reload symbology: ")))
(while (or (null ent) (not (is-xref ent)))
(setq ent (car (entsel "\nMissed pick or xref not selected, try again: ")))
)
(setq xname (cdr (assoc 2 (entget ent))))
(LayerState)
(vla-reload (vla-item blocks xname))
(foreach x onlst
(vla-put-layeron (vla-item layers (car x)) (cdr x)))
(foreach x frzlst
(vla-put-freeze (vla-item layers (car x)) (cdr x)))
(foreach x locklst
(vla-put-lock (vla-item layers (car x)) (cdr x)))
(princ (strcat "\nXref symbology reloaded from file: " xname))
(*Error* nil)
(princ)
) ;end
(defun LayerState ( / str pair )
(setq str (strcat xname "|"))
(vlax-for x layers
(if (vl-string-search str (vla-get-name x))
(setq pair (cons (vla-get-name x) (vla-get-freeze x))
frzlst (cons pair frzlst)
pair (cons (vla-get-name x) (vla-get-layeron x))
onlst (cons pair onlst)
pair (cons (vla-get-name x) (vla-get-lock x))
locklst (cons pair locklst)
)
)
)
) ;end
;is object an xref - returns T or nil
;arguments insrtObj - ename of an insert
(defun is-xref (insrtObj)
(if (= (type insrtObj) 'ENAME)
(vlax-Property-Available-p (vlax-ename->vla-object insrtObj) 'Path)
(vlax-Property-Available-p insrtObj 'Path)
)
) ;end