reload xref symbology

reload xref symbology

Anonymous
Not applicable
304 Views
7 Replies
Message 1 of 8

reload xref symbology

Anonymous
Not applicable
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
0 Likes
305 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I think I get it.
Not much time here, so:
1. Beware (vl-string-search); you might have xrefs named "ABC" and "XABC". Maybe
(wcmatch) would be better.
2. Plot/NoPlot?
3. Is VPLAYER affected?

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ

"Joe Burke" wrote in message
news:8DCEE3C6E5E09DA458A422459F66EED1@in.WebX.maYIadrTaRb...
> 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
>
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Hi John,

Thanks for your suggestions. Right, vl-string-search was a problem. Uses wcmatch
now. Added plot/noplot. Definitely needed, though that's not something I use.
I've seen too many cases of xrefs accidentally placed on a noplot layer. VPLAYER
is not affected.

Here's a revised version.

;; Joe Burke 10/26/2003
;; revised 10/27/2003 with thanks to John Uhden
;; reload xref symbology (colors, linetypes etc.)
;; without effecting xref on/off, freeze/thaw,
;; locked/unlocked, plot/noplot states in the active file
;; tested in model space only

(defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
ent xname onlst frzlst locklst plotlst )
(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)))
(foreach x plotlst
(vla-put-plottable (vla-item layers (car x)) (cdr x)))
(if onlst
(princ (strcat "\nXref symbology reloaded from file: " xname))
(princ "Failed to update xref symbology "))
(*Error* nil)
(princ)
) ;end

(defun LayerState ( / str pair )
(setq str (strcat xname "|*"))
(vlax-for x layers
(if (wcmatch (vla-get-name x) str)
(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)
pair (cons (vla-get-name x) (vla-get-plottable x))
plotlst (cons pair plotlst)
)
)
)
) ;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


"John Uhden" wrote in message
news:985E9693B2FE8B2A20AEAF33473C37E6@in.WebX.maYIadrTaRb...
> I think I get it.
> Not much time here, so:
> 1. Beware (vl-string-search); you might have xrefs named "ABC" and "XABC".
Maybe
> (wcmatch) would be better.
> 2. Plot/NoPlot?
> 3. Is VPLAYER affected?
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> http://www.cadlantic.com
> Sea Girt, NJ
0 Likes
Message 4 of 8

Anonymous
Not applicable
Joe:

I forgot to mention. Someone like me might rename a layer to upper case before
you reload, so...
(setq str (strcase (strcat xname "|*")))
(vlax-for x layers
(if (wcmatch (strcase (vla-get-name x)) str)

Naturally, I'm talking about a networked situation where XLOADCTL is set to 2.

Actually, what if layers are renamed wholesale? Rather than names, might their
handles stick between loads?
If so, that might change your approach just a tad.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ

"Joe Burke" wrote in message
news:AA545D21149E8107DF00B12FFA82DF12@in.WebX.maYIadrTaRb...
> Hi John,
>
> Thanks for your suggestions. Right, vl-string-search was a problem. Uses
wcmatch
> now. Added plot/noplot. Definitely needed, though that's not something I use.
> I've seen too many cases of xrefs accidentally placed on a noplot layer.
VPLAYER
> is not affected.
>
> Here's a revised version.
>
> ;; Joe Burke 10/26/2003
> ;; revised 10/27/2003 with thanks to John Uhden
> ;; reload xref symbology (colors, linetypes etc.)
> ;; without effecting xref on/off, freeze/thaw,
> ;; locked/unlocked, plot/noplot states in the active file
> ;; tested in model space only
>
> (defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
> ent xname onlst frzlst locklst plotlst )
> (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)))
> (foreach x plotlst
> (vla-put-plottable (vla-item layers (car x)) (cdr x)))
> (if onlst
> (princ (strcat "\nXref symbology reloaded from file: " xname))
> (princ "Failed to update xref symbology "))
> (*Error* nil)
> (princ)
> ) ;end
>
> (defun LayerState ( / str pair )
> (setq str (strcat xname "|*"))
> (vlax-for x layers
> (if (wcmatch (vla-get-name x) str)
> (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)
> pair (cons (vla-get-name x) (vla-get-plottable x))
> plotlst (cons pair plotlst)
> )
> )
> )
> ) ;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
>
>
> "John Uhden" wrote in message
> news:985E9693B2FE8B2A20AEAF33473C37E6@in.WebX.maYIadrTaRb...
> > I think I get it.
> > Not much time here, so:
> > 1. Beware (vl-string-search); you might have xrefs named "ABC" and "XABC".
> Maybe
> > (wcmatch) would be better.
> > 2. Plot/NoPlot?
> > 3. Is VPLAYER affected?
> >
> > --
> > John Uhden, Cadlantic/formerly CADvantage
> > http://www.cadlantic.com
> > Sea Girt, NJ
>
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
John,

