admin 发表于 2024-6-5 07:54:04

创建匿名组

int acdbAddAnonGrpRet2Lsp()

{

// TODO: Implement the command

resbuf *pArg =acedGetArgs ();



struct resbuf *startRb = NULL;

AcDbGroup *pGroup = new AcDbGroup();

AcDbObjectId grpId;

AcDbDictionary *pGroupDict;

Acad::ErrorStatus es;

AcApDocument *curDoc;



//get the group dictionary

AcDbDatabase *pDb = acdbHostApplicationServices()->

workingDatabase();

if (Acad::eOk == (es = acDocManager->lockDocument(

curDoc=acDocManager->curDocument())))

es = pDb->getGroupDictionary(pGroupDict,AcDb::kForWrite);



if (es != Acad::eOk)

return es;





//make an anonymous entry

if ((es = pGroupDict->setAt(L"*", pGroup, grpId)) ==

Acad::eOk) {

//retrieve its name char *pNam;

pGroup->close();

}



// create a resbuf with our ObjectID in it

struct resbuf *newRb = acutBuildList (RTLONG, grpId, RTNONE);

// if ok

if (newRb != NULL) {

// if this is the first time we've done this

if (startRb == NULL) {

   // then set this as the start

   startRb = newRb;

}

// otherwise add it to the end of our list

else {

   // create a pointer to the beginning of our resbuf list

   struct resbuf *ptr = startRb;

   // find the end of our list

   while (ptr->rbnext != NULL)

    ptr = ptr->rbnext;

   // now attach our newly create resbuf to the end

   ptr->rbnext = newRb;

}

}



pGroupDict->close();

acDocManager->unlockDocument(curDoc);



acedRetList(startRb);

acutRelRb(startRb);

return (RTNORM);

}
页: [1]
查看完整版本: 创建匿名组