- 积分
- 19100
- 明经币
- 个
- 注册时间
- 2003-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2012-10-22 23:30:34
|
显示全部楼层
本帖最后由 BDYCAD 于 2012-10-22 23:46 编辑
正巧,我也用到这样的功能,只是行业应用不同,要求不同,我也简单贴上ARX代码,大家参考一下,新手也可以学习一下。高就也可指导一下。谢谢。
对于ARX 写这个功能应该是很简单。所以在止抛砖引玉,有望有空的大侠改写一份ARX程序用JIG动态较果的:)
- //--------------------------------支持程序--------------------------------------
- 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;
- }
- //凸度计算函数
- double GetBulgeOf3Pt(
- const AcGePoint3d &startPt //起点
- , const AcGePoint3d &interPt //中间一点
- , const AcGePoint3d &endPt //终点
- )
- {
- double dTmp;
- AcGeCircArc3d aa(startPt, interPt, endPt);
- dTmp = (startPt.x - endPt.x) * (interPt.y - endPt.y) - (interPt.x - endPt.x) * (startPt.y - endPt.y);
- //圆弧逆时针方向
- if (dTmp > 0) {
- return tan((aa.endAng() - aa.startAng()) * 0.25);
- }
- //圆弧顺时针方向
- else if (dTmp < 0) {
- return -tan((aa.endAng() - aa.startAng()) * 0.25);
- }
- return 0;
- }
- //--------------------------------支持程序--------------------------------------
- static void BDYCAD2012_RF(void)//20110720画足球场
- {
- ads_real KuanDu,ChangDu,Rtd,Ltd;
- ads_point p1,p2,p3,p4,p5,Lmp,Rmp,Pt;
- AcGePoint3d Spt,Pt1,Pt2,Pt3,Pt4,Mpt;
- ads_name Ename;
- AcDbObjectId PLineID,CID;
- AcDbBlockTableRecord *pModelSpace;
- if (acedGetDist(NULL,_T("\n请输入宽度:"),&KuanDu)!=RTNORM)return;
- if (acedGetDist(NULL,_T("\n请输入长度:"),&ChangDu)!=RTNORM)return;
- if (acedGetPoint(NULL,_T("\n请输入插入点"),Pt)!=RTNORM)return;
- Spt=asPnt3d(Pt);
- p1[X]=Spt.x-((0.5*ChangDu)-(0.5*KuanDu));
- p1[Y]=Spt.y-(0.5*KuanDu);
- p2[X]=Spt.x+(0.5*ChangDu)-(0.5*KuanDu);
- p2[Y]=Spt.y-(0.5*KuanDu);
- p3[X]=Spt.x+(0.5*ChangDu)-(0.5*KuanDu);
- p3[Y]=Spt.y+(0.5*KuanDu);
- p4[X]=Spt.x-((0.5*ChangDu)-(0.5*KuanDu));
- p4[Y]=Spt.y+(0.5*KuanDu);
- p5[X]=Spt.x-((0.3*ChangDu)-(0.5*KuanDu));
- p5[Y]=Spt.y-(0.5*KuanDu);
- Lmp[X]=Spt.x-(0.5*ChangDu);
- Lmp[Y]=Spt.y;
- Rmp[X]=Spt.x+(0.5*ChangDu);
- Rmp[Y]=Spt.y;
- AcDbPolyline *QKPline=new AcDbPolyline(4);//生成四个点的LWPOLYLINE式多段线开始
- pModelSpace= GetModelSpace(AcDb::kForWrite);
- pModelSpace->appendAcDbEntity(PLineID,QKPline);
- pModelSpace->close();
- QKPline->setLayer(_T("0"));
- AcGePoint2d Pl2pt;
- Pl2pt=asPnt2d(p1);
- QKPline->addVertexAt(0,Pl2pt);
- Pt1=asPnt3d(p2);
- Pt2=asPnt3d(Rmp);
- Pt3=asPnt3d(p3);
- Rtd=GetBulgeOf3Pt(Pt1,Pt2,Pt3);//右边凸度如果RisFillQK=FALSE凸度等于0,这样就是直线,
- Pl2pt=asPnt2d(p2);
- QKPline->addVertexAt(1,Pl2pt,Rtd);//PLINE起点为弧
- Pl2pt=asPnt2d(p3);
- QKPline->addVertexAt(2,Pl2pt);//PLINE起点为弧3
- Pt1=asPnt3d(p4);
- Pt2=asPnt3d(Lmp);
- Pt3=asPnt3d(p1);
- Ltd=GetBulgeOf3Pt(Pt1,Pt2,Pt3);//右边凸度如果RisFillQK=FALSE凸度等于0,这样就是直线,
- Pl2pt=asPnt2d(p4);
- QKPline->addVertexAt(3,Pl2pt,Rtd);//PLINE起点为弧
- Pl2pt=asPnt2d(p1);
- QKPline->addVertexAt(4,Pl2pt);//PLINE起点为弧
- //QKPline->setClosed(TRUE);
- QKPline->close();
- acdbGetAdsName(Ename,PLineID);
- acedCommand(RTSTR,_T("rotate"),RTLB,RTENAME,Ename,RT3DPOINT,p1,RTLE,RTSTR,_T(""),RT3DPOINT,Pt,0);
- return;
- }
|
|