Getting osnapped object’s ID

By Gopinath Taget

Consider this: You need to find out after calling acedGetPoint() whether the point returned was osnapped to some geometry, and if it was osnapped, to get ID of the entity it was osnapped to. How can I achieve this?

To do this, you are going to have to use the AcEdInputPointMonitor reactor class. Use the ObjectARX Wizard to create an implementation of this reactor class. Here’s some pseudo code for your implementation of the monitorInputPoint() reactor method:

///////////////////////////////////////////////////////////////////

Acad::ErrorStatus asdkInputClosestPoint::monitorInputPoint(……)

{

 // if osnap mode is on

 if (history & Acad::PointHistory::ePickMask)

{

  // get any entities that have been used to calculate an osnap

  int keyPointLength = keyPointEntities.length ();

  // if entities have been used to calculate an osnap point

  if (keyPointLength)

  {

   // now we have the entities used for the osnap calc

   // the computedPoint gives us the snap point

 

   // you can iterate keyPointEntities array to get the

   // object Id’s of snapped entities

  }

}

 

 return Acad::eOk;

}


Comments

One response to “Getting osnapped object’s ID”

  1. Selevkos Avatar
    Selevkos

    Please provide us c# equivalent if it is possible?

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading