On previous class I have presented the step by step way to create a minimum application by hand. Of course there is a easier way to do that but I think is very important that you understand correctly things that are behind the scenes.
This time we will use the ARXWizard tool which is provided by Autodesk through ObjectARX SDK. If you go to the \Utils folder you will find the install program. Go ahead, install it and allow Live Update to run at the first time. Do this with your Visual Studio .NET closed.
After you install it, open Visual Studio.NET, open File menu and start a New Project. The following dialog will appear and you will find a new node inside Visual C++ Projects folder which is called Autodesk. Select this node and the ObjectARX/DBX/OMF Project icon will appear at the right side as following:
Fill out the Name field and specify the desired location to create the new project. Click OK to continue. The following dialog will appear:
This dialog presents the steps to setup your new project. The first page, called Overview, shows some information and give you the opportunity to inform your RDS (Registered Developer Symbol). This label will be used to prefix anything that your code could implement and could conflict with other third-party applications. To allow this prefix to be unique, Autodesk provides (through ADN subscriptions) a way to register your prefix and inform other ADN members. Even you are note an ADN member you should create your own RDS. Use your initials, your 3 name first chars or any other name you find clear and useful.
The next step is to choose your desired Application Type. As I have mentioned before, ARXWizard suggests the ARX / DBX types which are basically the separation of Interfaces and Custom Classes. More details about the main differences between ARX and DBX can be found at ObjectARX documentation. This time we will choose the ObjectARX option as follows:
The next step is about Additional SDK Support which allows you to extend basic ObjectARX features to an specific Autodesk vertical. There are two options:
- OMF Support: This is the SDK extension for Autodesk Architectural Desktop (aka ADT) which contains specific features that could be used if you plan to develop an ObjectARX application to run inside ADT;
- MAP API Support: This is the SDK extension for Autodesk MAP which contains extra features to be used if you plan to develop a MAP ObjectARX application.
In our case, we will develop an ObjectARX application targeting plain (or vanilla) AutoCAD so leave both blank.
The next step is to specify MFC Support. As I mentioned before we will use MFC Extension DLL project type. This dialog also offers the option to enable AutoCAD MFC Extension Support which will allow you to use specific AutoCAD controls like LineType combo boxes, Color combo boxes, Dockable dialogs, etc. This is pretty handy once those controls are not so simple to implement from scratch. Select Extension DLL and enabled AutoCAD MFC Support:
The last step is dedicated to COM related stuff. ObjectARX supports COM implementations on both Server and Client sides. As COM programming is very complex and is beyond this course scope so I will not cover it.
Leave the options on the Not a COM Server and None. Click Finish to proceed.
Now you can open the project files and see what the ARXWizard has done for you. There are a lot of differences between the project we have created on previous class and the present project because ARXWizard use different implementations using handy classes. We will cover these features several times with our upcoming samples on the next classes.
Compile and Build the project and try to load the resulting ObjectARX application inside AutoCAD. You probably will be able to successfully load it.
37 comments :
you should use VS2002 instead.
btw - the post above for free training in nothing but SPAM. It's a waste of time.
Now back to school...
While I had trouble getting Class 3a to build correctly this one built perfectly.
No errors - arx was built and available.
VS2002 SP1 with Object Arx 2006
Bill
Oh and one more thing...
When setting up the project with the wizard, when I click "finish". VS shows a warning message that says...
<<<
Due to a defect in the Visual Studio Intellisense, to avoid a freeze in VS later when using our class wizards, please open the stdafx.h file in the VS IDE. Once VS has finished parsing this file, simply save the solution. This will force the necessary update to the VS Intellisense database. Sorry for any inconvenience caused.
>>>
It pops up with every project in VS2002 and VS2003.
Other than that, thanks for the info on additonal SDK support. Very wise.
Using VS2002 with Object Arx 2006
Hi,
This defect is a bug on VStudio which freeze it if you try to navigate your code before the parsing process ends.
What I usually do is to open the solution, open the StdAfx.h file of the Startup Project (the one with bold name). I then wait for the parsing (see the VStudio status bar accesing files).
When the parsing is finished, perform a SaveAll.
That's it, strange but works.
Regards,
Fernando
Hi. I just wanted to ask how to turn it to managed form, cause when I just switch it in project setting and try to load it with Autocad 2006 it fails.
Anyone help?
Hi zdenek,
Managed form will be possible only if you convert or create the ObjectARX project as a Managed or Mixed-mode Module.
This way it will allow you to use .NET classes from C++ and then you will be able to create and show Windows Forms.
A MFC form is different from a Windows form which is based on .NET windows forms.
Once you create a managed module it needs to be loaded into AutoCAD by the NETLOAD command and it should use the .DLL extension instead of .ARX
Regards,
Fernando.
If you create an ARX project using VS 2005 and ARX Application wizard, and add a command in ObjectARX Commands window in acrxEntryPoint.cpp you will have the following:
created command(_MyCommand) is a static function. From a static function, you can call only other static functions.
How can you call another function which is not static?
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CArxProject1App : public AcRxArxApp {
public:
CArxProject1App () : AcRxArxApp () {}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// TODO: Load dependencies here
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
// TODO: Add your initialization code here
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
// TODO: Add your code here
// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
// TODO: Unload dependencies here
return (retCode) ;
}
virtual void RegisterServerComponents () {
}
public:
// - ArxProject1._MyCommand1 command (do not rename)
static void ArxProject1_MyCommand1(void)
{
// Add your code for command ArxProject1._MyCommand1 here
}
} ;
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CArxProject1App)
ACED_ARXCOMMAND_ENTRY_AUTO(CArxProject1App, ArxProject1, _MyCommand1, MyCommand1, ACRX_CMD_MODAL, NULL)
Hello Jelena,
You can call non static methods from inside a static method but to be able to do that you need to have an instance of the class these methods belong to.
It is always a good idea to create a class to wrap a package of similar methods or methods with the same purpose.
There is a Design Pattern called Singleton (http://en.wikipedia.org/wiki/Singleton_pattern) which design a class with a single instance which allow you to call its methods but avoiding the creation of too many unecessary instances which could consume extra memory.
Regards,
HI ,
when i use the arx wizard to add a variable using the Autodesk Class Explorer - Add
Variable
I get a Runtime error saying:
Line: 214
Error: 'Bases.Count' is null or not an object.
The error occur in the file arxCommon.js
thanks
Vindow
Hi Vindow,
Did you try to update your ARXWizard through its LiveUpdate?
Did you get the same error with a brand new project?
Regards.
hi Fernando Malard,
thanks for your help.
I try to follow your advice:
I try to update your ARXWizard through its LiveUpdate. But I get a message like this "No instructions found!".
I start a new brand project and try it again, i get the same error.
could you give me another sugesstion?
Hi,
Try to uninstall and then reinstall the ARXWizard.
If this does not work try to contact ARXWizard folks at oarxwiz-feedback@autodesk.com
Regards,
Thanks very much.
I will leave my message when i try it again.
Regards
Instead of using Autodesk Class Wizard try to use MS Class Viewer. In Visual Studio View - Other Windows - Class View. It worked for me.
Hello.
i am using AutoCAD 2010, ObjectARX 2010 and VS 2008 SP1. When I tried to run ARXWizard there was a message that VS 2008 should be installed. Could you give me some advice how to solve this problem?
Thanks in advance
Zix
Zix,
Strange, never heard about that.
Try to uninstall ARXWizard, make sure all VS2008 instances are closed and try to install again.
If you are running under the UAC or with a limited user, try to run the ARXWizard with Administrator privileges.
Regards.
Hello again.
The problem was in my Express Edition VS2008. After I took Full version everything works fine.
Thanks anyway
Zix
Had no problem Configuring ObjectARX in a Windows 7 Professional 64 bit system, using Visual Studio 2005 and AutoCAD 2009You have to know your stuff to do this. Especially the 64 bit version. I have been programming in C++ for 20 years. Tryed the simple example calling CENTS function. Everything worked fine. But you need to put all these steps in 1 block of example text. you have people jump around too much to get at this simple procedure.
Hi Fernando:
I am trying to run the class 3a but I got this error:
"fatal error C1083:Cannot open include file: 'AcTc_i.h': No such file or directory. The error ocurres in file arxheaders.h, line 203.
I will apreciate your answer.
Thanks.
Racso,
The problem seems to be related to your include files path.
ObjectARX 2010 SDK comes with 3 include folders:
\inc\
\inc-win32\
\inc-x64\
The "\inc\" folder should be included with the specific platform include folder because it contains platform independent files.
The file "AcTc_i.h" is located into the platform specific folder, in your case, \inc-x64\ folder.
Please let me know it it did work.
Regards.
Fernando:
I changed the folder \inc by \inc-x64\ and a new problem showed up. Now VS is looking for headers that are included in folder \inc but not in folder \inc-x64. I tried two things: First, copy those headers from \inc to \inc-x64. Second, add both folder to VS and in those two cases I got the new error: LN1112: module machine type 'x64' conflicts with target machine type 'X86'. The proble is on file acdb18.lib
Thanks.
Racso,
You don't need to change the folders just include both into your VS Solution folders as you did.
Check if your lib folder is also pointing to lib-x64 folder as it should be.
Another thing you will need to do is to create a x64 target for your project.
Regards.
Fernando:
Thanks a lot for your help. The problem was VS 2008. When I tried to create a x64 target for my project, VS didn't show that option. Then I found a solution on the web. Basically I needed to uninstall VS and then installed again but customizing it in order to include the C++ x64 tools. Now my application lodes fine....
Thanks again and have a good weekend.
Hello,
I am using AutoCAD 2010 and VS 2008. When I tried to run classes 3a & 3b I got this error:
“fatal error C1083: Cannot open include file: 'type_traits': No such file or directory”. The error ocurres in file acarray.h
How do I fix this?
Thanks,
Andrej
Andrej,
What version of ObjectARX are you using?
Is your machine x86 or x64?
Have you configured the ObjectARX inc and lib folders into your Visual Studio Settings?
Thank you for all the excelent classes ! Where can i find the mapheader files ? (map api support choice on additional sdk support arxwizard screen)
using VS2008 sp1 and objectarx 2011
Hello,
Autodesk MAP API is available through a different SDK which can be downloaded from here:
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=868220
It works on the top of ObjectARX SDK.
Regards.
Hello
I am using VS 2008 and Autocad 2010.
,i am using x64 win 7.
i had givven both the inc and inc-64 and also lib-64, but it is showing type_trait ,nosuch file are there.
If i remove the inc the arxheader file not found error is comming.
Please guid me
Thanks
Jeeban
Jeeban,
What version of ObjectARX SDK are you using?
Have you tried to create a default application with the ARXWizard?
Have you installed VS2008 SP1?
Regards.
Hi
I need your help.
i'm using windows7x64, vs2008sp1, autocad 2012, objectarx2012, and install the objectarx wizzard.
I configure the include & lib paths
and still have the message from the compiler
fatal error C1083: can not open include files: 'type_traits'
what else ii can do?
Jose,
Did you add both "inc" and "inc64" ("lib" and "lib64")?
The x64 mode requires general files with traditional folder names but also x64 versions of some libraries.
Please let me know if it works for you.
Cheers!
I follow your instructions on using the wizard exactly, but I keep getting the same error when I try to build:
Error 1 error C2664: 'LoadStringW' : cannot convert parameter 3 from 'LPSTR' to 'LPWSTR' d:\objectarx 2011\inc\arxEntryPoint.h 140 ArxProject1
Error 2 error C2664: 'AcEdCommandStack::addCommand' : cannot convert parameter 1 from 'LPSTR' to 'const ACHAR *' d:\objectarx 2011\inc\arxEntryPoint.h 151 ArxProject1
Error 3 error C2664: 'AcEdCommandStack::removeCmd' : cannot convert parameter 1 from 'LPSTR' to 'const ACHAR *' d:\objectarx 2011\inc\arxEntryPoint.h 173 ArxProject1
Error 4 error C2664: 'LoadStringW' : cannot convert parameter 3 from 'LPSTR' to 'LPWSTR' d:\objectarx 2011\inc\arxEntryPoint.h 189 ArxProject1
Error 5 error C2664: 'acedDefun' : cannot convert parameter 1 from 'LPSTR' to 'const ACHAR *' d:\objectarx 2011\inc\arxEntryPoint.h 193 ArxProject1
Error 6 error C2664: 'LoadStringW' : cannot convert parameter 3 from 'LPSTR' to 'LPWSTR' d:\objectarx 2011\inc\arxEntryPoint.h 212 ArxProject1
Error 7 error C2664: 'acedUndef' : cannot convert parameter 1 from 'LPSTR' to 'const ACHAR *' d:\objectarx 2011\inc\arxEntryPoint.h 216 ArxProject1
Hi,
Have you migrated your code to UNICODE? It requires several code changes including string manipulation. For example, all strings should be enclosed by a _T() macro, char must be replaced by TCHAR, etc.
If your code is not UNICODE compliant it will not compile with ARX 2012.
Further, try to open a SDK sample and compile it. See if it compiles without any errors.
Please let me know the results.
Hi Fernando:
I have problems installing objectARX-2015 wizard in my computer. I guess the problem is that I have win8 installed in a solid state drive(C:) and programs like Autocad-2015 installed in a HDD (D:). Anyway. I have VS 2012 with SP4 and I installed and uninstalled wizard but it does not work.
VS shows: creating ‘name’ project …… project creation failed.
Are you using objectARX-2015 wizard without problems?
Since it does not work in my computer, could you help me with the following?
I have the “Minimum application” running good but I don’t know how to create a new command. Suppose that I want to create a “test” command using the minimum application project. Could you guide me in how to create it?
Thanks in advance for your help, I really appreciate it.
Oscar.
Oscar,
I think the Wizards rely on C: drive being where you installed the ObjectARX SDK. So your folder should be "C:\ObjectARX 2015\"
Try to copy the SDK to the C: drive you everything should work just fine.
Regards,
Hi,
As im the begginer to Objectarx, i need some logical code to draw a polyline with arcs at corners of a polyline( i mean arcs at corners of a polyline) when the user provide length, width and radius to draw a polyline. Could u please help me out ASAP.
Thank you.
Hi Sandhya,
AcDbPolyline can represent arcs through bulges. A bulge is tangent of 1/4 of the included angle. Positive value means it is Counter-Clockwise in terms of rotation direction:
bulge = tangent ( ang / 4.0 )
The bulge is set through setBulgeAt() method.
If you are not sure about the appropriate values to your polyline you can create it at the AutoCAD screen and then perform a LIST command which will tell you the bulges for each polyline vertex.
Hope it helps.
Post a Comment