TheSwamp
Code Red => VB(A) => Topic started by: Matersammichman on July 17, 2006, 03:55:42 PM
-
Can Design Center command be accessed through VBA?
If so, how?
-
Accessed how? If you just want to launch it via VBA you could always go with ThisDrawing.SendCommand "ADCENTER"
-
No, I want to dive deeper, like access the commands necessary to check xref data
-
If you want to interface with design center, I don't know but I have my doubts. If you want to recreate the functionality, sure.
-
Thanks Bob...
In a nutshell, what I would like to do is create an app where I can easily search all of the xrefs in a directory, and find out if they're still being used or not by files in the same directory. I can do it one at a time, but it sure would be nice to be able to batch process it so I can can the garbage quickly.
-
further hints, Bob?
-
yes but if you mean "some code", not right now. Right now in the world of Bob, it's 5:00am, I've had no coffee and I couldn't get me brain to code if I tried. Seems to me like a good way to start would be to flow chart it (always a good idea) or at least write down a where you are, where you want to be, then go in and fill in the steps it will take to get there. I would think about going at it something like this
[NotCode]
1. get a list of all drawings in a directory
2. open first drawing in list
2a. If you don't want them to open in autocad, look into ObjectDBX (http://www.theswamp.org/index.php?topic=6697.0)
3. check drawing for xrefs
4. put list of xrefs into an array
5. close drawing
6. For each remaining drawing in list
7. open drawing
8. check for xrefs
9. add each xref to the array, checking for duplicates as you go
10. close drawing
11. next drawing
12. compare original drawing list to list of drawings that are xreffed into drawings
13. report the ones that aren't used.
[/NotCode]
-
I wrote this some time ago. Make a list of files with full path and save as a text file. (mj.txt in the example below). Of course you will have to modify some of the code to fit your environment.
Option Base 1
Sub BlockReport()
Dim Filename As String
Dim F As Integer
Dim G As Integer
Dim Block As AcadBlock
Dim BlockType As String
'open files
Close
F = FreeFile()
Open "w:\a\sheet\mj.txt" For Input As #F
G = FreeFile()
Open "w:\a\BlockReport.txt" For Output As #G
Do While Not EOF(F)
Line Input #F, Filename
ThisDrawing.Application.Documents.Open Filename, ReadOnly
For Each Block In ThisDrawing.Blocks
If Left(Block.Name, 1) = "*" Then
'dimension: do nothing
Else
BlockType = "BLOCK"
If Block.IsLayout Then BlockType = "LAYOUT"
If Block.IsXRef Then BlockType = "XREF"
Print #G, Block.Name; Chr$(9); ThisDrawing.FullName; Chr$(9); BlockType
End If
Next Block
ThisDrawing.Application.ActiveDocument.Close , savechanges = False
Loop
Close #F
Close #G
Debug.Print "DONE"
End Sub
-
Mike,
Thanks, that's good for finding out what blocks are INSIDE a dwg, but what I'm looking for is finding out from witin a dwg, what other dwgs it's xref'd out into. I have a longhand way through Design Center, but it's laborious and slow.
-
There's only one way possible to find what drawings a drawing is xreffed into and that is to open the drawings and check. Design center does it, the xref manager does it, you will have to do it. When you xref a drawing in, the drawing is not modified to show that it has been xreffed. I know it's not what you want to hear but it is the way the world works.
-
http://www.ellenfinkelstein.com/autocad_tips_find_xrefs.html
-
and?
-
Just sharing what info I have on the subject.
Did I say something wrong?
-
No, sorry, I guess that did come off as pretty crappy. I was just asking what you were showing with that. Is that what you are wanting to do? If so, the steps I gave you with some additional fleshing out will get you there. The code Mike posted will help with it.