ARX 创建组实例(新建组,选择实体添加到组,输入层,修改组所在的层)

创建组实例


//创建组,把选择的实体放入组内,并改变组的层为新层
static void TESTgrpcmd()
{


CString strGrp;
if(acedGetString(0,_T("\n输入组名"),strGrp.GetBuffer(10)) != RTNORM)
{
return;
}
strGrp.ReleaseBuffer();


ads_name ss;
if(acedSSGet(NULL,NULL,NULL,NULL,ss) != RTNORM)
{
return;
}
CString strLayer;
if(acedGetString(0,_T("\n输入层名称"),strLayer.GetBuffer(10)) != RTNORM)
{
acedSSFree(ss);
return;
}


////创建组,改变层
AcDbGroup* pGrp = new AcDbGroup(strGrp);
long len ;
acedSSLength(ss,&len);
AcDbObjectId idObj;
ads_name enName;
AcDbEntity* pEnt;
ErrorStatus es;


for(int i = 0;i < len;i ++)
{
if(acedSSName(ss,i,enName) != RTNORM)
{
continue;
}
acdbGetObjectId(idObj,enName);
pGrp->append(idObj);
}
pGrp->setLayer(strLayer);




////把组添加到词典中
AcDbDictionary* pGrpDic;
acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGrpDic,AcDb::kForWrite);
AcDbObjectId idGrp;
pGrpDic->setAt(strGrp,pGrp,idGrp);

////释放内存
pGrp->close();
pGrpDic->close();
acedSSFree(ss);
}


你可能感兴趣的:(null)