ObjectArx尺寸標註設置

轉載自:http://blog.sina.com.cn/s/blog_4c4a15950100rm0x.html

 


   

   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("仿宋"))

但是取了名字之後有一個問題就是,下次再調用這個程序是,如果程序識別到已經有這個名字的存在,它就不會再對樣式表進行設置了,所以我們很多時候調用了一次,下次調用發現根本就沒起作用就是這個道理。(當然這也是我自己的判斷)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章