Thanks for strcase.

I hadn't thought about layer names changing in the referenced file. I tried it.
Strange, I get this error: Error: Automation Error. Key not found, which makes
sense. But it still works. Changes made to the renamed layer are updated where
the file is referenced. Which makes no sense to me. Maybe I need
vl-catch-all-apply? I don't know how to apply that to the foreach functions.

Joe

"John Uhden" wrote in message
news:C963F2A99D2F2AB495A018848A733666@in.WebX.maYIadrTaRb...
> Joe:
>
> I forgot to mention. Someone like me might rename a layer to upper case
before
> you reload, so...
> (setq str (strcase (strcat xname "|*")))
> (vlax-for x layers
> (if (wcmatch (strcase (vla-get-name x)) str)
>
> Naturally, I'm talking about a networked situation where XLOADCTL is set to 2.
>
> Actually, what if layers are renamed wholesale? Rather than names, might
their
> handles stick between loads?
> If so, that might change your approach just a tad.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> http://www.cadlantic.com
> Sea Girt, NJ
>
> "Joe Burke" wrote in message
> news:AA545D21149E8107DF00B12FFA82DF12@in.WebX.maYIadrTaRb...
> > Hi John,
> >
> > Thanks for your suggestions. Right, vl-string-search was a problem. Uses
> wcmatch
> > now. Added plot/noplot. Definitely needed, though that's not something I
use.
> > I've seen too many cases of xrefs accidentally placed on a noplot layer.
> VPLAYER
> > is not affected.
> >
> > Here's a revised version.
> >
> > ;; Joe Burke 10/26/2003
> > ;; revised 10/27/2003 with thanks to John Uhden
> > ;; reload xref symbology (colors, linetypes etc.)
> > ;; without effecting xref on/off, freeze/thaw,
> > ;; locked/unlocked, plot/noplot states in the active file
> > ;; tested in model space only
> >
> > (defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
> > ent xname onlst frzlst locklst plotlst )
> > (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)))
> > (foreach x plotlst
> > (vla-put-plottable (vla-item layers (car x)) (cdr x)))
> > (if onlst
> > (princ (strcat "\nXref symbology reloaded from file: " xname))
> > (princ "Failed to update xref symbology "))
> > (*Error* nil)
> > (princ)
> > ) ;end
> >
> > (defun LayerState ( / str pair )
> > (setq str (strcat xname "|*"))
> > (vlax-for x layers
> > (if (wcmatch (vla-get-name x) str)
> > (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)
> > pair (cons (vla-get-name x) (vla-get-plottable x))
> > plotlst (cons pair plotlst)
> > )
> > )
> > )
> > ) ;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
> >
> >
> > "John Uhden" wrote in message
> > news:985E9693B2FE8B2A20AEAF33473C37E6@in.WebX.maYIadrTaRb...
> > > I think I get it.
> > > Not much time here, so:
> > > 1. Beware (vl-string-search); you might have xrefs named "ABC" and "XABC".
> > Maybe
> > > (wcmatch) would be better.
> > > 2. Plot/NoPlot?
> > > 3. Is VPLAYER affected?
> > >
> > > --
> > > John Uhden, Cadlantic/formerly CADvantage
> > > http://www.cadlantic.com
> > > Sea Girt, NJ
> >
> >
>
0 Likes
Message 6 of 8

