|
- void ASDKtestOrd()
- {
- ads采用point pt1;
- if( RTNORM != acedGetPoint(NULL,L"\n Select point for ord dim", pt1) )
- {return;}
- AcGePoint3d ptx1(pt1[X],pt1[Y],pt1[Z]);
- AcGePoint3d pT2;
- AcGeMatrix3d mx;
- AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
- if ( !acdbUcsMatrix(mx, pDb) )
- {
- return;
- }
- //pT2 is the point for the leader
- pT2[0] = ptx1[0];
- pT2[1] = ptx1[1]-3.0; //leader point dropped down 3 units below
- pT2[2] = ptx1[2];
- AcDbOrdinateDimension *pDim = new AcDbOrdinateDimension(Adesk::kTrue,ptx1,pT2,NULL,NULL);
- //Xaxis
- AcGeVector3d mXPrev = AcGeVector3d::kXAxis;
- //get the old HorizontalRotation
- double mOldHorzRot = pDim->horizontalRotation();
- AcGeMatrix3d mMat; //matrix to build the ECS
- //get the old Xaxis and transform it to current plane
- mMat.setToPlaneToWorld(pDim->normal()); //ECS
- mXPrev.transformBy(mMat); //get the ECS xaxis in the world coordinates
- mXPrev.transformBy(mx); //tranform the current xaxis to new plane defined by mx.
- //transform the dimension entity by the given transformation matrix
- pDim->transformBy(mx);
- //get the xAxis after transformation of the dimension entity
- mMat.setToWorldToPlane(pDim->normal());
- mXPrev.transformBy(mMat); //transform the old axis to the current ECS.
- //get the angle of the old xaxis with respect to the current xaxis
- double mNewHorzRot = - atan2(mXPrev.y, mXPrev.x);
- pDim->setHorizontalRotation(mOldHorzRot + mNewHorzRot);
- AcDbBlockTable *pBlockTableD;
- acdbHostApplicationServices()->workingDatabase()
- ->getSymbolTable(pBlockTableD, AcDb::kForRead);
- AcDbBlockTableRecord *pBlockTableRecordD;
- pBlockTableD->getAt(ACDB采用MODEL采用SPACE, pBlockTableRecordD, AcDb::kForWrite);
- pBlockTableD->close();
- AcDbObjectId dimIdD;
- pBlockTableRecordD->appendAcDbEntity(dimIdD, pDim);
- pBlockTableRecordD->close();
- pDim->close();
- }
复制代码 |
|