找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 154|回复: 0

[每日一码] ARX - Ordinate Dimension Text 在旋转UCS下不正确的解决方案

[复制链接]

0

主题

0

回帖

26

积分

管理员

积分
26
发表于 2024-2-26 10:30:52 | 显示全部楼层 |阅读模式
  1. void ASDKtestOrd()
  2. {
  3.     ads采用point pt1;
  4.     if( RTNORM != acedGetPoint(NULL,L"\n Select point for ord dim", pt1) )
  5.        {return;}
  6.     AcGePoint3d ptx1(pt1[X],pt1[Y],pt1[Z]);
  7.     AcGePoint3d pT2;
  8.     AcGeMatrix3d mx;
  9.     AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
  10.     if ( !acdbUcsMatrix(mx, pDb) )
  11.     {
  12.        return;
  13.     }
  14.     //pT2 is the point for the leader
  15.     pT2[0] = ptx1[0];
  16.     pT2[1] = ptx1[1]-3.0; //leader point dropped down 3 units  below
  17.     pT2[2] = ptx1[2];
  18.     AcDbOrdinateDimension *pDim = new AcDbOrdinateDimension(Adesk::kTrue,ptx1,pT2,NULL,NULL);
  19.     //Xaxis
  20.     AcGeVector3d mXPrev = AcGeVector3d::kXAxis;
  21.     //get the old HorizontalRotation
  22.     double mOldHorzRot = pDim->horizontalRotation();
  23.     AcGeMatrix3d mMat; //matrix to build the ECS
  24.     //get the old Xaxis and transform it to current plane
  25.     mMat.setToPlaneToWorld(pDim->normal()); //ECS
  26.     mXPrev.transformBy(mMat); //get the ECS xaxis in the world coordinates
  27.     mXPrev.transformBy(mx); //tranform the current xaxis to new plane defined by mx.
  28.     //transform the dimension entity by the given transformation matrix
  29.     pDim->transformBy(mx);
  30.     //get the xAxis after transformation of the dimension entity
  31.     mMat.setToWorldToPlane(pDim->normal());
  32.     mXPrev.transformBy(mMat); //transform the old axis to the current ECS.
  33.     //get the angle of the old xaxis with respect to the current xaxis
  34.     double mNewHorzRot = - atan2(mXPrev.y, mXPrev.x);
  35.     pDim->setHorizontalRotation(mOldHorzRot + mNewHorzRot);
  36.     AcDbBlockTable *pBlockTableD;
  37.     acdbHostApplicationServices()->workingDatabase()
  38.        ->getSymbolTable(pBlockTableD, AcDb::kForRead);
  39.     AcDbBlockTableRecord *pBlockTableRecordD;
  40.     pBlockTableD->getAt(ACDB采用MODEL采用SPACE, pBlockTableRecordD, AcDb::kForWrite);
  41.     pBlockTableD->close();
  42.     AcDbObjectId dimIdD;
  43.     pBlockTableRecordD->appendAcDbEntity(dimIdD, pDim);
  44.     pBlockTableRecordD->close();
  45.     pDim->close();
  46. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-28 13:59 , Processed in 0.137337 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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