Selecting Objects from PaperSpace into Modelspace without pre-selecting a Viewport using ObjectARX

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 uTransSpac
eFlag 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 pEnt(objId,AcDb::kForRead);        if (pEnt.openStatus() == Acad::eOk)          pEnt->list();      }    }

Comments

2 responses to “Selecting Objects from PaperSpace into Modelspace without pre-selecting a Viewport using ObjectARX”

  1. Could you give us the same code in vb.net We realy need it :-)

  2. In order to use acedNEntSelPEx with VB.NET you have to P/Invoke it such as: http://www.theswamp.org/index.php?topic=22963.msg345716#msg345716
    Also you have remember that code working with AutoCAD 2007…2009 x86, so you have to do some changes

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading