- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to add entities to the service object during AcEdSSGetFilter::endSSGet(), to replace entities that were removed (I need to swap out certain selectable entities for their parent object).
Removing IDs is easy - the remove() index) method works just fine.
This is the code I'm trying to use to add a list of object IDs:
int iNumObjectsToAdd = ObjectIDsToAdd.length();
for (int iObjectIndex = 0 ; iObjectIndex < iNumObjectsToAdd ; iObjectIndex++)
{
AcDbObjectIdArray ObjectIDs ;
ObjectIDs.append(ObjectIDsToAdd.at(iObjectIndex) );
AcDbSubentId SubEntID(parent_object_class::desc(), 0);
AcDbFullSubentPath Path(ObjectIDs, SubEntID);
ads_name ObjectName ;
if (acdbGetAdsName(ObjectName, ObjectIDsToAdd.at(iObjectIndex) ) == Acad::eOk)
{
resbuf *pBuf = acutBuildList(RTENAME, ObjectName, RTNONE);
Acad::ErrorStatus es = service.addSubentity(pBuf, Path);
acutRelRb(pBuf);
}
}
My first question is about AcDbSubentId. I want it to refer to the root object - if I have an object of type parent_object_class, I don't want edges or vertices or faces - I want the object as a whole (the entire entity, as if the user had selected that entity with the mouse instead of the nested entity). Have I constructed the AcDbSubentId object correctly for that situation?
My second question is about addSubentity(). Am I building the resbuf correctly?
I ask because addSubentity() is returning Acad::eInvalidInput, but I don't know which bit is wrong or how to do it correctly. What samples there are in the help docs only talk about individual faces or edges, not the whole entity as a unit. There is no sample for addSubentity().
To try and clarify what I'm trying to do here, imagine custom object A has an AcDb3dSolid as its member. Object A has edges only, and the solid provides the body. If the user clicks the body (the easiest bit to click), I get the property manager for the solid. I want the solid to appear to be attached to the parent - so you select either one, you get the parent (since the parent is the one that has the custom properties I want to show). They would have to really fiddle to select the edge, to get object A. I am therefore removing the solid from the selection set and trying to replace it with its parent object - object A. I have the AcDbObjectId of object A and can obviously get its ads_name(), but beyond that I don't know how to achieve what I want.
Can anyone point me in the right direction, please?
(Is it possible to somehow tie owned objects to their parent via some AcDbEntity override method so that when you click the child, it automatically selects the parent instead? That would be a neater solution.
Note that deriving directly from AcDbSolid is not an option here - and besides, I have larger, more complex custom objects with multiple different classes of owned objects for which this functionality would also be useful.)
Thanks in advance.
Solved! Go to Solution.

