- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 csharp 于 2016-3-13 08:41 编辑
环境 Windows 10 32bit + VS2008 + AutoCAD 2010
问题一: AcDbCurve::getOffsetCurves() 距离正负对 AcDbLine 竟然和其它曲线相反,其它曲线正常时,AcDbLine 结果就反了,下面是模拟 Offset 通过点偏移- <div>
- static double IsLeft(AcGeVector3d &A,AcGeVector3d &B)
- {
- return (A.x*B.y-A.y*B.x);
- }
- static void asdkMyGroupMyOffset()
- {
- Acad::ErrorStatus es;
- ads_name ent;
- ads_point p1,p2;
- AcDbObjectId id;
- AcDbEntity *pEnt=NULL;
- AcGePoint3d pt;
- AcGeVector3d vec;
- AcDbVoidPtrArray dbs;
- int ret=acedEntSel(L"\nPick Curve: ",ent,p1);
- if (ret!=RTNORM)
- {
- return;
- }
- do
- {
- if (RTNORM!=acedGetPoint(p1,L"\nThrough Point: ",p2))
- {
- return;
- }
- acdbGetObjectId(id,ent);
- acdbOpenObject(pEnt,id,AcDb::kForRead);
- if (!pEnt->isKindOf(AcDbCurve::desc()))
- {
- pEnt->close();
- return;
- }
- AcDbCurve *pCurve=AcDbCurve::cast(pEnt);
- es=pCurve->getClosestPointTo(asPnt3d(p2) ,pt);
- pCurve->getFirstDeriv(pt,vec);
- if (es!=Acad::eOk)
- {
- pEnt->close();
- return;
- }
- double dist=pt.distanceTo(asPnt3d(p2));
- if (IsLeft(asPnt3d(p2)-pt,vec) <0)
- {
- dist*=-1;
- }
- dbs.setLogicalLength(0);
- dbs.setPhysicalLength(0);
- pCurve->getOffsetCurves(dist,dbs);//此处 AcDbLine 和其它曲线正负规则相反
- if (!dbs.isEmpty())
- {
- AcDbBlockTableRecordPointer btr(curDoc()->database()->currentSpaceId(),AcDb::kForWrite);
- if (btr.openStatus()!=Acad::eOk)
- {
- pEnt->close();
- return
- }
- for (int i=0;i<dbs.logicalLength();i++)
- {
- AcDbEntity *pEnt1=(AcDbEntity *)dbs.at(i);
- btr->appendAcDbEntity(pEnt1);
- pEnt1->close();
- }
- }
- pEnt->close();
- ret=acedEntSel(L"\nPick Curve: ",ent,p1);
- } while (ret == RTNORM);
- }
- </div>
复制代码 问题二: VS2010 + AutoCAD 2014中调试一到 AcDbCurve::getClosestPointTo() 函数处 AutoCAD 直接挂掉 |
|