ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcEdSelectionSetService::addSubEntity() Parameters - How?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
jason.teagle
676 Views, 5 Replies

AcEdSelectionSetService::addSubEntity() Parameters - How?

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.

5 REPLIES 5
Message 2 of 6
owenwengerd
in reply to: jason.teagle

It sounds to me like you are doing it all wrong. If you want your subentities to not be exposed as subentities, then just don't expose them at all. Keep them as non-DBR members of your custom object and use them for whatever purposes you need them. This is typically referred to as "embedding", so search the group with "embedded object" for examples.

--
Owen Wengerd
ManuSoft
Message 3 of 6
jason.teagle
in reply to: owenwengerd

OK, that will certainly solve the problem for one of our objects so I'll change to doing that (found the information in the developer's help file - didn't even know this was a valid way to embed objects).

 

However, I would still like to know how to correctly use addSubEntity() to add an object to the selection set. The method's there (so it's designed to be used) but the documentation is very lacking in examples. For some reason they made it easy to remove an object by index, but didn't add a nice simple addEntity(AcDbObjectId).

 

Message 4 of 6

Try instead of:

resbuf *pBuf = acutBuildList(RTENAME, ObjectName, RTNONE);

use:

resbuf *pBuf = acutBuildList(RTLB,RTSHORT,0,RTENAME,ObjectName,
RTSHORT,0,RTLE,RTNONE);

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 6

Thank you for this. Unfortunately it still returns eInvalidInput. I also found that I could use

 

AcDbFullSubentPath Path(ObjectIDsToAdd.at(iObjectIndex), kNullSubentId);

 

to specify the object itself rather than a subentity, but even that didn't help.

 

So my current code is this:

 

AcDbFullSubentPath Path(ObjectIDsToAdd.at(iObjectIndex), kNullSubentId);

ads_name ObjectName ;

if (acdbGetAdsName(ObjectName, ObjectIDsToAdd.at(iObjectIndex) ) == Acad::eOk)

{

    resbuf *pBuf = acutBuildList(RTLB,

        RTSHORT, 0,

        RTENAME, ObjectName,

        RTSHORT, 0,

        RTLE,

        RTNONE);

    Acad::ErrorStatus es = service.addSubentity(pBuf, Path);

    acutRelRb(pBuf);

}

 

Any further suggestions as to what I might be doing wrong?

 

 

Message 6 of 6
jason.teagle
in reply to: jason.teagle

The problem is using service.addSubEntity() - it's not what AutoCAD considers a subEntity(). I had to use service.add() instead.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost