.NET

Reply
Valued Contributor
TickleMeElmo
Posts: 72
Registered: ‎08-18-2009
Message 1 of 11 (635 Views)

ObjectDBX reference

635 Views, 10 Replies
08-29-2011 11:53 AM

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?

Board Manager
StephenPreston
Posts: 362
Registered: ‎05-22-2006
Message 2 of 11 (614 Views)

Re: ObjectDBX reference

08-29-2011 04:39 PM in reply to: TickleMeElmo

You should use the .NET Interop assemblies provided. You can reference them from the ObjectARX SDK, or the versions installed to the GAC.

Cheers,

Stephen Preston
Autodesk Developer Network
Valued Contributor
TickleMeElmo
Posts: 72
Registered: ‎08-18-2009
Message 3 of 11 (609 Views)

Re: ObjectDBX reference

08-29-2011 04:45 PM in reply to: StephenPreston

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

*Expert Elite*
norman.yuan
Posts: 946
Registered: ‎04-27-2009
Message 4 of 11 (590 Views)

Re: ObjectDBX reference

08-30-2011 06:38 AM in reply to: TickleMeElmo

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.

*Expert Elite*
dgorsman
Posts: 5,057
Registered: ‎10-12-2006
Message 5 of 11 (572 Views)

Re: ObjectDBX reference

08-30-2011 12:00 PM in reply to: 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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Valued Contributor
TickleMeElmo
Posts: 72
Registered: ‎08-18-2009
Message 6 of 11 (456 Views)

Re: ObjectDBX reference

06-05-2012 04:36 PM in reply to: dgorsman

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:

 

  • VS2010 express
  • C#.net
  • Acad2008 (oh the shame)
  • Windows XP 32 bit

 

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 :catindifferent:

 

 

Distinguished Contributor
eljobe
Posts: 704
Registered: ‎01-24-2003
Message 7 of 11 (431 Views)

Re: ObjectDBX reference

06-06-2012 10:16 AM in reply to: TickleMeElmo

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.

Valued Contributor
TickleMeElmo
Posts: 72
Registered: ‎08-18-2009
Message 8 of 11 (423 Views)

Re: ObjectDBX reference

06-06-2012 11:01 AM in reply to: eljobe

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:

 

acaddoc.png

Distinguished Contributor
eljobe
Posts: 704
Registered: ‎01-24-2003
Message 9 of 11 (420 Views)

Re: ObjectDBX reference

06-06-2012 12:03 PM in reply to: TickleMeElmo

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.

Valued Contributor
TickleMeElmo
Posts: 72
Registered: ‎08-18-2009
Message 10 of 11 (418 Views)

Re: ObjectDBX reference

06-06-2012 12:09 PM in reply to: eljobe

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!!!!

woohoo.png

 

"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.

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community