void Additional_Class::Insert_TableRow( AcDbObjectId TableID, vector<CString> StrList) { AcDbEntity *pEnt_Temp = NULL; Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, TableID, AcDb::kForRead); if (es != Acad::eOk) { acutPrintf(_T("\nOPEN TABLE ERROR")); return; } if (!pEnt_Temp->isKindOf(AcDbTable::desc())) { acutPrintf(_T("\nENTITY NOT TABLE")); return; } AcDbTable *pTable = AcDbTable::cast(pEnt_Temp); int Row = pTable->numRows(); int Col = pTable->numColumns(); if (Col < StrList.size()) { acutPrintf(_T("\nTABLE ERROR")); pTable->close(); return; } double RowHeight = pTable->rowHeight(0); double TextHeight = pTable->textHeight(0, 0); pTable->insertRows(Row, RowHeight,1); for (int i=0; i<StrList.size(); i++) { pTable->setTextString(Row, i, StrList.at(i)); pTable->setTextHeight(Row, i,TextHeight); } pTable->close(); pEnt_Temp->close(); }
AcDbObjectId Additional_Class::Creat_Table(AcGePoint3d TablePoint, vector<CString> Title, double ColWidth, double RowHeight, double TextHeight) { AcDbTable *pTable = new AcDbTable(); AcDbObjectId TableID; pTable->setNumColumns(Title.size()); pTable->setNumRows(1); pTable->setColumnWidth(ColWidth); pTable->setRowHeight(RowHeight); pTable->setDirection(AcGeVector3d(1,0,0)); pTable->setNormal(AcGeVector3d(0,0,1)); pTable->setPosition(TablePoint); AcDbBlockTable *pBlockTable; AcDbBlockTableRecord *pBlockTableRecord; acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead); pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite); pBlockTableRecord->appendAcDbEntity(TableID, pTable); //pBlockTable->close(); pBlockTableRecord->close(); //pTable->setTextString(0,0, "桩 号"); //pTable->setTextHeight(0,0,10); //pTable->setTextString(0,1, "X坐标值"); //pTable->setTextHeight(0,1,10); //pTable->setTextString(0,2, "Y坐标值"); //pTable->setTextHeight(0,2,10); //pTable->setTextString(0,3, "特性值"); //pTable->setTextHeight(0,3,10); //pTable->setTextString(0,4, "长 度"); //pTable->setTextHeight(0,4,10); pTable->close(); return TableID; }
void Additional_Class::Change_TablePoint( AcDbObjectId TableID,AcGePoint3d newPt ) { AcDbEntity *pEnt_Temp; if (acdbOpenAcDbEntity(pEnt_Temp, TableID, AcDb::kForWrite)!= Acad::eOk) { acutPrintf(_T("\nOPEN TABLE ERROR")); return; } if (!pEnt_Temp->isKindOf(AcDbTable::desc())) { acutPrintf(_T("\nENTITY NOT TABLE")); return; } AcDbTable *pTableChange; pTableChange = AcDbTable::cast(pEnt_Temp); pTableChange->setPosition(newPt); pEnt_Temp->close(); pTableChange->close(); return; }
void generateInventarTable(std::map<std::wstring, AcGePoint3d>& m_points, double textHeight) { Acad::ErrorStatus es; AcGePoint3d insertionPoint; AcDbObjectId objectID; AcDbTable* pTable = nullptr; AcDbDictionary* pDic = nullptr; AcDbBlockTable* pBT = nullptr; AcDbBlockTableRecord* pBTR = nullptr; AcDbDatabase*pDb = nullptr; u_int nrRows = m_points.size() + 2; double headerHeight = textHeight + ((textHeight * HEADERPERCENT) / 100); double titleHeight = textHeight + ((textHeight * TITLEPERCENT) / 100); double nrpctWidth = 0.0; int ret = acedGetPoint(NULL, _T("\nSelecteaza punctul de insertie al tabelului "), asDblArray(insertionPoint)); AcDbObjectId textID = Utils::NewTextStyle(_T("TableStyle"), titleHeight); pDb = acdbHostApplicationServices()->workingDatabase(); pBTR = new AcDbBlockTableRecord; pDb->getSymbolTable(pBT, AcDb::kForRead); pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite); pBT->close(); es = pDb->getTableStyleDictionary(pDic, AcDb::kForWrite); es = pDic->getAt(_T("Standard"), objectID); es = pDic->close(); pTable = new AcDbTable; pTable->setTableStyle(objectID); pTable->setSize(nrRows, NUM_COL); pTable->setAlignment(AcDb::kMiddleCenter); pTable->setTextHeight( titleHeight,AcDb::kTitleRow); pTable->setTextHeight(headerHeight, AcDb::kHeaderRow); pTable->setTextHeight(textHeight, AcDb::kDataRow); //pTable->setTextStyle(objectID); pTable->setTextStyle(0, 0, textID); pTable->setTextString(0, 0, _T("Inventar de coordonate")); double tableWidth = Utils::GetTextWidth(_T("Inventar@de@coordonate"), _T("TableStyle")); pTable->setWidth(tableWidth + (tableWidth * 15) / 100); pTable->setTextString(1, 0, _T("Nr.\npct.")); pTable->setTextStyle(1,0, textID); nrpctWidth = Utils::GetTextWidth(_T("NRPCT"), _T("TableStyle")); pTable->setColumnWidth(0,nrpctWidth); pTable->setTextStyle(1, 1, textID); pTable->setTextString(1, 1, _T("X[m]")); pTable->setTextStyle(1, 2, textID); pTable->setTextString(1, 2, _T("Y[m]")); std::map<std::wstring, AcGePoint3d>::iterator it = m_points.begin(); for (u_int row = 0; row < nrRows; row++) { //double tempWidth = Utils::GetTextWidth(Utils::int_To_wstring(row + 1).c_str(),_T("TableStyle")); //if (tempWidth > nrpctWidth) //{ // nrpctWidth = tempWidth; // pTable->setColumnWidth(0, nrpctWidth); //} pTable->setTextStyle(row + 2, 0, textID); pTable->setTextString(row + 2, 0, Utils::int_To_wstring(row+1).c_str()); //nr. curent pTable->setTextStyle(row + 2, 1, textID); pTable->setTextString(row + 2, 1, Utils::real_To_wstring(it->second.y).c_str()); // valoare X pTable->setTextStyle(row + 2, 2, textID); pTable->setTextString(row + 2, 2, Utils::real_To_wstring(it->second.x).c_str()); // valoare Y it++; } pTable->generateLayout(); pTable->setPosition(insertionPoint); pBTR->appendAcDbEntity(pTable); pBTR->close(); pTable->close(); }