天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 51|回复: 0

objectarx 图元矩阵转换

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
//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();
}

 

 

 

 

objectarx 图元矩阵转换
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 11:28 , Processed in 0.145893 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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