命令类的另一个示例,并使用OdDbUserIO类获取选择集。
- //++-- class CommandLAYCUR -----------------------------------------------
- class CommandLaycur : public OdStaticRxObject
- {
- public:
- const OdString localName() const { return globalName(); }
- const OdString groupName() const { return DD_T("DRXLayerIso"); }
- const OdString globalName() const { return OdString("LAYCUR"); }
- //++--
- void execute(OdEdCommandContext* pCmdCtx)
- {
- OdDbCommandContextPtr pDbCmdCtx(pCmdCtx);
- OdDbUserIOPtr pDbIO = pDbCmdCtx->dbUserIO();
- OdDbDatabasePtr pDb = pDbCmdCtx->database();
- OdDbObjectId clayerId = pDb->getCLAYER();
- //++-- Get the selection set using the OdDbUserIO class
- //++-- you can iterate through the seletion set or
- //++-- use the objectIdArray() method
- //++-- note: the ids in the array are guaranteed to be valid
- OdString message = "\nSelect object(s) to be changed to the current layer: ";
- OdDbSelectionSetPtr pSelectionSet = pDbIO->select(message);
- OdDbObjectIdArray objectIdArray = pSelectionSet->objectIdArray();
- for (unsigned int i = 0 ; i setLayer(clayerId);
- }
- pDbIO->putString(_T("\nDone!"));
- }
- };
|