Alex,
ARX file is compiled by ObjectARX SDK so it has all dependent references inside. Those dependencies also have their other nested dependencies, and they are wiring each other to live in the same AutoCAD installation directory. When we call a method inside an ARX file, all related methods (in other native DLLs) will get called accordingly. So a .NET app that uses an ARX file should reference the world of AutoCAD native assemblies.
.NET plug-in has commands exposed as .NET attributes (CommandMethodAttribute), so it will be easier to get those commands using .NET reflection (with help from Mono.Cecil library).
See an example of registering commands in ARX (C++ code):
AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)
{
switch (msg) {
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(appId);
acrxDynamicLinker->registerAppMDIAware(appId);
gpEdReac = new AsdkNODEdReactor();
acedRegCmds->addCommand(_T("ASDK_CLONENOD_TEST"),
_T("ASDK_NODSETUP"),
_T("NODSETUP"),
ACRX_CMD_TRANSPARENT,
setup);
break;
case AcRx::kUnloadAppMsg:
clearReactor();
acedRegCmds->removeGroup(_T("ASDK_CLONENOD_TEST"));
delete gpEdReac;
}
return AcRx::kRetOK;
}
ARX plug-in defines a command as code content of acrxEntryPoint method, without exposing outside to retrieve. So unless we can decompile C++ code to read those commands, we need to call acrxEntryPoint method to ask it to run acedRegCmds->addCommand(). This addCommand method will store defined commands somewhere. From there, we can retrieve those commands that we need to find.
acedRegCmds is a macro of the class AcEdCommandStack with method addCommand. AcEdCommandStack comes from accmd.h which I don’t know exactly its DLL file.
A solution that I can think of is to create some “fake” native DLL files with names copied from AutoCAD real DLL files. Those “fake” DLL files will be implemented only some needed functions with non-actions, except addCommand will return a list of added commands, and we retrieve them from there using DllImport in .NET code.
Because ARX is C++ code so it should call another C++ code from its code. “Fake” or real AutoCAD native DLL files are still needed to reference in this ARX file. If we can decompile or binary-read ARX file to extract raw command strings, we can skip C++ calls and ignore all above explanations.
I try to make it clear and logic to solve this challenge topic. Not sure to find the final code but at least we can learn something of the complicated world of managed and unmanaged code living together in AutoCAD.
-Khoa