我是一个ARX二次开发CAD的新手,做了一个尺寸自动标注的程序,部分代码如下:
AcDbDatabase *pcurdb=acdbHostApplicationServices()->workingDatabase(); AcDbDimStyleTable *pnewdimtable; pcurdb->getSymbolTable(pnewdimtable,AcDb::kForWrite); AcDbDimStyleTableRecord *pnewdimrecord=new AcDbDimStyleTableRecord(); pnewdimrecord->setDimasz(20);//设置箭头大小 pnewdimrecord->setDimzin(8);//十进制小数显示时,抑制后续零 pnewdimrecord->setDimexe(30);//设置尺寸界线超出尺寸线距离为400 pnewdimrecord->setDimexo(0);//设置尺寸界线的起点偏移量为300 pnewdimrecord->setDimtxt(30);//设置文字高度 pnewdimrecord->setDimtad(1);//设置文字位置-垂直为上方,水平默认为居中,不用设置 pnewdimrecord->setDimgap(10);//设置文字位置-从尺寸线的偏移量 pnewdimrecord->setDimtih(0); pnewdimrecord->setDimtix(1);//设置标注文字始终绘制在尺寸界线之间 pnewdimrecord->setDimtofl(1);//即使箭头放置于测量点之外,尺寸线也将绘制在测量点之间 // pnewdimrecord->setDimgap(0.5); color.setColorIndex(iDimColor); pnewdimrecord->setDimclrd(color); //尺寸线颜色 pnewdimrecord->setDimclre(color); //尺寸边界线颜色 color.setColorIndex(iTextColor); pnewdimrecord->setDimclrt(color); //文字颜色
AcDbObjectId dimrecordid; pnewdimtable->add(dimrecordid,pnewdimrecord); pnewdimtable->close(); pnewdimrecord->close(); AcGePoint3d Pt1(KD[k].ZB_X+t,KD[k].ZB_Y+t,0); AcGePoint3d Pt2(DY.m_Chang+t,KD[k].ZB_Y+t,0); AcGePoint3d Pt3(KD[k].ZB_X+t,DY.m_Kuan+t+150+k*70,0); AcGePoint3d Pt6(KD[k].ZB_X+t-KD[k].KongJing/2*cos(PI/4.0),KD[k].ZB_Y+t+KD[k].KongJing/2*sin(PI/4.0),0); AcGePoint3d Pt7(KD[k].ZB_X+t+KD[k].KongJing/2*cos(PI/4.0),KD[k].ZB_Y+t-KD[k].KongJing/2*sin(PI/4.0),0); AcDbBlockTable *pBlockTable;//定义块表指针 acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTable, AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); pBlockTable->close(); AcDbAlignedDimension *pDim1 = new AcDbAlignedDimension(Pt1, Pt2,Pt3,NULL,dimrecordid); AcDbDiametricDimension *pDim3 = new AcDbDiametricDimension(Pt6, Pt7,leaderLength,dimText,dimrecordid); pDim3->setLeaderLength(20); AcDbObjectId Id; pBlockTableRecord->appendAcDbEntity(Id, pDim1); pBlockTableRecord->appendAcDbEntity(Id, pDim3); pBlockTableRecord->close(); pDim1->close(); pDim3->close();
现在我希望标出的值是图形实际尺寸的一半,而不是尺寸的实际值,不知道对程序怎样操作。恳请高手不吝赐教,再次表示感谢,鲜花赠上 |