天气与日历 切换到窄版

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

OBJECT ARX三维图形绘制

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]创建三维图形


三维长方体==================
static void TESTaddboxcmd(){

AcDb3dSolid* pSolid = new AcDb3dSolid();
Acad::ErrorStatus es = pSolid->createBox(40,50,30);
if(es != Acad::eOk){
acedAlert(_T("创建长方体失败"));
delete pSolid;
return;
}
//acedAlert(_T("创建成功"));


使用几何变换矩阵移动长方体
AcGeMatrix3d xform;
AcGeVector3d vec(100,100,100);
xform.setToTranslation(vec);
pSolid->transformBy(xform);


LoadEntity(pSolid);


}


//三维圆锥==============
static void TESTaddcylinedercmd(){

AcDb3dSolid* pSolid = new AcDb3dSolid();
pSolid->createFrustum(30,10,10,0);
LoadEntity(pSolid);
}




三维弹簧
static void TESTaddspirecmd(){

半径和每周在垂直方向的增量
double radius,deltaVertical;


螺旋线的旋转圈数和组成一圈
double number,segment;
radius = 30,deltaVertical = 12;
number = 5,segment = 30;


计算点的个数和角度间隔
int n = number * segment;
double angle = 8 * atan(1.0)/segment;


计算控制点的坐标
AcGePoint3dArray points;
for(int i = 0;i < n + 1;i ++){

AcGePoint3d vertex;
vertex[X] = radius * cos(8 * i *
atan(1.0) / segment);
vertex[Y] = radius * sin(8 * i *
atan(1.0) / segment);
vertex[Z] = i * deltaVertical / segment;
points.append(vertex);


}


创建螺旋路径
AcDb3dPolyline* p3dPoly = new
AcDb3dPolyline(AcDb::k3dSimplePoly,
points);


AcDbObjectId spireId = LoadEntity(p3dPoly);


这时已经创建了2D模型,增加3D圆截面


AcGeVector3d vec(0,1,0);
AcGePoint3d ptCenter(30,0,0);
AcDbCircle* pCircle = new AcDbCircle(ptCenter,
vec,3);
AcDbObjectId circleId = LoadEntity(pCircle);


根据圆创建面域


AcDbObjectIdArray boundaryIds,regionIds;
boundaryIds.append(circleId);
regionIds = CreateRegion(boundaryIds);

打开拉伸截面和拉伸路径
AcDbRegion* pRegion;
acdbOpenObject(pRegion,regionIds.at(0),AcDb::kForRead);
AcDb3dPolyline* pPoly;
acdbOpenObject(pPoly,spireId,AcDb::kForRead);


进行拉伸操作


AcDb3dSolid* pSolid = new AcDb3dSolid();
pSolid->extrudeAlongPath(pRegion,pPoly);
LoadEntity(pSolid);


pPoly->close();
pRegion->close();


}



多段线形成面域旋转=============
static void TESTaddreventcmd(){
AcGePoint3d vertex[5];
vertex[0] = AcGePoint3d(15,0,0);
vertex[1] = AcGePoint3d(45,0,0);
vertex[2] = AcGePoint3d(35,10,0);
vertex[3] = AcGePoint3d(41,18,0);
vertex[4] = AcGePoint3d(15,20,0);

AcGePoint3dArray points;
for(int i = 0;i < 5; i++){


points.append(vertex[i]);
}
创建作为旋转截面的多段线


AcDb3dPolyline* p3dPoly = new AcDb3dPolyline(AcDb::k3dSimplePoly,points,true);
AcDbObjectId polyId = LoadEntity(p3dPoly);


将闭合的多段线转化为面域
AcDbObjectIdArray boundaryIds,regionIds;
boundaryIds.append(polyId);
regionIds = CreateRegion(boundaryIds);


进行旋转操作


AcDbRegion* pRegion;
Acad::ErrorStatus es = acdbOpenObject(pRegion,regionIds.at(0),
AcDb::kForRead);
AcDb3dSolid* pSolid = new AcDb3dSolid();
es = pSolid->revolve(pRegion,AcGePoint3d::kOrigin,
AcGeVector3d(0,1,0),8 * atan(1.0));


LoadEntity(pSolid);
pRegion->close();


}[/code]

 

 

 

 

OBJECT ARX三维图形绘制
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-1 10:18 , Processed in 0.168504 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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