Code Red > .NET

how ObjectId change to AcDbObjectId

(1/1)

ahlzl:
Entity -> AcDbEntity:
AcDbEntity *pEnt = (AcDbEntity*)ent.UnmanagedObject.ToPointer();  // ent is Entity

but how ObjectId change to AcDbObjectId? thanks for your help.

It's Alive!:
you can try something like


--- Code: ---    ObjectId idb;
    AcDbObjectId ida;

    ida.setFromOldId(idb.OldId);
    idb = ObjectId(ida.asOldId());

//or

    ObjectId idc((long)(AcDbStub*)ida);
    AcDbObjectId idd(reinterpret_cast<AcDbStub*>(idc.OldId));


--- End code ---

It's Alive!:
another way


--- Code: ---    Editor^ ed = Application::DocumentManager->MdiActiveDocument->Editor;
    Database ^pDb = Application::DocumentManager->MdiActiveDocument->Database;
    AcDbObjectId ide = *reinterpret_cast<AcDbObjectId*>(&(pDb->CurrentSpaceId));

    ed->WriteMessage(pDb->CurrentSpaceId.ToString());
    acutPrintf(_T("\n%ld"), ide.asOldId());

--- End code ---

ahlzl:

--- Quote from: Daniel on September 21, 2008, 04:45:42 AM ---you can try something like


--- Code: ---    ObjectId idb;
    AcDbObjectId ida;

    ida.setFromOldId(idb.OldId);
    idb = ObjectId(ida.asOldId());

//or

    ObjectId idc((long)(AcDbStub*)ida);
    AcDbObjectId idd(reinterpret_cast<AcDbStub*>(idc.OldId));


--- End code ---

--- End quote ---

Daniel is god !


--- Code: ---    ObjectId idb;
    AcDbObjectId ida;

    ida.setFromOldId(idb->OldId);
    idb = ObjectId(ida.asOldId());

--- End code ---

TonyT:

--- Quote from: ahlzl on September 21, 2008, 04:21:40 AM ---Entity -> AcDbEntity:
AcDbEntity *pEnt = (AcDbEntity*)ent.UnmanagedObject.ToPointer();  // ent is Entity

but how ObjectId change to AcDbObjectId? thanks for your help.

--- End quote ---

from mgdinterop.h:


--- Code: ---
#define GETOBJECTID(id)     (*reinterpret_cast<AcDbObjectId*>(&(id)))

inline Autodesk::AutoCAD::DatabaseServices::ObjectId ToObjectId(const AcDbObjectId& pt)
{
    Autodesk::AutoCAD::DatabaseServices::ObjectId ret;
    GETOBJECTID(ret) = pt;
    return ret;
}


--- End code ---

Navigation

[0] Message Index

Go to full version