TheSwamp

Code Red => VB(A) => Topic started by: jbuzbee on February 16, 2007, 01:12:07 PM

Title: 2006 dvb in 2007?
Post by: jbuzbee on February 16, 2007, 01:12:07 PM
Will a dvb file created in ACAD2006 work in 2007?
Title: Re: 2006 dvb in 2007?
Post by: David Hall on February 16, 2007, 01:13:43 PM
yep, unless you have done something crazy :lol:

Post it and I'll try it for you
Title: Re: 2006 dvb in 2007?
Post by: havano on February 17, 2007, 03:41:55 PM
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.
Title: Re: 2006 dvb in 2007?
Post by: Keith™ on February 17, 2007, 06:14:49 PM
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
Code: [Select]
Set Acad = GetObject(,"AutoCAD.Application.17")

But if I want the code to run on any version, I would use

Code: [Select]
Set Acad = GetObject(,"AutoCAD.Application")

I hope that is clear as mud ...
Title: Re: 2006 dvb in 2007?
Post by: jbuzbee on February 19, 2007, 10:31:03 AM
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

Code: [Select]
Dim dbxDoc As AxDbDocument
So I should remove the reference and add the following:

Code: [Select]
Set dbx = GetObject(,"ObjectDBX") [don't know the right syntax here]
Dim dbxDoc as dbx.AxDbDocument

??
Title: Re: 2006 dvb in 2007?
Post by: Keith™ on February 19, 2007, 10:59:22 AM
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.
Code: [Select]
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.
Title: Re: 2006 dvb in 2007?
Post by: jbuzbee on February 23, 2007, 01:36:46 PM
thanks Keith - I'll give it a try! :wink: