|
- 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();
复制代码
设置自动标注的精度pnewdimrecord->setDimdec(2); //小数点后两位
设置标出的值是图形实际尺寸的一半,而不是尺寸的实际值
AcDbRotatedDimension *pdim;pdim->setDimlfac(0.5)
在我们建立标注样式或文字样式时都习惯把他们设一个名字,如setName(采用T("仿宋"))
但是取了名字之后有一个问题就是,下次再调用这个程序是,如果程序识别到已经有这个名字的存在,它就不会再对样式表进行设置了,所以我们很多时候调用了一次,下次调用发现根本就没起作用就是这个道理。(当然这也是我自己的判断) |
|