找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 296|回复: 0

[ARX程序]:求助!3维实体的问题!

[复制链接]
发表于 2004-8-8 11:25:28 | 显示全部楼层 |阅读模式

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

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

×
本人现在做一个3维实体,可是在同一个平面上好用,在空间就出现问题了,主要是圆锥不符合要求,请高手们指点改正!!谢谢
下面是程序:
        AcGePoint3d pt3,pt4;
        double slopy1,cosy1,siny1;
        CString strSql;
acedCommand(RTSTR,"shademode",RTSTR,"g",RTNONE);
    double length;
        CDatabase db1;
    if (db1.Open(_T( "vendata" ), FALSE, FALSE, _T( "ODBC;UID=sa;PWD=" )))
        {
        CFcData     fdb;
                int j;
                strSql.Format("select * from fcariways");
                j=fdb.Open(AFX_DB_USE_DEFAULT_TYPE,strSql);
                if (j==0)
                {
                        acutPrintf("\n 读取网络图数据失败!");
                }
                else
                {
                        fdb.MoveFirst();
                        while(!fdb.IsEOF())
                        {               
                pt4.x=fdb.m_strpointx; pt4.y=fdb.m_strpointy; pt4.z=fdb.m_strpointz;
                                pt3.x=fdb.m_endpointx; pt3.y=fdb.m_endpointy; pt3.z=fdb.m_endpointz;

                                AcGeMatrix3d xfrom4;
                                xfrom4(0,3)=pt3.x; xfrom4(1,3)=pt3.y; xfrom4(2,3)=pt3.z;
         
                                AcDb3dSolid *pSphere2 = new AcDb3dSolid;
                                pSphere2->createSphere(4);
                                AcDbObjectId sphere2Id;
                                pSphere2->transformBy(xfrom4);
//                                pBlkTableRecord->appendAcDbEntity(sphereId,pSphere);
                                pSphere2->setColorIndex(3);
                                postToDatabase(pSphere2,sphere2Id);
                                pSphere2->close();

                                length=sqrt((pt3.x-pt4.x)*(pt3.x-pt4.x)+(pt3.y-pt4.y)*(pt3.y-pt4.y));
                                slopy1=atan2(length,(pt3.z-pt4.z));
                                cosy1=cos(slopy1);
                                siny1=sin(slopy1);

                                AcDbLine *pLine1 = new AcDbLine(pt3,pt4);
                                AcDbObjectId pline1Id;
                                postToDatabase(pLine1,pline1Id);
                                pLine1->close();

                                AcGeVector3d nrm1;
                                nrm1.set(cosy1,siny1,0);
                                AcDbCircle *pCir1 = new AcDbCircle(pt4,nrm1,1);
                                AcDbObjectId circle1Id;
                postToDatabase(pCir1,circle1Id);
                                pCir1->close();

                                AcGeMatrix3d fxform;
                fxform(0,3)= pt4.x; fxform(1,3)=pt4.y; fxform(2,3)=pt4.z;

                                AcDb3dSolid *pSphere3 = new AcDb3dSolid;
                                pSphere3->createSphere(4);
                                AcDbObjectId sphere3Id;
                                pSphere3->transformBy(fxform);
//                                pBlkTableRecord->appendAcDbEntity(sphereId,pSphere);
                                pSphere3->setColorIndex(3);
                                postToDatabase(pSphere3,sphere3Id);
                                pSphere3->close();

                     AcGeVector3d faxis(0,1,0);
                                AcGePoint3d  center(0,0,0);
                            fxform.setToRotation(PI/2,faxis,center);
                                AcDb3dSolid *pFrustum1 = new AcDb3dSolid;
                                pFrustum1->createFrustum(35,4,4,0);
                                AcDbObjectId frustum1Id;
                                pFrustum1->transformBy(fxform);
                                faxis.set(0,0,1);
                                fxform.setToRotation(slopy1,faxis,center);
                                pFrustum1->transformBy(fxform);

                                AcGeMatrix3d fxform1;
                fxform1(0,3)=(pt3.x+pt4.x)/2; fxform1(1,3)=(pt3.y+pt4.y)/2;fxform1(2,3)=(pt3.z+pt4.z)/2;

                    pFrustum1->transformBy(fxform1);
                                pFrustum1->setColorIndex(1);
                            postToDatabase(pFrustum1 ,frustum1Id);       
                                pFrustum1->close();       

                                AcDbVoidPtrArray flines;
                                AcDbVoidPtrArray fregions1;
                                AcDbCircle *fspline;
                                acdbOpenObject(fspline,circle1Id,AcDb::kForRead);
                                flines.append((void*) fspline);
                                AcDbRegion::createFromCurves(flines,fregions1);
                                AcDbRegion* fregions = AcDbRegion::cast((AcRxObject*)fregions1[0]);

                                AcDb3dSolid *p3dSolid1 = new AcDb3dSolid;
                                p3dSolid1->extrudeAlongPath(fregions,pLine1);       
                                p3dSolid1->setColorIndex(2);
                                AcDbObjectId solid1Id;       
                                postToDatabase(p3dSolid1,solid1Id);
                                p3dSolid1->close();

                                fdb.MoveNext();
                        }
                }
    }
        acedCommand(RTSTR,"3dorbit",RTNONE);
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-9-21 21:53 , Processed in 0.362056 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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