Hi, I'm just starting to play with ObjectDBX. I've had joy in VBA, but I would much prefer to develop in VS for various reasons. Problem is that when I add the project reference to C:\Program Files\Common Files\Autodesk Shared\axdb17enu.tlb the path shows as "<The system cannot find the reference specified>". (That was adding reference from the COM tab, I get the same if I browse to it.
Do I need to register the .tlb or something?
You should use the .NET Interop assemblies provided. You can reference them from the ObjectARX SDK, or the versions installed to the GAC.
Thanks Stephen,
I'm pretty ignorant on GAC. As far as I can tell its somewhere under C:\WINDOWS\Microsoft.NET\assembly\?
I took a look in there (windows explorer) but can see anything vaguely Autodesky.....I'm guessing it's far more tricky than just copying in axdb17enu.tlb
What do you really want to do with ObjectDBX? If you want to use it in the way of VBA age, e.g. using AxDbDocuemt to access data in a drawing without opening it in the editor, then since you are using .NET (C# or VB.NET) there is not point to do that: Acad .NET API allows you to read an drawing into a Database object without opening it in editor. Well, uless you are doing external stand-alone app to automate AutoCAD.
Norman Yuan
... or doing an intermediate transition from VBA to VB.NET. I agree that going the full .NET route is better long term. However going the ObjectDBX route can leverage a lot of previously done VBA work and cut down migration time, which can be important if the tool needs to be working *now*. Not exactly optimal but tight schedules don't always allow for that.
So I'm back at this in a roundabout way but am hitting a wall.
I don't even care anymore if I'm accessing a drawing db directly - if I have to open and process each drawing fine but there's some fundamental (likely) basic step I must be missing. Using:
I have code like:
AcadApplication mAcadApp = (AcadApplication) Marshal.GetActiveObject("AutoCAD.Application");
...and it happily links to AcadApp, opens+saves+closes documents. As soon as I try doing anything useful though (even as simple as getting a modelspace.count) it spits the dummy:
'Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.Common.IAcadModelSpace'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C60BC8AF-58DA-4866-859D-22A7F61411DE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'
Why does mAcadApp think its a type System.__ComObject?
Stephen Preston suggested: "You should use the .NET Interop assemblies provided" - provided with what? I downloaded ObjectARX2008 and my project happily sets a reference to Autodesk.AutoCAD.interop and ....Common.
Is this the part where I need to pay Autodesk vast amounts of money?
I don't want to create a dll or .netload anything into acad - just trying to get an external app (ours) to play with Acad.
Help a brother out?
I feel the need to annul my overtones of frustration with a
The interop dll's Stephen referred to are in the dir where acad.exe is. You just need to reference them in your project. They describe the interfaces that the error mentioned. You may aslo need to include some 'using' statements, depending on the objects you are referencing.
In VBA terms, this is equivalent toTools>References and selecting a *.tlb. In your code, you could use CreateObject() and it would work, but without the tlb to tell the how the Object is formed, the compiler can't figure out what to do with it.
Cheers for the reply mate, but I get the same problem. I've got to abandon this approach; I need to deliver product and I've wasted over a day. My problem basically boils down to declaring a var of one type, but it thinks it's another:
Is this an out-of-process app? If so, you may want to have a look at the code here. Look at the the notes on registering for COM.
I found that yesterday. Kean is a god amongst men.
In desperation I randomly tried switching to different versions of the DLLs in the GAC - victory!!!!
"i've paid my dues....time after time....I've done my sentance....but committed no crime" etc etc.
Very. Happy. Camper.
Thanks for everyone's help.
I suppose having the right interops would help.
Can't find what you're looking for? Ask the community or share your knowledge.