[cpp] view plain copy
- //添加自定义样式========================
- static void TESTaddstylecmd(){
- CString strName;
- if(acedGetString(Adesk::kFalse,_T("\n输入样式名称"),strName.GetBuffer()) != RTNORM){
- return;
- }
- ////获得当前图形的标注样式表
- AcDbDimStyleTable* pDimStyleTbl;
- acdbHostApplicationServices()->workingDatabase()->getDimStyleTable(pDimStyleTbl,AcDb::kForWrite);
- ////是否已包含
- if(pDimStyleTbl->has(strName)){
- pDimStyleTbl->close();
- return;
- }
- ////创建新的标注样式表
- AcDbDimStyleTableRecord* pDimStyleTblRcd;
- pDimStyleTblRcd = new AcDbDimStyleTableRecord();
- ////设置标注样式的特性
- pDimStyleTblRcd->setName(strName);
- pDimStyleTblRcd->setDimasz(3);////箭头长度
- pDimStyleTblRcd->setDimexe(3);//尺寸线与标注的点偏移量
- pDimStyleTblRcd->setDimtad(1);////文字位于标注线上方
- pDimStyleTblRcd->setDimtxt(3);////标注文字的高度
- ////将标注样式表记录添加到标注样式表中
- pDimStyleTbl->add(pDimStyleTblRcd);
- pDimStyleTblRcd->close();
- pDimStyleTbl->close();
- }
时间: 2024-11-13 09:34:12