|
//void testAlignCoordSysToVectorPlane(){
static void MyGroupMyCommand4 () {
AcTransaction* pTrans = actrTransactionManager->startTransaction();
AcDbObjectId blkTabId = acdbHostApplicationServices()->workingDatabase()->blockTableId();
AcDbBlockTable* pBlkTab = NULL;
pTrans->getObject((AcDbObject*&)pBlkTab, blkTabId, AcDb::kForRead);
AcDbObjectId msId;
AcDbBlockTableRecord* pMS = NULL;
pBlkTab->getAt(ACDB_MODEL_SPACE, msId);
pTrans->getObject((AcDbObject*&)pMS, msId, AcDb::kForWrite);
AcGePoint3d orig(0,0,0);
AcGeVector3d worldNorm(0,0,1);
AcGeMatrix3d transMat;
AcDbCircle* pCirc1 = new AcDbCircle(orig, worldNorm, 1);
AcDbCircle* pCirc2 = new AcDbCircle(orig, worldNorm, 1);
AcDbLine* pLine1 = new AcDbLine(orig, AcGePoint3d(0,0,2));
AcDbLine* pLine2 = new AcDbLine(orig, AcGePoint3d(0,0,2));
AcDbLine* pLine1a = new AcDbLine(orig, AcGePoint3d(0,0,2));
AcDbLine* pLine2a = new AcDbLine(orig, AcGePoint3d(0,0,2));
pCirc1->setColorIndex(1);
pCirc2->setColorIndex(2);
pLine1->setColorIndex(1);
pLine2->setColorIndex(2);
// Transform pCirc1 & pLine1
AcGePoint3d toPnt1(2.3, 4.5, 7.8);
AcGeVector3d dir1(0.1234, -0.72361, -0.75);
AcDbLine* pLine3a = new AcDbLine(toPnt1, toPnt1+dir1);
AcGeVector3d xAxis1 = dir1.perpVector();
AcGeVector3d yAxis1 = dir1.crossProduct(xAxis1);
AcDbLine* pLine1b = new AcDbLine(toPnt1, toPnt1+xAxis1);
xAxis1.normalize();
yAxis1.normalize();
dir1.normalize();
transMat.setToAlignCoordSys(orig, AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis, toPnt1, xAxis1, yAxis1, dir1);
pCirc1->transformBy(transMat);
pLine1->transformBy(transMat);
// Transform pCirc2 & pLine2
AcGePoint3d toPnt2(5.5, 3.6, 2.0);
AcGeVector3d dir2(1, 1, 1);
AcDbLine* pLine4a = new AcDbLine(toPnt2, toPnt2+dir2);
AcGeVector3d xAxis2, yAxis2;
AcGePlane Plane (toPnt2, dir2);
AcGePoint3d pt;
Plane.get(pt, xAxis2, yAxis2);
xAxis2.normalize();
yAxis2.normalize();
dir2.normalize();
transMat.setToAlignCoordSys(orig, AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis, toPnt2, xAxis2, yAxis2, dir2);
pCirc2->transformBy(transMat);
pLine2->transformBy(transMat);
// Add the entities
pMS->appendAcDbEntity(pCirc1);
pMS->appendAcDbEntity(pCirc2);
pMS->appendAcDbEntity(pLine1);
pMS->appendAcDbEntity(pLine2);
pMS->appendAcDbEntity(pLine1a);
pMS->appendAcDbEntity(pLine2a);
pMS->appendAcDbEntity(pLine3a);
pMS->appendAcDbEntity(pLine4a);
actrTransactionManager->addNewlyCreatedDBRObject(pCirc1);
actrTransactionManager->addNewlyCreatedDBRObject(pCirc2);
actrTransactionManager->addNewlyCreatedDBRObject(pLine1);
actrTransactionManager->addNewlyCreatedDBRObject(pLine2);
actrTransactionManager->addNewlyCreatedDBRObject(pLine1a);
actrTransactionManager->addNewlyCreatedDBRObject(pLine2a);
actrTransactionManager->addNewlyCreatedDBRObject(pLine3a);
actrTransactionManager->addNewlyCreatedDBRObject(pLine4a);
actrTransactionManager->endTransaction();
} |
|