嗨…
我正在做一个应用程序来获取选定的圆的圆心和半径
如果我选择了实体,它应该会显示出来。请帮帮我。
我的代码是
-
- [code]void CDbModReactor::objectModified(const AcDbDatabase* pDb,
- const AcDbObject* pDbObj)
- {
- AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);
- if(docLock.lockStatus() != Acad::eOk)
- return;
- else
- objDisplay("modified", pDbObj);
- }
- void objDisplay(const char* pWhat, const AcDbObject* pDbObj)
- {
- if(!gpDlg)
- return;
- char hstr[20];
- char idstr[20];
- const char *pClsName = NULL;
- double pRadius, y_value;
- if(pDbObj)
- {
- AcDbObjectId id = pDbObj->objectId();
- AcDbHandle h;
- pClsName = pDbObj->isA()->name();
- pDbObj->getAcDbHandle(h);
- h.getIntoAsciiBuffer(hstr);
- //acutPrintf("\nDbModReactor: obj %s: "
- // "class %s, id %lx, handle %f.\n",
- // pWhat, pClsName , id, idstr);
- //sprintf(idstr, "0x%08lx", id);
- }
- else
- {
- pClsName = "";
- strcpy(hstr, "");
- strcpy(idstr, "");
- }
- ads_name ss;
- if( RTNORM !=
- acedSSGet("P",NULL,NULL,NULL,ss))
- {
- // Get Previous selection set
- if( RTNORM != acedSSGet(NULL,NULL,NULL,NULL,ss))
- {
- acDocManager->unlockDocument(acDocManager->curDocument());
- return;
- }
- }
- long nEnts;
- acedSSLength(ss,&nEnts);
- AcDbObjectIdArray entities(nEnts);
- //acutPrintf("\nFound %d Entities", nEnts);
- CString Tot_Cir;
- Tot_Cir.Format("%d",nEnts);
- gpDlg->SetDlgItemText(IDC_EDIT1, Tot_Cir);
- AcDbCircle* pCircle = AcDbCircle::cast(pDbObj);
- if(pCircle == NULL)
- return;
- AcGePoint3d pCenter = pCircle->center();
- y_value = pCenter.y;
- pRadius = pCircle->radius();
- //acutPrintf("Selected object Y value %f\n", y_value);
- //acutPrintf("Selected object X value %f\n", pCenter);
- Cir_Radius.Format("%f",pRadius);
- Cent_X.Format("%f",pCenter);
- Cent_Y.Format("%f",y_value);
- m_lstCtrl.InsertItem(0,Cent_X);
- m_lstCtrl.SetItemText(0,1,Cent_Y);
- FILE * pFile;
- pFile = fopen ("C:myfile.csv","a");
- if (pFile!=NULL)
- {
- CString x2 = Cent_X+","+Cent_Y+"\n";
- fwrite(x2, x2.GetLength(), 1, pFile);
- fclose (pFile);
- }
- acedSSFree(ss);
- }
[/code]
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |