IntelliCAD.net

The IntelliCAD Network

In my OpenCAD book, I show just how easy it is to create a DRX plug-in. I start by creating a simple "Hello World" plug-in with just 22 lines of code. Here are the 22 lines:

#include "OdaCommon.h"
#include "RxDynamicModule.h"
#include "Ed/EdCommandStack.h"
#include "StaticRxObject.h"
#include "DbCommandContext.h"

#pragma comment(lib, "DD_Root_dll.lib")

class CMyCommand : public OdStaticRxObject
{
public:
const OdString groupName() const { return DD_T("MyGroup"); }
const OdString globalName() const { return OdString("MyCommand"); }
const OdString localName() const { return globalName(); }
void execute(OdEdCommandContext* pCmdCtx) { AfxMessageBox(_T("Hello World")); }
};

class CMyModule : public OdRxModule
{
OdStaticRxObject m_cmdMyCommand;
public:
void initApp() { odedRegCmds()->addCommand(&m_cmdMyCommand); }
void uninitApp() { odedRegCmds()->removeCmd(DD_T("MyGroup"), DD_T("MyCommand")); }
};

ODRX_DEFINE_DYNAMIC_MODULE(CMyModule);

Reply to This

Replies to This Discussion

Uggg.

C++ is a perfect example of what happens when someone tries to bolt on an object class structure to an inherently procedural programming language. To make matters worse, there are several incompatible coding variations of C++ (although DRX obviously only uses one) Sorry I just can't help that reaction every time I see anything written in C++, regardless how noble the effort :)

Thanks for the demo.

Reply to This

I take it you're not fond of C++ : )

Reply to This

Hello,

I am very new to this but I like veru much what you are doing. I have the book and now also access to ODA libraries. Visual Studio has long trial period so I hope to learn it one day :-)

Current version of ODA libraries is 3.02 and I was not able to build this DRX "Hello World" with it. It says:
OCKernel.obj : error LNK2001: unresolved external symbol _odrxAlloc
OCKernel.obj : error LNK2001: unresolved external symbol _odrxFree

I was able to build it with DRX SDK 2.06 which was used in the book but then current 3.02 applications say the DRX module cannot be found. I think I have already tried everything with numberinf file names like "...3.02_9.drx". In ODA member area I have only access to 3.02 version I think. So I cannot check with older versions.

OpenCAD ís one of example applications which helped me a lot but still it did not load DRX plugin which is in examples as well.

May be I am just using wrong version of libraries?

Thank you for any help!

Reply to This

Probably just one more line is enough:

#pragma comment(lib, "DD_Alloc.lib")

I have to read better documentation and release notes...

Reply to This

Yes, I need to update the book and code for the new ODA libraries. I am waiting for them to be done with their rebranding so that I don't have to rewrite everything once again.

Marek Ruzicka said:
Probably just one more line is enough:

#pragma comment(lib, "DD_Alloc.lib")

I have to read better documentation and release notes...

Reply to This

Reply to This

RSS

Badge

Loading…

© 2010   Created by Deelip Menezes.   Powered by .

Badges  |  Report an Issue  |  Terms of Service

Sign in to chat!