TheSwamp
Code Red => ARX Programming => Topic started by: Draftek on November 22, 2006, 02:08:52 PM
-
Can someone show me how to convert an autocad unmanaged object to a managed one in a wrapper class:
long TEST::Wrapper::Utils::TestHighlight(ObjectId &ID)
{
AcDbObjectId * newid = new AcDbObjectId();
// the unmanaged method
highlightTest(*newid);
return newid.asOldId();
}
I'm getting a long from the asOldId() method, but I'd really like to convert the unmanaged newid to the managed ID as the wrapper argument.
Thanks, cause I'm lost.
I tried using DisposableWrapper.Craate() but to no avail....
-
In the SDK, have a look at the mgdinterop header file (and include it in your projects) for some typical conversions of typical items commonly used in these situations.
here's an example of getting an object id that I used to store objects in an array
//in the header:
public:
void AddId(ObjectId entId); //add managed objId's to id array
private:
AcDbObjectIdArray* _ids; //native storage of ObjId's
//------------------------------------------------------------------------------------//
//- in the cpp
void DCS_3D::HlrEngine::DCS2dEngine::AddId(ObjectId entId)
{
_ids->append(GETOBJECTID(entId));// use managed macro to convert id types
}
I've used this to write a very basic wrapper of some functions and classes, basically you just need a pointer to the native object inside your wrapper class and you can handle marshaling the input/output with those macros and methods in the mgdinterop.h
hth,
Mick.
-
sweet! Thanks.
I'll try that.
Get back with you as soon as I hose it....
-
ooooOOOOO!
Thanks. If you knew how long today, I've been fighting this, you'd feel sorry for me. :)
If we ever meet, I owe you a beer - and not any watered-down American crap either.
-
....
If we ever meet, I owe you a beer - and not any watered-down American crap either.
I'll hold you to that :) , glad to be of some help.