by Fenton Webb
There is an undocumented function in ObjectARX which you can use called acedNEntSelPEx() which does exactly this. It even allows you to supply a picked point via the ‘pickflag’ parameter so you can supply your own programmatically supplied PS points…
Here’s some sample code for you…
extern int acedNEntSelPEx ( const TCHAR *str, ads_name entres,
ads_point ptres, int pickflag,
ads_matrix xformres,
struct resbuf **refstkres,
unsigned int uTransSpaceFlag,
int* gsmarker);
static void asdkSelectEnt_sel(void)
{
int gsmarker = -1;
ads_name ename;
struct resbuf *rbChain;
ads_point selPt;
ads_matrix tranMat;
// Select a single object. If it's a block reference or a sub-entity
// within a block reference, rbChain will not be null.
unsigned int uTransSpaceFlag = 1;
// set uTransSpaceFlag to 0, if the current layout is in model space
struct resbuf rb;
acedGetVar(_T("CVPORT"), &rb);
if (rb.resval.rint != 1)
uTransSpaceFlag = 0; // Model space
// now do the entity select
int stat = acedNEntSelPEx(_T("\nPick entity : "), ename,
selPt, 0, tranMat, &rbChain, uTransSpaceFlag, &gsmarker);
// if everything worked ok
if (RTNORM == stat)
{
// open the selected entity for
AcDbObjectId objId;
acdbGetObjectId(objId,ename);
AcDbObjectPointer<AcDbEntity> pEnt(objId,AcDb::kForRead);
if (pEnt.openStatus() == Acad::eOk)
pEnt->list();
}
}