Anonymous
Not applicable
I should add in case anyone wonders... Why not save a layer state, reload with
visretain off, restore layer state, reset visretain to 1. Doesn't work. I think
because the objects in the layer table change when reloading with visretain off.
That's why I had to use the layer names to restore layer settings instead of the
layer object itself.

Joe Burke

"Joe Burke" wrote in message
news:8DCEE3C6E5E09DA458A422459F66EED1@in.WebX.maYIadrTaRb...
> 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
>
>
0 Likes
Message 7 of 8

Anonymous
Not applicable
Hi John,

Following is a revised version which I think deals with xref layer names
changed, added or deleted. Now it reloads the xref with visretain "on" first.
Then get the current layer state. Note, the old LayerState function is folded
in. Also, the (setq layers (vla-get-layers doc)) statement is relocated. That
part gave me fits. You might also notice, now I think I don't need the strcase
functions you suggested. Of course, I could be wrong.

Your insights into this thing are appreciated as usual. I also learned something
about word usage, i.e., "effecting" (probably not a word) versus "affecting".

Eventually I'll probably add a DosLib dialog which lets the user choose "update
colors", "update linetypes" etc.

Joe

;; Joe Burke 10/26/2003
;; revised 10/27/2003 with thanks to John Uhden
;; revised 10/28/2003 ditto
;; reload xref symbology: layer color, linetype and lineweight
;; without affecting xref layer on/off, freeze/thaw,
;; locked/unlocked, plot/noplot states in the active file

(defun c:ReloadXrefSymbology ( / *Error* acad doc layers blocks
ent xname onlst frzlst locklst plotlst )
(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)
blocks (vla-get-blocks doc)
)
(vla-startundomark doc)
(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))))
(setvar "visretain" 1)
(vla-reload (vla-item blocks xname))
(setq layers (vla-get-layers doc))
(setq str (strcat xname "|*"))
(setvar "visretain" 0)
(vla-reload (vla-item blocks xname))
(vlax-for x layers
(if (wcmatch (vla-get-name x) str)
(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)
pair (cons (vla-get-name x) (vla-get-plottable x))
plotlst (cons pair plotlst)
)
)
)
(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)))
(foreach x plotlst
(vla-put-plottable (vla-item layers (car x)) (cdr x)))
(if onlst
(princ (strcat "\nXref symbology reloaded from xref name: " xname))
(princ "Failed to update xref symbology "))
(*Error* nil)
(princ)
) ;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



"John Uhden" wrote in message
news:C963F2A99D2F2AB495A018848A733666@in.WebX.maYIadrTaRb...
> Joe:
>
> I forgot to mention. Someone like me might rename a layer to upper case
before
> you reload, so...
> (setq str (strcase (strcat xname "|*")))
> (vlax-for x layers
> (if (wcmatch (strcase (vla-get-name x)) str)
>
> Naturally, I'm talking about a networked situation where XLOADCTL is set to 2.
>
> Actually, what if layers are renamed wholesale? Rather than names, might
their
> handles stick between loads?
> If so, that might change your approach just a tad.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> http://www.cadlantic.com
> Sea Girt, NJ
0 Likes
Message 8 of 8

Anonymous
Not applicable
Joe, did you ever get round to adding the DosLib dialog to the routine you posted a month or two back?? When i run that routine i get the following error message:
Command: ReloadXrefSymbology
Error: no function definition: VLAX-GET-ACAD-OBJECT; error: An error has
occurred inside the *error* functionno function definition: VLA-ENDUNDOMARK.

Any ideas??

Thanks, Simon.
0 Likes