Friday, January 28, 2005

Requirements

Hello,

Prior to begin the course I would like to list what are the requirements to create, compile and use ObjectARX applications.

I will use the most recent version that is ObjectARX 2005. Most of features presented will be compatible to previous versions (I will consider release 2000 and above).

What you will need:
  • AutoCAD 2000,2000i and 2002 (and verticals): ObjectARX 2000 and VC++ 6.0;
  • AutoCAD 2004, 2005 and 2006 (and verticals): ObjectARX 2004 and VC.NET 2002 (7.0);
  • AutoCAD 2007, 2008 and 2009 (and verticals): ObjectARX 2007 and VC.NET 2005 (8.0);
  • AutoCAD 2010, 2011 and 2012 (and verticals): ObjectARX 2010 and VC.NET 2008 (9.0);
  • AutoCAD 2013 and 2014 (and verticals): ObjectARX 2013 and VC.NET 2010 (10.0);
*** Visual Studio 2010 and 2012 does provide the Platform Toolset capabilities allowing you to use their IDE but compile the code with previous version. Note that this is possible only if you have the corresponding platform core compiler version installed at your machine. The advantage of this feature is to be able to centralize multiple project versions into the same IDE.

You may download AutoCAD trial versions from Autodesk web site (www.autodesk.com).
To download ObjectARX (for free), go to www.objectarx.com (this will redirect you to the right page at Autodesk's web site).
Once you have the above products, proceed with the installation:
  • Install AutoCAD (full option recommended);
  • Install Visual C++;
  • Install (just need to extract) ObjectARX to your computer;
On the next post I will explain how to install the ObjectARX Wizard tool.

Further information about Microsoft Visual Studio versions:
Product nameCodenameInternal
version
Supported .NET
Framework versions
Release date
Visual StudioN/A4.0N/A1995-04
Visual Studio 97Boston5.0N/A1997-02
Visual Studio 6.0Aspen6.0N/A1998-06
Visual Studio .NET (2002)Rainier7.01.02002-02-13
Visual Studio .NET 2003Everett7.11.12003-04-24
Visual Studio 2005Whidbey8.02.0, 3.02005-11-07
Visual Studio 2008Orcas9.02.0, 3.0, 3.52007-11-19
Visual Studio 2010Dev10/Rosario10.02.0, 3.0, 3.5, 4.02010-04-12
Visual Studio 2012Dev1111.02.0, 3.0, 3.5, 4.0, 4.52012-09-12
Visual Studio 2013Dev1212.02.0, 3.0, 3.5, 4.0, 4.5, 4.5.1Upcoming


Cheers!

105 comments :

maq said...

I have the folowing question..
Is this software "Visual C++.NET 2003 Standard" ready to create ARX programs together with ObjectARX?

Fernando Malard said...

Hello maq,

Officially only the Visual Studio .NET 2002 is supported which uses the .NET Framework 1.0 and MFC 7.0

This applies to AutoCAD 2004,2005 and the brand new 2006.

There are some tricks over the Internet to make VS.NET 2003 generate compatible code with 2002 but I really recommend you to use VS.NET 2002.

If you already purchased the 2003 version just request a downgrade from Microsoft.

Regards.

Anonymous said...

Hi Fernando, great website! My question is this, is there a difference between Visual Studio .Net 2002 "standard" and "professional"? Then which one should I get, to learn programming and customize arx for autocad? Thanks!

Fernando Malard said...

Hi there,

Regarding to ObjectARX requirements the Visual Studio .NET 2002 Standard, Professional, Enterprise Developer, Enterprise Architect and Academic will generate the same results.

Basically, the differences among them are only about development tools included into the package.

For more information, please take a look at:

http://msdn.microsoft.com/vstudio/previous/2002/overview/academic/features/comparison.aspx

Regards,
Fernando.

Anonymous said...

I have question:
Does VISUAL STUDIO 2003 be suitable to ACAD 2005 ?

Fernando Malard said...

Hi maq,

VS 2003 (any flavor) is not officially compatible with AutoCAD 2004, 2005 and 2006. There are some tricks to allow it to generate compatible code but I really would suggest you to avoid these tricks.

If you already have purchased the 2003 version you need to request a downgrade from Microsoft which is free and will charge you only for the media set.

Regards,
Fernando.

Anonymous said...

How can I downgrading MS VISUAL STUDIO 2003 to fit version for ObjectARX for ACAD2005 and 2006 ? I can't find it in Microsoft web site.

Fernando Malard said...

Hi,

You will need to contact Microsoft support by phone and request instructions on how to proceed. As far as I know you will pay only for the shipment and media.

Regards,
Fernando.

Tamas Veres said...

Hi Fernando!
I like this page too.
I need to implement an application for AutoCAD 2004, but I'm still using VS6.0 SP5, (because VS .NET 2002, 2003 and the 2005 beta was producing strange runtime errors when I was using mixed sources - old application in C and my C++ code.)
What do you think, is it possible to use VC6 and its MFC with "ObjectARX for AutoCAD 2002" to develop an app for ACAD2004?
Thanks in advance
Tamas

Fernando Malard said...

Hi Tamas,

No, there is no way to load an application compiled with ObjectARX 2002 inside AutoCAD 2004 and above.

You need to use VS.NET 2002 (SP0) to be 100% compatible with AutoCAD 2004 and above.

Some people use some tricks to use VS.NET 2003 to build applications compatible with AutoCAD 2004 but it is not supported by Autodesk.

There are several changes in MFC, ATL and inside the ObjectARX SDK that are probably causing the problems you report. The best thing to do is to migrate your applications step by step and fix all problems.

Regards,
Fernando.

KewlToyZ said...

I have been looking around on the web for a download of vc++ 6.0 but it appears we cant even buy this anywhere anymore? I bought the 2003 version fairly cheap in 2003 but I dont want a bunch of error ridden fixes just to get started with arx lol. Is there an actual download available that you know of without spending hours upon hours trying to virtually create something similiar?

Fernando Malard said...

Hello KewlToyZ,

If you are planning to develop for AutoCAD 2004,2005 or 2006 you can buy a VS2003 or VS2005 and require a downgrade license from Microsoft.

Regards,
Fernando.

Anonymous said...

I am using ADT 2005. Which version of C++ do I need. I have version 6.0 but I think I read somewhere that the OBJECT ARX.sdk will only work with C++ version 8.0. Is this true or can I get by with versionb 6.0? Also which version of Visual Studio do I need? Thanks for the help.
David W Estridge
dwestridge@comcast.net

Fernando Malard said...

Hi David,

ADT 2005 is based on AutoCAD 2005 so it will require Visual Studio 2002 (7.0) and at least ObjectARX 2004.

ADT also requires its own specific framework which is called OMF (Object Modeling Framework). This framework will allow you to create and manage specific ADT objects and entities.

Your VS2002 projects will need to use at least ObjectARX and OMF SDK if it will deal with ADT objects.

IMPORTANT: If your ObjectARX application will only use native AutoCAD features and nothing from ADT API you can compile your projects without ADT headers and libraries. It will load fine on ADT and on any other AutoCAD based vertical.

NOTE: ADT OMF SDK is only available to Autodesk ADN members.

Hope this help.
Fernando.

Anonymous said...

I'm sorry Fernando. I am using ADT 2006! NOT 2005. I hit the wrong key on my keyboard. Can go over the requirements that will be compatible for ADT 06 real quick please. I am very sorry for the inconvenience. Thanks
Dave
dwestridge@comcast.net

Fernando Malard said...

Hi Dave,

ADT 2006 will require the VISUAL STUDIO 2005 version and ObjectARX2005 SDK.

All other remarks of my previous post are also valid to 2006. There is also a OMF 2006 SDK you need to use to be able to access specific ADT features.

ObjectARX application compiled with 2005 are NOT binary compatible with 2006 and vice-versa.

Regards,
Fernando.

Anonymous said...

Hello Fernando,
Can I use Microsoft Visual C++ express?
Thanks

Anonymous said...

Hello Fernando,
Is it possible to use Microsoft Visual C++ Express?
Thanks

Fernando Malard said...

Hello,

Check this article from Kean Walmsley:

http://through-the-interface.typepad.com/
through_the_interface/2006/07/
getting_the_obj.html

Regards,
Fernando.

satya said...

I am planning to program with objectARX for autocad 2006. what other requirements do i need to install.
thanks for the service

satya said...

I am planning to program with objectARX for autocad 2006. what other requirements do i need to install.
thanks for the service

Fernando Malard said...

Hello satya,

AutoCAD 2006 requires:

- ObjectARX 2004, 2005 or 2006;
- Microsoft Visual C++ 2002 (7.0);

Note that you are planning to use some features existing only on AutoCAD 2006 you will need to use ObjectARX 2006. In other hand, if you would like to make your application compatible with 3 versions (2004,2005 and 2006) you need to use ObjectARX 2004.

Regards,
Fernando.

Valdemar said...

Hello Mr. Fernando,
Is there any access to ADT 2006 & LDT 2006 objects in ObjectARX 2006. I need to create parametrical foundation as bearing structure and to compute volume of soil in quadrant between two layers.

Fernando Malard said...

Hello Valdemar,

ADT has its own SDK which works together with ObjectARX. It is called OMF and is available only to ADN members.

This way you need to signup ADN membership or use only AutoCAD level entities in your application.

Regards,
Fernando.

Đào Anh Vũ said...

Hi Fernando,
Your page's so cool.

I'm using VC++6.0 and I want to develop ObjectARX for AutoCad 2000.
Have I do anything different from your lessons?

Thank in advance.

Fernando Malard said...

Hi,

ObjectARX 2000 will be restrict as AutoCAD 2000 is.
AutoCAD 2000 was the first version to provide MDI support.

I'm not 100% sure what will work on 2000 but the major part of this Blog's concept applies to 2000 and some part of the code should work too.

Regards,
Fernando.

iain9876 said...

Hi there,

I have a load of object ARX files I have found. I would like to look at them. Is there anyway to get a reader or some simple way of viewing the files>?

Fernando Malard said...

Hi iain9876,

ObjectARX unmanaged modules are C++ binary code which cannot be easily reversed engineered. If you have the PDB (program database) of this module you could try some third-party disassembler applications.

The better option is to find the author and request its source code if he can provide.

Regards.

Guillaume said...

Hi, I'm using Autocad 2004 and I'm trying to find Objectarx 2004. Where can I download objectarx 2004? Does Objectarx2005 work with autocad 2004?

Thank you!

Fernando Malard said...

Hi Guillaume,

The ObjectARX 2004 SDK is made available through the following Autodesk FTP site:

ftp://ftp.autodesk.com/WebPub/autocad/oarx/

Regards,

Fernando Malard said...

...and regarding to your question about 2005 it contains features specific for 2005 so it cannot fully run inside 2004.

Regards,

Antonio said...

Hello from Italy, Fernando! My question: I’m using Architecture 2008 (i.e. AutoCAD 2007, I think), and I want to study arxprogramming. Some years ago I have bought on ebay Visual Studio .net 2002: is it the right version?

Fernando Malard said...

Hi Antonio,

Autodesk Architectural 2008 is based on AutoCAD 2008. Due that it requires Visual Studio 2005 without Service Pack.

VS2002 works only for versions 2004,2005 and 2006.

Best regards,

Antonio said...

Thank you for the quick reply! So now I have a second question. I have only one official copy of AutoCAD (Architecture 2008), which I use in my professional business. I was thinking I could buy a new hard disk and install there a previous trial version of autocad, together with my visual net 2002. Is an arx2005 application compatible with autocad 2008?

Fernando Malard said...

Hi Antonio,

No, ARX2005 will not run inside 2007,2008 and 2009. There is a binary break. You need to recompile your code inside VS2005 and this will require your code to be UNICODE compatible.

Basically if you need to support both 2004,2005,2006 and 2007,2008,2009 families you will need to live with VS2002 and VS2005 in parallel. In this case, I would recommend ObjectARX2004 for VS2002 and ObjectARX2007 for VS2005.

There are some "hacks" over the Internet to avoid this problems but they are not supported by Autodesk so there is no guarantee they will not cause any problems to you.

Sorry about the bad news.
Regards,

Chty said...

Hello,

I want to know if the examples which are provided in arx lib can be compiled with VS2008 ?
Because I've tried to do this but I have the following error : "Error 8 fatal error LNK1104: cannot open file 'mfc80u.lib'"

regards,

William

Fernando Malard said...

Hello William,

VS2008 is not compatible with ObjectARX 2007,2008 and 2009.

You need to use VS2005 (without SP1) to be fully compatible with these 3 versions.

Regards.

Chty said...

thank's for the answer, but why "without SP1" ?

Fernando Malard said...

William,

Because SP1 make some changes into some libraries which may cause problems with AutoCAD.

In fact you can use SP1 but ONLY with ObjectARX 2009. If you plan to build based on ObjectARX 2007 or 2008 the only supported version is VS2005 without SP1.

Regards.

Chty said...

Hello,

It's strange, I've been using ARX 2006 & ARX 2008 with Visual Studio 2008 without any problems. (I didn't know the requirements)

Fernando Malard said...

Hi,

You will probably run into problems because they are not compatible. There are some hacks over the Internet but they are not 100% guarantee to work.

Check your compiled module dependencies with the following tool:

C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\Depends.exe

Open your compiled ARX or DBX module inside this applicatio and check the libraries it depends on.

Probably if you deploy your product to a machine without VStudio something will happen.

Regards.

rickjkelley said...

Since Microsoft Visual Studio 9.0 has been out, there isn't a depends.exe file in the subfolders.

I copied and renamed the mfc90u.lib and the mfcs90u.lib to mfc80u.lib, and mfcs80u.lib. Then I compiled the clones objectarx sample. When I used the Arx command to load the clones.arx object, it complained of not being compatable, but went ahead and loaded it. You cannot use clone1, or clone2, but will use clone3 command correctly.

Anonymous said...

For the clones.arx compilation, I just copied and renamed two files needed called mfc80u.lib, and mfcs80u.lib from the latest VS 9.0 libs called mfc90u.lib, and mfcs90u.lib. Recompiled them and loaded it using the ARX command. When you load it, the message will come up saying that it is not compatable with 2007, but will load it anyway. Clone1, and clone2 seem not to work, but clone3 will. (This is the one that I was interested in anyway).

Fernando Malard said...

Hello,

I really don't recommend you to do that. The compatibility is not related only to those libraries. You may run into trouble due several changes on the MFC and CRT libraries.

If you already have purchased the VS2008 request a downgrade from Microsoft. They probably will charge you only by the DVD mailing.

Remember, only because it loads does not means it will work.

Regards,

Anonymous said...

Hi,

Is there any chance that this ObjectARX can work with C#?

thank you,

Fernando Malard said...

Hello,

There is a specific .NET AutoCAD API which allows you to do almost everything you can do with C++ ObjectARX.

In fact the way and the code itself is different and the way to use the features may also vary a little bit.

.NET does not allow you to develop custom objects so you still need C++ ObjectARX to do that.

Regards,

Anonymous said...

Hi.

First question: Is AutoCAD 2010, ObjectARX 2010 and VS 2008 SP1 a compatible environment?
Second: Is there any tutorial like this (ObjectARX&Dummies) for these latest versions? If not, could I use this tutorial?

Thanks in advance and best regards

Zix

Fernando Malard said...

Hello Zix,

Yes, to build AutoCAD 2010 compatible product you need to use ObjectARX 2010 and VS2008 SP1.

Pay special attention to the platform (x32 or x64) which will require the proper SDK files to compile as the AutoCAD 2010 comes in two platforms too.

This Blog's tutorials should apply to 2010 release with a few modifications due the SDK changes which you can verify at its Migration Guide.

Try to just open the projects inside VS2008 follow VS migration wizard and try to compile. If some error appear, go to the Migration Guide and check for the corresponding changes. For the custom entity, the major problem will be the new subXXX() methods like subWorldDraw() which replaces the current worldDraw(). For that a simple #define may do the trick.

Regards.

Anonymous said...

Thanks for a quick response!

Best regards

Zix

Anonymous said...

Hi Fernando.

Regarding my question about the environment: is it possible to work with VS 2008 SP1 Express Edition or it has to be full version? I have Express Edition and for example I don't have possibility to choose MFC DLL under C++ projects.

Thanks

Zix

Fernando Malard said...

Zix,

Express edition does not support MFC. There are some workarounds but you will need to use external resource editors, modify used libraries, etc. If you need to use it, go to the Standard version.

Sorry about bad news.

Anonymous said...

Hello.

As far as concerned these subXXX() functions from post above, what should be exactly after #define?

thank you

Fernando Malard said...

Hi,

This will depend on the platforms you will target.

If your product will be only focused on the 2010 you just need to replace the non-sub method by the corresponding sub. Take a look at the Migration Guide inside ObjectARX 2010.

If you plan to target both 2010 and previous family (2007,2008 and 2009 which require a VS2005 project) you will need to create a #define to change the name of these SubXXX methods depending on the project you are compiling.

Something like that:

#ifdef MY_VS2005
#define subXXX XXX
#endif

This way, when compiling inside VS2005 you will use the old style names and when compiling the same code inside VS2008 it will not change the names. Note that "MY_VS2005" is a pre-compile symbol you should define yourself inside the VS2005 project settings.

Good luck.

Anonymous said...

Hi Fernando.

Where is Migration Guide located? I simply couldn't find it.

Regards

Fernando Malard said...

Hi,

ObjectARX Migration Guide:
arxxmg.chm

x64 Migration Guide:
arxmgr.chm

Both inside \ObjectARX 2010\docs

For the previous SDKs these document's name may vary.

Regards.

dincer said...

hi Fernando;

I am dincer from Turkey and have a question .
what can you say about DOTNETARX? Where can we find documents, source codes and such a blog for DOTNOTARX?

Thank you

Fernando Malard said...

Hello dincer,

The best resource for ObjectARX .NET programming is this from my friend Kean Walmsley:

http://through-the-interface.typepad.com/

Regards,

Estudiante said...

Fernando,

I have Windows 7 and I'm testing the beta version of VS2010, is there way to make it work with ObjectARX 2010? I tried it but it's now telling me:

LINK : fatal error LNK1104: cannot open file 'mfc90u.lib'

What do you suggest??

Fernando Malard said...

Hello Estudiante,

I have not tested this environment yet but I'm afraid you will need to make some unsupported tweaks into the VS libraries.

In regards to C#, probably it will work with VS2010.

Regards,

Shahid said...

can I use Visual C# (sharp) instead?

Fernando Malard said...

Shahid,

You can but only for C# programming. C++ will require Visual C++.

Regards.

Aurore said...

Hello,
I'm using Autocad 2007 and I need to compile a program I just received. The problem is : I've been looking everywhere, I can't find any website where we can download VS2005...

Could you help me, or tell me if it's possible to downgrade a more recent version ?

Thanks !

Fernando Malard said...

Aurore,

You will need to call Microsoft and see if they can provide you VS2005/VS2008 if you buy a version of VS2010.

If this ObjectARX application is targeting AutoCAD 2010,2011 and 2012 you should use VS2008. This will require you to convert some things inside your project.

If you are targeting AutoCAD 2008/2009 thus you will need VS2005 indeed.

Good luck.

Miguel Angel Armenta Lopez said...

hello, i am compiling a proyect VC++ 6.0 for AutoCad 2012 with VS 2010 and ObjectARX 2012, the ARX loads ok, but the commands do not work, i list th commands and the names are in Chinesse characters, help me please
PD: Too Im try to compile it in VS 2008 SP1 and ObjectARX 2010 with same result...

Fernando Malard said...

Miguel,

Did you try to encapsulate your string messages with the _T() macro?

"Your Message"

to

_T("Your Message")

This will use the string as UNICODE symbol.
This also requires you to port your app to UNICODE which requires some modifications described into the ObjectARX documentation.

Regards,

Anonymous said...

Hi, i get the error LNK2019: unresolved external symbol "class AcDbObjectId __cdecl createLine(class AcGePoint3d,class AcGePoint3d,char *)" (?createLine@@YA?AVAcDbObjectId@@VAcGePoint3d@@0PAD@Z)
what does it mean? how can I resolve it?

Fernando Malard said...

Did you create the project using ARXWizard?
Usually this indicates you are missing the ARX libraries or the createLine() method body is not being linked with your code.

Can you provide more details about your project?

Anonymous said...

Hello, Fernando:
how can i debug my arx with VS 2010 and AutoCAD 2012? Im trying to do it, but VS 2010 say me there is not source code available and the arx do not appear in the stack frame, I put in the start up suite...
The break points do not activate because can't load symbol for the document...
Thanks in advance

Fernando Malard said...

Hello,

Here is my checklist:

- Your code should be compiled as DEBUG;
- The main ARX module should be the current/active project at the VS project tree;
- VS2010 should have SP1 installed;
- You need to load into AutoCAD the same binary file you have just compiled in DEBUG mode;

Another thing you can try is to debug via binding. You compile your project as Debug but do not start AutoCAD from VS. Manually open AutoCAD, load your ARX module and return to VS. There, into the Debug menu, you will find ATTACH command which will show you a dialog with current running processes including acad.exe. Select this process and it will dynamically bind your source code with the runtime DLL.

Please let me know if any of these tips did solve your problem.

Best regards,

Anonymous said...

Hi Fernando!
Well, i have installed SP1, now i'm trying to compile with DEBUG but i get the error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: char * const & __thiscall std::_Vector_const_iterator >::operator*(void)const " (??D?$_Vector_const_iterator@PADV?$allocator@PAD@std@@@std@@QBEABQADXZ)
Without DEBUG all is ok!
I have these libraries in linker input:
acad.lib
acapp.lib
acismobj18.lib
AcMPolygonObj18.lib
acui18.lib
adui18.lib
AdApplicationFrame.lib
aseapi18.lib
asiapi18.lib
acdbmgd.lib
acge18.lib
acgiapi.lib
acdb18.lib
axdb.lib
odbc32.lib
odbccp32.lib
rxapi.lib

Fernando Malard said...

Hello,

Have you checked if your _DEBUG symbol is being properly handled into StdAfx.h?

As this symbol affects how MFC libraries are compiled you need to wrap the includes with a #if statement like this example (see how the BOLD definitions wrap the includes):

_________________________________


#if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
#pragma message("Building debug version of this module to be used with non-debug/Prod AutoCAD")
#define DEBUG_THIS_ONLY
#undef _DEBUG
#endif


#pragma warning(disable: 4275)

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include // MFC core and standard components
#include // MFC extensions

#ifndef _AFX_NO_OLE_SUPPORT
#include // MFC OLE classes
#include // MFC OLE dialog classes
#include // MFC OLE automation classes
#endif // _AFX_NO_OLE_SUPPORT


#ifndef _AFX_NO_DB_SUPPORT
#include // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT

#ifndef _AFX_NO_DAO_SUPPORT
#pragma warning(push)
#pragma warning(disable:4265)//disable missing virtual destructor warning
#include // MFC DAO database classes
#pragma warning(pop) // C4265
#endif // _AFX_NO_DAO_SUPPORT

#ifndef _AFX_NO_AFXCMN_SUPPORT
#include // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include
#include "AcadStdafx.h"


// Turn on the _DEBUG symbol if it was defined, before including
// non-MFC header files.
//
#ifdef DEBUG_THIS_ONLY
#define _DEBUG
#undef DEBUG_THIS_ONLY
#endif


Hope it helps you.
Regards,

Anonymous said...

Hi, Fernando: I get this error trying to write xdata to an acad object: Unhandled Exception in 0x76e82cc7 in acad.exe: 0xC0000005: Access violatios reading at 0x289ee5bf. Funny thing that sometimes fails and sometimes not!
WHat may be happenning??
Thanks in advanced...

acdbRegApp(XDataName);
pRb =acutNewRb(AcDb::kDxfRegAppName);
AcDbObjectId objId;
AcDbEntity *pEntity;

if (acdbOpenObject(pEntity, objId, AcDb::kForWrite, false) != eOk)
acedAlert(_T("Error: Can´t open object!"));
else {
pEntity->upgradeOpen();
if (pEntity->setXData(pRb) != Acad::eOk)
acedAlert(_T("Error: Can´t add XData!"));
pEntity->close();
acutRelRb(pRb);
}
Sometimes fails in pEntity->setXData and sometimes fails in pEntity->close()

Fernando Malard said...

Hello,

The problem seems to be related to the upgradeOpen() method call.
This method is only intended to be used when you have an entity opened for READ and want to enable WRITE capability to it.

At your code you opened the entity for WRITE so you don't need to call upgradeOpen(). As a matter of fact, the ideal scenario would be changing the open to READ and keep the upgradeOpen() call.

Note that every open operation in WRITE mode will trigger a lot of reactors inside AutoCAD database so it is way slower than a READ open. Only use WRITE mode when you are sure the entity is going to be changed. If any test needs to be done prior to the modification you can do the test in READ mode.

Another minor issue is that your call to acutRelRb(pRb); is inside the ELSE so if your entity cannot be processed the resbuf is not being cleaned up. The following two calls in your code:

acdbRegApp(XDataName);
pRb =acutNewRb(AcDb::kDxfRegAppName);

...should be inside the IF because if you don't open the entity why use them anyway?

Hope it will fix your strange behavior.

Best regards,

Anonymous said...

Hello, Fernando!
I get this error executing an arx application: Unhandled Exception 0x77303873 in acad.exe: 0xC0000374: This in free.c in:
#endif /* _WIN64 */
{
retval = HeapFree(_crtheap, 0, pBlock); // Here the error

if (retval == 0)
{
errno = _get_errno_from_oserr(GetLastError());
}
}

What is can be it??

Anonymous said...

Hi Fernando!

I changed my code just you say and the exception error still be present.
NOw, fails in acutRelRb() function too:
Unhandled Exception in 0x0f477750 in acad.exe: 0xC0000005: Access violation reading at 0x0000001a.
It will be problem with AutoCad, MSVC++ or ObjectARX, or other anything???

Fernando Malard said...

Hello,

To better understand the problem I need more info about your installed software and versions.

What version of VS are you using?
Does it have the latest updates?
What version of AutoCAD and ObjectARX?
Is it 64bit, 32 or both?

Thank you,

Anonymous said...

Well, i´m using Visual Studio 2010 Sp1, ObjectArx 2012, Autocad 2012 SP2 in win 7 Ultimate SP1 32 bits

Fernando Malard said...

Ok,

Without seeing your complete code is difficult to point the cause of your exception.

As the method acutRelRb() is responsible for deallocating the memory used by a resbuf object.

Not sure how you created your VS Project but if it was done manually check the Project type: /MT
(Multi-threaded) as opposed to /MD (Multi-threaded DLL). You need to use the latter.

Try to improve your debug exception range by enabling some additional exceptions at the Debug > Exceptions... dialog. Debug your app and when ready to call your command go back to VS and enable some additional exceptions (remember to reset them after you finish the debug with the RESET button). More info about it here:

http://truncatedcodr.wordpress.com/2011/04/04/visual-studiodebugexceptions/

If none of those things worked, try to create a new blank project with ARXWizard and test portions of your code there to validate each routine.

Sometimes in AutoCAD an object left opened will crash later when you reuse it or its container so the code line where the crash occurred doesn't necessarily mean that the problem is there.

Tell me how it turns out.

Regards,

Anonymous said...

Hi

Wonder if you can advise on how to get AutoCAD 2009 working with VS 2010?

I also have VS2008 installed but obviously I wish to use 2010 if possible.

Regards
Malcom

Fernando Malard said...

Malcom,

Did you check this article I published some time ago?

http://arxdummies.blogspot.com.br/2010/04/visual-studio-2010.html

Regards,

Anonymous said...

HI, Fernando!
Is There some way to call a lisp function from an ARX??

Thanks!

Fernando Malard said...

Hello,

Basically you can send commands to AutoCAD as LISP expressions.

There are several ways to do it but it will depend on what exactly you want to do.

Take a look at this article:

http://through-the-interface.typepad.com/through_the_interface/2006/08/techniques_for_.html

Note that once you register your own command it can be called the same way AutoCAD native commands can.

Regards,

Anonymous said...

Hi, Fernando!
Well, really i want to call a function in C++ code from visual lisp code...

Fernando Malard said...

Hello,

Once you register your function command using acedDefun() it will be callable from AutoLISP.

If you are using ARXWizard the "C>" button will show the command registration dialog where you can do that by adding your command at the lower list.

Hope this help,

Anonymous said...

HI, Fernando!
how can i create a 3dface in ObjectARx??

Thanks...

Fernando Malard said...

Just use the AcDbFace class:

__________

AcDbFace(
const AcGePoint3d& pt0,
const AcGePoint3d& pt1,
const AcGePoint3d& pt2,
Adesk::Boolean e0vis = Adesk::kTrue,
Adesk::Boolean e1vis = Adesk::kTrue,
Adesk::Boolean e2vis = Adesk::kTrue,
Adesk::Boolean e3vis = Adesk::kTrue
);

Parameters:

const AcGePoint3d& pt0
Input first corner point (in WCS coordinates)
const AcGePoint3d& pt1
Input second corner point (in WCS coordinates)
const AcGePoint3d& pt2
Input third corner point (in WCS coordinates)
Adesk::Boolean e0vis = Adesk::kTrue
Input Boolean indicating whether or not first edge will be visible
Adesk::Boolean e1vis = Adesk::kTrue
Input Boolean indicating whether or not second edge will be visible
Adesk::Boolean e2vis = Adesk::kTrue
Input Boolean indicating whether or not third edge will be visible
Adesk::Boolean e3vis = Adesk::kTrue
Input Boolean indicating whether or not fourth edge will be visible

Description:

This constructor initializes the AcDbFace to use the points pt0--pt2 as the four corner points of the face with pt2 being used for both the third and fourth corner points. This produces a face that is triangular. The points must be in WCS coordinates.

The e0vis--e3vis arguments control the edge visibilities. e0vis controls the visibility of the edge between pt0 and pt1, e1vis the edge between pt1 and pt2, etc. An Adesk::kTrue value indicates the edge is to be visible. An Adesk::kFalse value indicates the edge is to be invisible.

In addition, standard AcDbEntity initialization occurs.
__________

Regards,

Anonymous said...

i get the error "an unhandled win32 exception ocurred in ACAD.EXE [xxxx]" when i run my ARX aplication. Before all were fine, and some time after this is what happening...i dont understand it! Help me please!

Fernando Malard said...

Hello,

I would need further information to help you.
Things like:

- AutoCAD version
- Windows platform: 32 or 64?
- Visual Studio version

Further, can you put a breakpoint into the code and detect which line is causing the Exception?

Regards,

Anonymous said...

Well...
Windows 7 32 bit SP1
AutoCad 2012 SP2
VS 2010 SP1
And the module of the error is free.c:

#endif /* CRTDLL */
else // __active_heap == __SYSTEM_HEAP
#endif /* _WIN64 */
{
retval = HeapFree(_crtheap, 0, pBlock);
if (retval == 0) //Here
{
errno = _get_errno_from_oserr(GetLastError());
}
}
}

Fernando Malard said...

Ok, so you are running a 32-bit machine.

Further questions:

- AutoCAD 2012 requires VS2008 engine to compile. Did you set the Platform Toolset:

Project Setting > Configuration Properties > General: Platform Toolset = Visual Studio 2008 (v90) ?

- Did you port your code to x64? If you, are you keeping different Builds for each Platform (Win32/x64)?

- Are you including the proper Headers/Libraries from ObjectARX for each Platform version?

- Are you instantiating non-ARX classes into one DLL and trying to delete them into another DLL?

- Can you debug your code since kLoadAppMsg inside acrxEntryPoint.cpp and check the last code line executed before the exception it thrown?

Regards,

Anonymous said...

Well Fernando:

The platform toolset is v90, i have installed VS 2008 and i am building only for win32, i dont delete classes in diferent dlls, i noted that while in debugger, if i continue till end skipping the error, at second try, the error disapears...

Fernando Malard said...

Can you create a new empty project with the portion of the code is raising the exception or is it too complex to isolate?

BTW, are you deleting a point to an entity you just added to database and called close()? Remember that Database resident objects cannot be deleted.

It is difficult to further troubleshoot the problem without seeing or running the code...

Anonymous said...

Well, i cant isolate that code, but if before all its ok, and now its malfunction, what can it be??
NET Framework? Before: 4.0 Now: 4.5
U believe it can be?

Fernando Malard said...

Probably not.

Try this:

- Compile your code in Debug mode;
- Once it is built, Start de Debug process (F5);
- Let AutoCAD initialize its things and don't load your DLL;;
- Go back to Visual Studio screen, menu DEBUG, click Exceptions...;
- Into the Exceptions dialog, enable all itens at the Thrown column;
- Go back to AutoCAD and load your app;
- You should see a lot of exceptions being thrown. Pay special attention to those thrown by your own code.

This option will catch more exceptions than usual and could help you to find the real culprit.

Don't forget to go back to the Exceptions dialog after you finish and restore the configuration using the "Reset All" button.

Hope it helps you to identify the problem.
Let me know how it goes.

Regards,

Anonymous said...

Hello Fernando!
The function where the error produces is in:
free(Word);
where Word is a pointer to char string...
i'm trying to liberate the memory, it's necessary???

Fernando Malard said...

Hi,

It depends on two things:

- How you allocated the memory for it;
- What you did with that string;

If you need to manipulate a simple local string you know the necessary buffer size to handle, just use:

char buffer[1024];

In this case you don't need to free the memory once it will be a stack variable and will be deleted when the code get out of scope.

In other hand, if you declare as a pointer instantiated with the NEW operator, you need to DELETE it. So, in this case:

char *p = new char[200];
delete[] p;

Finally, if you are dealing with a string returned by an AutoCAD native method you need to read the method documentation to check if the string returned should be deallocated by the caller. Once ObjectARX has its own heap management you will need to use acutDelString() method to do that.

free() method is used together with malloc() method a legacy C string memory management mechanism.

If you plan to port your code later to UNICODE and x64 machines I would recommend to port all your strings to TCHAR or ACHAR and use their corresponding UNICODE string manipulation Macros (_tcscpy, _tcsdup, etc.).

If you need to stay into the pure C world, take a look at the std::string class from Standard C++ Library: http://www.cplusplus.com/reference/string/

Here is a good reading about all those type of strings:

http://www.codeproject.com/Articles/2995/The-Complete-Guide-to-C-Strings-Part-I-Win-Chara

Hope it clarifies you and help with the exception.

Regards,

Anonymous said...

Well, only i deleted the line because it isn't necessary and all go ok again!
Thanks by ur help!

Fernando Malard said...

Glad it worked!

Regards,

Anonymous said...

Hello, Fernand!
i try to modify a pline adding two vertex, and only adds one...im passing the list ok to entmod, something do not function here! Always i have problems with entmod...

Help!

Fernando Malard said...

Hello,

I'm sorry but I'm not an expert in AutoLISP.

A quick Google Research gave me this URL: http://www.lee-mac.com/addpolyvertex.html

Hope it helps.

Regards,

Anonymous said...

Hello!

I compiled an arx project x64 in VS2010 for autocad 2012, and when im loading in Autocad it says me: Unable to load arx file.

Help me!

Fernando Malard said...

Hello,

- Did you compile your code with ObjectARX 2012 version?

- Did you install the VS2010 updates?

- Is your machine x64?

Regards,

Anonymous said...

Hello Fernando!

Im using this:

- x64 machine
. objectarx 2012
- autocad 2012
- vs2010

I just be wanting vs2010 updates...


Anonymous said...

Hello Fernand!

im using next:

- Autocad 2012
- ObjectARX 2012
- VS2010
- NET Framework 4.5
- Machine X64

WHat updates are necessary for VS
2010?

Thanks

Fernando Malard said...

Hello,

Just use Windows Updates or go to Microsoft website.
My VS2010 version is:

"10.0.40219.1 SP1Rel"

Another thing you can do is to install Depends which is a helper tool to scan your DLLs (ARXs/DBXs) que tell you the other DLLs it depends on and which symbols it is expecting to link with:

http://www.dependencywalker.com

Hope this helps.

Regards,