TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AVCAD on June 13, 2005, 12:06:54 PM
-
Is there are routine out there that will do the following:
Detattch an xref in a drawing
Save the where and what rotation it was at
reinsert the xref
and restore th placement of that xref
And if so, Can it do multiple Xrefs in 1 drawing...basically all xrefs.
-
If you are wanting to reset the layers to match that of the Xref drawing, I do have a VBA macro to do that. That is essentially all yoy are doing with the re-inserting of them.
-
Unless I'm missing something, isn't that just reloading the xref?
-
Yes, but I can't give mine out.
Check your dxf values and set variables for them
(entget (car (entsel)))
Insertion point 10
Rotation angle 50? I forget.
Of course, Dommy's comment should be the same thing, unless you need these for a greater purpose than you've let on here.
-
I'm with Dommy on this one. Why not just unload the files, then reload when you want 'em back. All the layer controls remain set.
Some quickies:
(DEFUN C:xru ()
(command "-xref" "unload" (cdr (assoc 2 (ENTGET (CAR (ENTSEL "\N Select Element in XREF to UNLOAD "))))))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:xrd ()
(command "-xref" "detach" (cdr (assoc 2 (ENTGET (CAR (ENTSEL "\N Select Element in XREF to DETACH "))))))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:xre ()
(command "-xref" "reload" (cdr (assoc 2 (ENTGET (CAR (ENTSEL "\N Select Element in XREF to RELOAD "))))))
)
-
Just unloading the Xrefs wont change all the colors, or the Layer state according to t he master xref file.
Jeff may have what I am looking for. He was correct when saying all I want is to change the layer states of the master xref file.
If unloading a drawing that is xrefed already wont shut off the (lets jsut say) Doors layer if I had shut it off in the master xref file. IT will still keep the layer states that are current in that file.
Does that make any sense I think I lost my self.....
I would like to try out the VBA macro that Jeff uses. EMail it to me me or post it here please.
-
Ahh VISRETAIN.
-
Avcad,
I posted a zip file in The Lilly Pond (http://www.theswamp.org/lilly_pond/jeff_m/Xref_Sync.zip?nossi=1) with my routines. The lisp file will call the correct dvb file depending on the version of Acad you are using (or it is supposed to anyway). To use, make sure all 3 files are in the support search path, just load the lisp and type XREF_SYNC to run it.
Jeff
-
I am using ACAD Version 2004
I am getting an error and it is opening Visual Basic to fix it but I have no clue what to fix...
any help would be nice
Thanks!
-
What is the error?
What line is highlighted in the VBAIDE?
-
I am getting an error
You didn't like VISRETAIN?
(defun c:fixxrefcolors ()
(command "undo" "begin")
(setq fixedxref (cdr (assoc 2 (ENTGET (CAR (ENTSEL "\N Select XREF to Reset Layers "))))))
(command "-xref" "unload" fixedxref)
(setvar "visretain" 0)
(command "-xref" "reload" fixedxref)
(setvar "visretain" 1)
(command "undo" "end")
(princ)
)
(defun c:fxc () (c:fixxrefcolors))
-
(defun c:fixallxrefcolors ()
(command "undo" "begin")
(command "-xref" "unload" "*")
(setvar "visretain" 0)
(command "-xref" "reload" "*")
(setvar "visretain" 1)
(command "undo" "end")
(princ)
)
-
when I run the xref_sync command this is the line that is highlighted...
Dim dbxDoc As AxDbDocument
???? I have no clue what that means.. :?
-
I will have to play with that CAD. I never really played with the visretain options.
-
It's an ObjectDBX document. You'll need to add a reference to the AutoCAD/ObjectDBX Common Type library thru "Tools -> References" from the VBA editor.
-
The problem with changing VISRETAIN is that it affects ALL Xrefs you have in the drawing. If you only want to update the layers to match those in one Xref and you have 2 or more, VISRETAIN is NOT what you want. That is what led me to write the VBA macro.
AVCAD, sorry about that. I should have noted that since I don't have R2004+ I couldn't set the reference. Once the VBAIDE opens with the error, select the cancel/end button. Still in the VBAIDE, go to the Tools pulldown menu and select References... In the references dialog you will see an item near the top that says ObjectDBX Type 1.0 library(not found)...uncheck the box next to that; scroll down and find another ObjectDBX X.X Type Library, where X.X is a higher number than 1.0, and select it. Save and close. That should fix it.
-
The problem with changing VISRETAIN is that it affects ALL Xrefs you have in the drawing.
ummm... not in R2002. It only affects those you reload while it is off.
If you only want to update the layers to match those in one Xref and you have 2 or more, VISRETAIN is NOT what you want.
Gee, it works just fine for me, but I was making it even harder than it needed to be:
(defun c:fxc ()
(command "undo" "begin")
(setvar "visretain" 0)
(command "-xref" "reload" (cdr (assoc 2 (ENTGET (CAR (ENTSEL "\N Select XREF to Reset Layers "))))))
(setvar "visretain" 1)
(command "undo" "end")
(princ)
)
Now if you want to pick a bunch to reset try this:
(defun c:fxc ( / old setlgth co t2 temp blkname)
(command ".undo" "BEGIN")
(setvar "cmdecho" 0)
(setvar "visretain" 0)
(prompt "\N Select XREFs to Reset Layers ")
(setq
old (ssget)
setlgth (sslength old)
co -1
t2 "t"
)
(while (boundp 't2)
(progn
(setq
co (1+ co)
temp (entget (ssname old co))
blkname (cdr (assoc 2 temp))
t2 (ssname old (1+ co))
)
(command "-xref" "reload" blkname)
) ;; end progn
) ;; end while
(setq co (1+ co))
(setvar "visretain" 1)
(princ (strcat "\n FINISHED... " (rtos co 2 0) " XREFs Reset to original colors"))
(princ)
(command ".undo" "END")
(princ)
)
That is what led me to write the VBA macro.
Now VBA may work faster, but toggling VISRETAIN is working for me.
-
The problem with changing VISRETAIN is that it affects ALL Xrefs you have in the drawing.
ummm... not in R2002. It only affects those you reload while it is off.
That is what led me to write the VBA macro.
Now VBA may work faster, but toggling VISRETAIN is working for me.
OK, I'll admit I never tried changing VISRETAIN/unload/reload on individual xrefs. What I originally wanted was a way to update just the linetype or color of the xref layers, not necessarily the entire drawing's display. I guess it was for more of a specific purpose that I have migrated to general use.
-
What I originally wanted was a way to update just the linetype or color of the xref layers, not necessarily the entire drawing's display.
That's all it does, it only updates the display of the selected XREF, not the entire drawing. Or am I missing something?
I guess it was for more of a specific purpose that I have migrated to general use.
How much more specific than a selected XREF do you want to get?
-
That's all it does, it only updates the display of the selected XREF, not the entire drawing. Or am I missing something?
How much more specific than a selected XREF do you want to get?
The architect changes the linetypes to be used for some features on his plan. I have his drawing Xref'ed into mine with only specific layers thawed & on. To update the new linetypes using VISRETAIN means I must update the entire Xref in my drawing meaning I must go back and freeze/thaw & turn /on/off my specific layers. Using my macro I only update the linetypes.....period.
-
The architect changes the linetypes to be used for some features on his plan. I have his drawing Xref'ed into mine with only specific layers thawed & on. To update the new linetypes using VISRETAIN means I must update the entire Xref in my drawing meaning I must go back and freeze/thaw & turn /on/off my specific layers. Using my macro I only update the linetypes.....period.
Gee, had I just downloaded your function and run it, I'd have seen that. That's pretty cool Jeff, the only thing to make that slicker I could see is allowing multiple xref file selections.
-
That's pretty cool Jeff, the only thing to make that slicker I could see is allowing multiple xref file selections.
Thanks! Yeah, this was actually one of my first VBA applications...and I had no clue how to do that. Now that I know how to at least find a clue, maybe I'll go back and see if I can add the multiple files option.
-
That's pretty cool Jeff, the only thing to make that slicker I could see is allowing multiple xref file selections.
Thanks! Yeah, this was actually one of my first VBA applications...and I had no clue how to do that. Now that I know how to at least find a clue, maybe I'll go back and see if I can add the multiple files option.
Yeah well, don't break a neck on my account, I gripe if I was hung with a new rope.
-
Jeff,
I am in the same boat you are. I first receive a set of Arch files, clean them up and change the colors to specific color that our ctb file uses, thaw, off, and lock layers that we dont need. Then I xref the arch files to a "master xref" for our office.
Right now everytime I get updated drawings I have go through that process over and over again. If I just over wrote the old drawings with the new drawings and used the visretain option on my sheet files all the xref'ed layers would then take the architects colors and layers settings back.
I still havent gotten your program to work...actually I havent tried to fix it yet :wink:
we will see what happens.
-
AVCAD, sorry about that. I should have noted that since I don't have R2004+ I couldn't set the reference. Once the VBAIDE opens with the error, select the cancel/end button. Still in the VBAIDE, go to the Tools pulldown menu and select References... In the references dialog you will see an item near the top that says ObjectDBX Type 1.0 library(not found)...uncheck the box next to that; scroll down and find another ObjectDBX X.X Type Library, where X.X is a higher number than 1.0, and select it. Save and close. That should fix it.
OK I tried this but the references option is greyed out? :?
-
OK I tried this but the references option is greyed out?
I think that the references is only greyed out if you try to access it while the program is still running. Make sure to End the macro before editing. You may need to load the dvb manually since the lisp routine is supposed to unload it. To do that, before trying to run it type VBAMAN at the command prompt. In the dialog select "Load" and browse to the Xref_sync-2004.dvb file and load it. Now select the "Visual Basic Editor" button. In the VBAIDE you should have a pane on the left with any open projects, make sure that the Xref_sync is the one highlighted then set the references correctly and save.
If this doesn't work, maybe someone else with experience and 2004 can fix it up for you.