找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 740|回复: 1

[每日一码] AcDbRegion::transformBy在2014和2015结果不同的解决方案

[复制链接]

已领礼包: 13个

财富等级: 恭喜发财

发表于 2018-6-19 08:00:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Question:  
I have a situation where the use of the method AcDbRegion::transformBy is giving me different results in AutoCAD 2015 as opposed to AutoCAD 2014. Can you tell me what has changed in the method that would account for the change.

Answer :
It worked in Acad 2014 because we used a bigger tolerance before (equalPoint to 1.0e-8 and  equalVector to 1.0e-6). In Acad 2015 the tolerance setting was removed,this change is having impact on few scenarios ,one such scenario is illustrated below and possible workaround is also demonstrated. Thanks to our ADN partner for surfacing this behavior.

To restore legacy behavior in such circumstances we may have to reset system wide tolerance to

/*Resetting sytsem wide tolerance for ACAD 2015*/

AcGeContext::gTol.setEqualPoint(1.0e-8);

AcGeContext::gTol.setEqualVector(1.0e-6);



  1. static void transformTest()
  2. {
  3.         /*Resetting sytsem wide tolerance for ACAD 2015*/
  4.         AcGeContext::gTol.setEqualPoint(1.0e-8);
  5.         AcGeContext::gTol.setEqualVector(1.0e-6);

  6.         double epTol = AcGeContext::gTol.equalPoint();
  7.         double evTol = AcGeContext::gTol.equalVector();

  8.         CString msg;
  9.         msg.Format(_T("point tolerance is %e, and vector tolerance is %e\n"), epTol, evTol);
  10.         acedPrompt(msg);

  11.         // Second, create a transform matrix that maps from one coordinate syste to another

  12.         AcGePoint3d startPoint;
  13.         AcGeVector3d mStockProfileXDir, mExtrudeDir, mNormalDir;

  14.         startPoint.set(12342.705102605765, -14874.057509290647, 25.766600469474248);

  15.         mStockProfileXDir.set(0.00000000000000000, 1.0000000000000000, 0.00000000000000000);
  16.         mNormalDir.set(-0.048960818631765893, -6.4357153980460105e-012, 0.99880069995915965);
  17.         mExtrudeDir.set(-0.99880069995915977, 0.00000000000000000, -0.048960818631764047);

  18.         AcGeMatrix3d xform;
  19.         xform.setToAlignCoordSys(AcGePoint3d(0, 0, 0),
  20.                 AcGeVector3d::kXAxis,
  21.                 AcGeVector3d::kYAxis,
  22.                 AcGeVector3d::kZAxis,
  23.                 startPoint,
  24.                 mStockProfileXDir,
  25.                 mNormalDir,
  26.                 mExtrudeDir);

  27.         // Is the new coordinate system orthogonal?

  28.         if (!xform.isUniScaledOrtho())
  29.                 acedPrompt(_T("Transform matrix axes are not orthogonal\n"));
  30.         else
  31.                 acedPrompt(_T("Transform matrix axes are orthogonal\n"));


  32.         // Finally, transform a region to the new coordinate system.
  33.         AcDbVoidPtrArray curves, regions;
  34.         AcDbCircle *pTestCircle = new AcDbCircle(AcGePoint3d::kOrigin, AcGeVector3d::kZAxis, 10.0);

  35.         if (pTestCircle != NULL)
  36.         {
  37.                 curves.append(pTestCircle);

  38.                 AcDbRegion::createFromCurves(curves, regions);
  39.                 if (regions.length() != 0)
  40.                 {
  41.                         for (int i = 0; i < regions.length(); i++)
  42.                         {
  43.                                 AcDbRegion* testRegion = static_cast<AcDbRegion*>(regions);
  44.                                 Acad::ErrorStatus es = testRegion->transformBy(xform);
  45.                                 delete testRegion;
  46.                                 msg.Format(_T("The transform operation returned %d\n"), es);
  47.                                 acedPrompt(msg);
  48.                         }
  49.                 }

  50.                 delete pTestCircle;
  51.         }
  52. }


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 112个

财富等级: 日进斗金

发表于 2018-6-26 12:30:07 | 显示全部楼层
谢谢楼主分享,这个细节还没有发现,挺好的资料
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-22 11:13 , Processed in 0.395787 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表