TheSwamp
Code Red => VB(A) => Topic started by: Keith™ on November 24, 2003, 06:51:54 AM
-
Ok all you pond scum....thats a little higher than the bottom dwellers for all of you lacking sufficient knowledge of a watery ecosystem, we will discuss what an ecosystem is later, it doesn't really matter right now.
What does matter is that I need to put together a program that will open 4000 drawings in succession, spread out in various folders, then remove and replace or redefine a nested block, then remove or rename an existing layer, finally purge any extraneous information and save the drawing. I already have a good start with a program that will open and close all drawings in a specified folder, but what I was wondering is:
Should I attempt to redefine the block within the program or in the interest of widespread usability, should I make a form that asks what block to replace and let the user select an existing block from the hard drive. Either way, I need for this to be hands free after running the program. Since VBA can run across multiple drawings it would be my language of choice.
-
That fastest and easiers way would be to hard code the block names into your program.
If you have the source, you can always change them later if they change.
-
Keith, did you ever get into ObjectDBX? I understand that it can be written from vba and it sounds like as long as you don't need a selection set, you can do this. I think I have a file that was given me that is ODX. I'll post it so you can look at it.
-
That was my thinking, but I was also considering whether this would be a program that would be used once or many times.
So all of you coders out there, lets see what we can come up with.
This is the base that I have:
Sub GeneratePreview()
Dim CurrentDwg As AcadDocument
Dim File As Variant
Dim Folder As String
ThisDrawing.SetVariable "Acadlspasdoc", 0
'the ReturnFolder command is externally defined and pops up a window alowing the user to browse for a folder
Folder = ReturnFolder.ReturnFolder("File location to generate previews: ")
File = Dir(Folder & "\*.DWG")
While File <> ""
Set CurrentDwg = Application.Documents.Open(Folder & "\" & File)
CurrentDwg.Activate
Application.ZoomExtents
CurrentDwg.Close True
Set CurrentDwg = Nothing
File = Dir
Wend
ThisDrawing.SetVariable "Acadlspasdoc", 1
End Sub
I am now thinking of a way to open subfolders and their drawings, although I am not really worried about that at the time.
As I progress I will post more info.
-
Have a look here (http://theswamp.org/swamp.files/Daron/bosivBlockUpdate.dvb). This was written for ODX to update a block in multiple drawings. I never used it, but it might give you an idea of how to write your code. You would need to set a reference to ObjectDBX Type 1.0. I can't find one in 2004, but I know it's there in 2002. The thing I like about ODX is that you can't open the drawings to update them. I've read that it is faster. It makes sense to me.
-
Thx I will take a look.