- 积分
- 19100
- 明经币
- 个
- 注册时间
- 2003-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2009-3-10 08:34:00
|
显示全部楼层
三点画弧ARX源代码:- AcDbBlockTableRecord *GetModelSpace(AcDb::OpenMode Mode){
- AcDbDatabase *pDwg = acdbHostApplicationServices()->workingDatabase();
- AcDbBlockTable *pBlockTable;
- AcDbBlockTableRecord *pModelSpace;
- pDwg->getSymbolTable(pBlockTable, AcDb::kForRead);
- pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);
- pBlockTable->close();
- return pModelSpace;
- }
- //功能:三点画弧
- //编程:包达勇
- //时间:20080812
- AcDbObjectId CreateArc(ads_point pt1,ads_point pt2,ads_point pt3){
- bool LongARC=FALSE;
- AcDbCurve *pCur;
- AcDbArc *pArc;
- ads_point /*pt1,pt2,pt3,*/cpt,mp1,mp2,mp3,mp4;
- ads_real GDist1,GDist2,Dist,Angle1,Angle2,Radius,StartAngle,EndAngle;
- GDist1=GDist2=0;
- AcGePoint3d Mid,Mp1,Mp2,Cpt;
- AcGePoint3d Spt,Mpt,Ept;
- Spt=asPnt3d(pt1);Mpt=asPnt3d(pt2);Ept=asPnt3d(pt3);
- Mid=Mpt;
- Dist=acutDistance(pt1,pt2);
- Angle1=acutAngle(pt1,pt2);
- Angle2=acutAngle(pt3,pt2);
- acutPolar(pt1,Angle1,acutDistance(pt1,pt2)*0.5,mp1);
- acutPolar(pt3,Angle2,acutDistance(pt3,pt2)*0.5,mp2);
- acutPolar(mp1,Angle1+(pi*0.5),Dist,mp3);
- acutPolar(mp2,Angle2+(pi*0.5),Dist,mp4);
- acdbInters(mp1,mp3,mp2,mp4,FALSE,cpt);
- Cpt=asPnt3d(cpt);
- Radius=acutDistance(cpt,pt2);
- StartAngle=acutAngle(cpt,pt1);
- EndAngle=acutAngle(cpt,pt3);
- AcDbObjectId ObjID,ObjID1,ObjID2;
- AcDbBlockTableRecord *pModelSpace =GetModelSpace(AcDb::kForWrite);
- AcDbArc *Narc1=new AcDbArc(Cpt,Radius,StartAngle,EndAngle);
- AcDbArc *Narc2=new AcDbArc(Cpt,Radius,EndAngle,StartAngle);
- pModelSpace->appendAcDbEntity(ObjID1,Narc1);
- pModelSpace->appendAcDbEntity(ObjID2,Narc2);
- Narc1->close();
- Narc2->close();
- pModelSpace->close();
- acdbOpenObject(pCur,ObjID1,AcDb::kForRead);
- pCur->getDistAtPoint(Mid,GDist1);
- pCur->close();
- acdbOpenObject(pCur,ObjID2,AcDb::kForRead);
- pCur->getDistAtPoint(Mid,GDist2);
- pCur->close();
- if (GDist1>GDist2) {
- EraseEntity(ObjID2);
- ObjID=ObjID1;
- }else{
- EraseEntity(ObjID1);
- ObjID=ObjID2;
- }
- return ObjID;
- }
复制代码 |
|