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

How to get the ObjectID or ads_name of the already seleted entity

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
2269 Views, 2 Replies

How to get the ObjectID or ads_name of the already seleted entity

I have a scenario, where using a same command I have draw and edit of our entities.

 

If nothing is selected during firing the command, insert mode will be activated where a block will be inserted with attribute values from UI.

 

But if the block is selected and the command is invoked, the attributes will be read and be populated in the UI and the UI will work as an editor.

 

I have used acedGetCurrentSelectionSet. Its working fine when something is all ready selected before firing the command.

 

But next time when nothing is seleted, it still, considers, the previous selection as the current selection, which is not correct.

 

So what is the correct API to get the currect selection.

 

NB: I only want the 1st entity in the selection set, I don't want to iterate through the selection set.

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

I have used the following code.

 

    static void InvokeMainUI(void)
    {
        AcDbObjectIdArray CurrSelSet;
        Acad::ErrorStatus es = acedGetCurrentSelectionSet(CurrSelSet);

        try
        {
                if(!CurrSelSet.isEmpty() )//Something is selected, so start in edit mode
                {
                    AcDbObjectId objID = CurrSelSet.at(0);

                    AcDbEntity *pEnt;       
                        acdbOpenAcDbEntity(pEnt,objID,AcDb::kForRead);

                        if (pEnt->isKindOf(AcDbBlockReference::desc()))
                        {
                            CNSDWGMgr ThisDrawing;
                            ThisDrawing.SubStnBlokEdit(pEnt);// Edit Mode
                        }

                       

                    pEnt->close();
                }
                else // nothing is selected, so start with out editing mode
                {
                           

                        MYSTRINGSTRINGMAP mapOfAttributesFromRegistry;
                        //getAttributeInfoFromWithInBlock(mapOfAttributesFromRegistry);

                        CAcModuleResourceOverride myResources;
                        CNSMainSubstaionDlg* objDlg = new CNSMainSubstaionDlg(mapOfAttributesFromRegistry,acedGetAcadFrame());
                        if(objDlg!=NULL)
                        {
                            objDlg->DoModal();
                            delete objDlg;
                        }

                }

                CurrSelSet.removeAll();
                CurrSelSet.removeSubArray(0,CurrSelSet.length());
               

        }
        catch(...)
        {

        }

    }   

Message 3 of 3
Balaji_Ram
in reply to: Anonymous

Hello Subir,

 

Have you tried using the pick-first selection set for this ?

The command that runs this code must specify ACRX_CMD_USEPICKSET

 

Here is a sample code :

 

structresbuf * ss = NULL;

 

if(RTNORM != acedSSGetFirst(NULL, &ss))

 

return;

 

longlen;

 

if(RTNORM != acedSSLength(ss->resval.rlname, &len))

{

acedSSFree(ss->resval.rlname);

acutRelRb(ss);

return;

}

if(len < 1)

{

acedSSFree(ss->resval.rlname);

acutRelRb(ss);

return;

}

BOOL ret = TRUE;

for (longi = 0; i < len; i++)

{

ads_name name;

acedSSName(ss->resval.rlname, i, name);

AcDbObjectId id;

acdbGetObjectId(id, name);

}

acedSSFree(ss->resval.rlname);

acutRelRb(ss);

 

Cheers,

 

Balaji

 

Developer Technical Services



Balaji
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report

”Boost