.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simple image insert impossible?

10 REPLIES 10
Reply
Message 1 of 11
kstate92
640 Views, 10 Replies

Simple image insert impossible?

I'm trying to convert an existing VBA routine to a vb.Net dll.  One of the functions is inserting and scaling an existing tif image file into a blank AutoCAD 2010 drawing.  I've searched and found just a few examples, but they all seem horrifically complicated .  Am I missing the simple way of doing this, or is this an example of the seemingly massive learning curve of .Net that is beginning to remind me of my collegiate C class (shudder)?

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000
10 REPLIES 10
Message 2 of 11
chiefbraincloud
in reply to: kstate92

Well, If you stick to the COM API, the code will be almost the same as the VBA code. 

Dave O.                                                                  Sig-Logos32.png
Message 3 of 11
kstate92
in reply to: chiefbraincloud

I was dangerous/clueless enough in VB6/VBA, but in vb.net I am truly a noob.  Do you mean a COM reference such as ...\VBAServer\VBAServerx64.exe?

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000
Message 4 of 11
chiefbraincloud
in reply to: kstate92

No, I mean the AutoCAD COM libraries, instead of the Managed .NET References.  See image.

 

AcadComRefs.PNG

Dave O.                                                                  Sig-Logos32.png
Message 5 of 11
kstate92
in reply to: chiefbraincloud

Can't find the second oneUntitled.png

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000
Message 6 of 11
chiefbraincloud
in reply to: kstate92

Not sure why the name is listed that way, but it is the AXDBLib pointing to the file axdb18enu.tlb

Dave O.                                                                  Sig-Logos32.png
Message 7 of 11
kstate92
in reply to: chiefbraincloud

And now I get this:

 

Error 15 The project currently contains references to more than one version of Autodesk.AutoCAD.Interop.Common, a direct reference to version 18.0.0.0 and an indirect reference (through 'Autodesk.AutoCAD.Interop.IAcadApplication.ActiveDocument') to version 18.1.0.0. Change the direct reference to use version 18.1.0.0 (or higher) of Autodesk.AutoCAD.Interop.Common.

 

I tried a suggested work around by installing ObjectARX in this thread http://forums.autodesk.com/t5/NET/2011-Type-Libraries-Breaks-2010/td-p/2679224, and using those tlb files instead, but I cannot get past this duplication error.

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000
Message 8 of 11

Hi,

 

As you may notice, this is because your references are duplicated 🙂

 

First lets clean the house, go to your project properties, at references tab, then remove all AutoCAD.Interop references, including AutoCAD Type Library and ObjectDBX Type Lirabry.

 

Now add them from the proper place: ObjectARX SDK. Go to add reference, and instead using the COM tab, go to Browse tab and select from the ObjectARX SDK location, add only Autodesk.AutoCAD.Interop.dll and Autodesk.AutoCAD.Interop.Common.dll. Do not select the .tlb, as will be the same as add it from COM tab, which is not good.

 

Not that the ObjectARX have two folders: \inc-win32 and \inc-x64\. If you plan to reply your application on 32 bit select the first, if 64 bit select them from the second folder.

 

Finally, if you are developing for a vertical, such as Civil 3D, after doing the above, it is possible (likely) that when you add reference to a vertical .tlb, it will try readd AutoCAD reference, but again this is from .tlb which is not good - remove them again.

 

When you add the references from ObjectARX SDK you have more control over the version, so select the correct platform (32 or 64) and the minor version on a cycle that you want yo support (e.g. if you want to support 2010/11/12, use 2010 references).

 

Hope this help.

 

Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 9 of 11

Okay; with your instructions I got it to finally compile, though using .Net components for .COM functionality is still confusing to my tiny rat brain.  With a silly work around(text edit of the *.vbproj file) to allow AutoCAD to be launched for debugging this dll project (using Visual Basic 2008 Express), I now realize I have no idea to invoke this project from within AutoCAD.

 

So glad Microsoft decided to depricate VBA as so far, .Net is so much easier. #Sarcasm

 

But I do sincerely thank you for the help.

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000
Message 10 of 11

 

Hi,

 

Glad you are moving to .NET, I'm sure you will realize in time that this is much better than VBA

 

As you have a VBA project, have you looked at this material?

http://through-the-interface.typepad.com/through_the_interface/2010/04/translated-autocad-vba-to-vbn...

 

You may see at video above that for a regular VBA subroutine, you need to add a CommandMethod attribute with a command name. Once this is compiled into a DLL, call AutoCAD NETLOAD command and then you custom command will be registered in AutoCAD.

 

Also, the video come with a tool to help you, including the edition of the .vbproj to start it from Visual Express. Take a look, it worth it!

 

Regards,

Augusto Goncalves

Autodesk Developer Network

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 11 of 11

I'll definitely take a look.  Thanks again.

KState92
Inventor Professional 2020
AutoCAD Mechanical 2022.0.1
Windows 10 Pro 64 bit - 1903
Core i7-8700 32 GB Ram
Quadro P2000

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost