ObjectARX

ObjectARX

Reply
Valued Contributor
jason.teagle
Posts: 75
Registered: ‎06-22-2010
Message 1 of 6 (206 Views)
Accepted Solution

AcEdSelectionSetService::addSubEntity() Parameters - How?

206 Views, 5 Replies
05-29-2012 06:03 AM

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.



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

 

 

Distinguished Mentor
owenwengerd
Posts: 686
Registered: ‎08-06-2002
Message 2 of 6 (202 Views)

Re: AcEdSelectionSetService::addSubEntity() Parameters - How?

05-29-2012 08:02 AM 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
Valued Contributor
jason.teagle
Posts: 75
Registered: ‎06-22-2010
Message 3 of 6 (194 Views)

Re: AcEdSelectionSetService::addSubEntity() Parameters - How?

05-29-2012 11:41 PM 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).

 

Moderator
Alexander.Rivilis
Posts: 1,458
Registered: ‎04-09-2008
Message 4 of 6 (190 Views)

Re: AcEdSelectionSetService::addSubEntity() Parameters - How?

05-30-2012 02:47 AM in reply to: jason.teagle

Try instead of:

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

use:

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

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
jason.teagle
Posts: 75
Registered: ‎06-22-2010
Message 5 of 6 (186 Views)

Re: AcEdSelectionSetService::addSubEntity() Parameters - How?

05-30-2012 03:00 AM in reply to: Alexander.Rivilis

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?

 

 

Valued Contributor
jason.teagle
Posts: 75
Registered: ‎06-22-2010
Message 6 of 6 (154 Views)

Re: AcEdSelectionSetService::addSubEntity() Parameters - How?

08-08-2012 04:48 AM 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.

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.