Author Topic: how ObjectId change to AcDbObjectId  (Read 3162 times)

0 Members and 2 Guests are viewing this topic.

ahlzl

  • Guest
how ObjectId change to AcDbObjectId
« 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.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: how ObjectId change to AcDbObjectId
« Reply #1 on: September 21, 2008, 04:45:42 AM »
you can try something like

Code: [Select]
    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));


It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: how ObjectId change to AcDbObjectId
« Reply #2 on: September 21, 2008, 02:46:10 PM »
another way

Code: [Select]
    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());

ahlzl

  • Guest
Re: how ObjectId change to AcDbObjectId
« Reply #3 on: October 09, 2008, 09:38:59 AM »
you can try something like

Code: [Select]
    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));


Daniel is god !

Code: [Select]
    ObjectId idb;
    AcDbObjectId ida;

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

TonyT

  • Guest
Re: how ObjectId change to AcDbObjectId
« Reply #4 on: October 09, 2008, 03:13:45 PM »
Entity -> AcDbEntity:
AcDbEntity *pEnt = (AcDbEntity*)ent.UnmanagedObject.ToPointer();  // ent is Entity

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

from mgdinterop.h:

Code: [Select]

#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;
}