TheSwamp
Code Red => VB(A) => Topic started by: jbuzbee on February 16, 2007, 01:12:07 PM
-
Will a dvb file created in ACAD2006 work in 2007?
-
yep, unless you have done something crazy :lol:
Post it and I'll try it for you
-
I had to change a reference for a DVB to work with Acad 2007: Autocad/Objectdbx Common 16.0 type library had to be replaced with Autocad/Objectdbx Common 17.0 type library.
-
One of the issues with having dvb files work across multiple versions is early binding. If you are going to utilize a specific type library other than the VBA or AutoCAD type libraries, if you do late binding, it will make the program more portable. Most type libraries allow you to select the base version and the OS will keep track of the latest version.
For example, if I wanted to get a reference to AutoCAD 2007 I could use
Set Acad = GetObject(,"AutoCAD.Application.17")
But if I want the code to run on any version, I would use
Set Acad = GetObject(,"AutoCAD.Application")
I hope that is clear as mud ...
-
Everyone thanks for the responses! I'm very new to VBA.
Keith, so instead of setting "hard" references in the Tools / References / dialog, I can(should) set them in a module?
Right now I have the ObjectDBX 16.0 type library referenced and in a module & use the following statement
Dim dbxDoc As AxDbDocument
So I should remove the reference and add the following:
Set dbx = GetObject(,"ObjectDBX") [don't know the right syntax here]
Dim dbxDoc as dbx.AxDbDocument
??
-
In short .. yes .. except you need to use "GetInterfaceObject" for the ObjectDBX library.
Thus .. as in this example, you need only run the application and not add any reference to the type library.
Sub Test()
Dim ACDbx As Object
Dim Block As AcadBlock
Set ACDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
ACDbx.Open ("c:\test.dwg")
For Each Block In ACDbx.Blocks
MsgBox Block.Name
Next
Set ACDbx = Nothing
End Sub
But ... the answer is not always that simple, because not all libraries work with all versions of AutoCAD, BUT if you set the reference programmatically, it will load the class from the current version on the computer and not try to load the one from the development computer.
Oh .. and you don't load the ObjectDBX object per 'se , you actually load the document interface, then open the document you want to manipulate.
-
thanks Keith - I'll give it a try! :wink: