How to create AutoCad object from this handle using ObjectARX

150 views Asked by At

I have object handle and I wish create object, using ARX Now I try CPtr pEnt(handle_Obj);

But is does not result (return null ptr) Please, tell me, how links handles, id-s, and object pointers Autodesk help is to confused fo me.

1

There are 1 answers

0
CAD Developer On

You can get objectId like this:

CString handle = L"ABCD";
AcDbObjectId id;
ads_name en;
ads_handent ( handle, en ) ;
acdbGetObjectId ( id , en ) ;

Now You can open object based on AcDbObjectId like this

AcDbEntity* ent = NULL;
Acad::ErrorStatus es;
es = acdbOpenAcDbEntity(ent, id, AcDb::OpenMode::kForRead);

Then You need to cast entity to object You need like this:

AcDbLine* line = AcDbLine::cast( ent ) ;