找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2887|回复: 22

[求助] 求助,怎样画一个圆柱

[复制链接]
发表于 2014-4-12 21:56:30 | 显示全部楼层 |阅读模式

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

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

×
首先,先谢谢各位老师。我现在想画一个圆柱,给出一条基准线,画一个半径为R的圆柱,准备用面域绕基准线旋转形成圆柱,请问各位老师怎样实现,谢谢了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2014-4-12 22:04:18 | 显示全部楼层
用createFromCurves函数要求边界必须是闭合的,而createFrustum函数画出的圆柱中心线只能沿Z轴,所以现在不知道该怎样画,或者各位老师给出一个思路,谢谢了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:07:48 | 显示全部楼层
revolve函数不能指定半径呀,现在不知道怎么办
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 13个

财富等级: 恭喜发财

发表于 2014-4-12 22:36:37 | 显示全部楼层
圆柱当然边界要闭合了,你先把曲线封闭,再生成不就行了。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:37:57 | 显示全部楼层
请问用哪一个函数

点评

你说的 createFromCurves 啊。  详情 回复 发表于 2014-4-12 22:38
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 13个

财富等级: 恭喜发财

发表于 2014-4-12 22:38:44 | 显示全部楼层
minewind 发表于 2014-4-12 22:37
请问用哪一个函数

你说的 createFromCurves 啊。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:40:50 | 显示全部楼层
谢谢回答,这个函数能实现指定半径,指定轴线画圆柱吗

点评

AcDbRegion::createFromCurves 这个函数是从曲线生成REGION,你把圆曲线实体生成REGION,然后拉伸它就是圆柱了。 上面代码有几个通用的函数你可借鉴用。  详情 回复 发表于 2014-4-12 22:44
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 13个

财富等级: 恭喜发财

发表于 2014-4-12 22:42:14 | 显示全部楼层
minewind 发表于 2014-4-12 22:37
请问用哪一个函数

有个资料,你英文应该没问题吧,下面代码把AcGePoint3dArray数组点生成REGION,然后拉伸生成3D SOLID。


To create a solid extrusion you have to provide a region as input. You can then use points to create a polyline for creating a region. After the region is created, use it to create the solid extrusion. After the solid is created, manipulate it as you would any other AcDbEntity. The sample below uses a set of points to create a polyline that creates a region. A solid extrusion is then created from the region. Lastly, it demonstrates how to manipulate the solid by moving it.

// main function
void createSolid()
{
    // Assign the set of points that will define the vertices
    // of the region used to create the solid extrusion.  The
    // points are defined and loaded in an AcGePoint3dArray.
    // The first and last point are the same so a close
    // region will be created.
    AcGePoint3dArray pointArray;
    AcGePoint3d VertexPoint(0.0, 0.0, 0.0);
    pointArray.append(VertexPoint);

    VertexPoint.set(4.0, 0.0, 0.0);
    pointArray.append(VertexPoint);

    VertexPoint.set(4.0, 3.0, 0.0);
    pointArray.append(VertexPoint);

    VertexPoint.set(2.0, 2.0, 0.0);
    pointArray.append(VertexPoint);

    VertexPoint.set(0.0, 3.0, 0.0);
    pointArray.append(VertexPoint);

    VertexPoint.set(0.0, 0.0, 0.0);
    pointArray.append(VertexPoint);

    // Create a region using the point array.
    AcDbObjectId RegionId;
    RegionId = CreateRegionFromPoints(pointArray);

    // Create a solid extrusion using the region.
    // The depth of the
    // protrusion will be 2 units with a taper of 5 degrees.
    AcDbObjectId SolidId;
    SolidId = CreateSolidExtrusion(RegionId, 2.0,
                     3.14159256359/36.0);

    // Demonstrate manipulating the solid by moving it.
    MoveObject(SolidId, AcGeVector3d(5.0, 0.0, 0.0));
}

// Given an AcDbObjectId, move the object.
void MoveObject(AcDbObjectId ObjectId,
                AcGeVector3d MoveVector)
{
    // Open the object for write.
    AcDbEntity* pEnt;
    acdbOpenObject(pEnt, ObjectId, AcDb::kForWrite);

    AcGeMatrix3d transMatrix;
    transMatrix = transMatrix.setTranslation(MoveVector);
    pEnt->transformBy(transMatrix);

   // Force the entity to draw.    pEnt->draw();

    // Close the object.
    pEnt->close();  

    // Force the update of the display.
    acedUpdateDisplay();
}


// Given a region create a solid extrusion.
AcDbObjectId CreateSolidExtrusion(
     AcDbObjectId RegionId,
     double Height,
     double Taper)
{
    AcDbObjectId solidId;

    // Get the AcDbEntity for the input region.
    AcDbEntity* pRegion;
    acdbOpenAcDbEntity(pRegion, RegionId, AcDb::kForRead);

    // Create a solid using the region.
    AcDb3dSolid* solid = new AcDb3dSolid;
    assert(solid != NULL);
    solid->extrude(static_cast<AcDbRegion*>(pRegion),
                Height, Taper);
    pRegion->close();

    // Add the solid to the database
    AcDbBlockTable* pBlockTable;
    acdbHostApplicationServices()->workingDatabase()->
        getBlockTable(pBlockTable, AcDb::kForRead);
    AcDbBlockTableRecord* pBlockTableRecord;

    // get model space
    pBlockTable->getAt(ACDB_MODEL_SPACE,
        pBlockTableRecord,
        AcDb::kForWrite);
    pBlockTable->close();

    pBlockTableRecord->appendAcDbEntity(solidId, solid);

    pBlockTableRecord->close();
    solid->close();

    // Return the ID of the solid.
    return solidId;
}

// Given an AcGePoint3dArray, create a region that
// uses these points at the vertices of the region.
AcDbObjectId CreateRegionFromPoints(
        AcGePoint3dArray InPoints)
{
    // Create the the polyline.
    AcDbObjectId polylineID = NULL;
    polylineID = createPolyline(InPoints);

    // Get the AcDbEntity for the polyline.
    AcDbEntity* pPolyline;
    AcDbObjectId regionId;
    acdbOpenAcDbEntity(pPolyline,
        polylineID, AcDb::kForRead);

    // Create a region using the polyline.
    AcDbVoidPtrArray polylineArray;
    polylineArray.append(static_cast<void*>(pPolyline));
    AcDbVoidPtrArray regions;
    AcDbRegion::createFromCurves(polylineArray, regions);
    AcDbRegion *pRegion = NULL;
    pRegion = AcDbRegion::cast((AcRxObject*)regions[0]);

    pPolyline->close();

    // Add the region to the database.
    AcDbBlockTable* pBlockTable;
    acdbHostApplicationServices()->workingDatabase()->
        getBlockTable(pBlockTable, AcDb::kForRead);

    // get model space
    AcDbBlockTableRecord* pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE,
        pBlockTableRecord,
        AcDb::kForWrite);
    pBlockTable->close();

    AcDbRegion* regionObj =
        static_cast<AcDbRegion*>(regions[0]);
    pBlockTableRecord->appendAcDbEntity(
                regionId,
                regionObj);

    pBlockTableRecord->close();
    regionObj->close();

    // Return the ID of the region.
    return regionId;
}

// Given an AcGePoint3dArray, create a polyline that
// uses these points at the vertices of the region.
AcDbObjectId createPolyline(AcGePoint3dArray Vertices)
{
    // Create the polyline.
    AcDb3dPolyline* pPolyline =
        new AcDb3dPolyline(AcDb::k3dSimplePoly,
                        Vertices);

    // Add the polyline to the databse.
    AcDbBlockTable* pBlockTable;
    acdbHostApplicationServices()->workingDatabase()->
        getBlockTable(pBlockTable,
                AcDb::kForRead);

    AcDbBlockTableRecord* pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE,
        pBlockTableRecord,
        AcDb::kForWrite);
    pBlockTable->close();

    AcDbObjectId polylineId;
    pBlockTableRecord->appendAcDbEntity(
        polylineId, pPolyline);

    pBlockTableRecord->close();
    pPolyline->close();

    // Return the ID of the polyline.
    return polylineId;

}


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:43:03 | 显示全部楼层
英语六级刚刚的:lol,谢谢
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:43:44 | 显示全部楼层
就是太多了
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 13个

财富等级: 恭喜发财

发表于 2014-4-12 22:44:47 | 显示全部楼层
minewind 发表于 2014-4-12 22:40
谢谢回答,这个函数能实现指定半径,指定轴线画圆柱吗

AcDbRegion::createFromCurves 这个函数是从曲线生成REGION,你把圆曲线实体生成REGION,然后拉伸它就是圆柱了。

上面代码有几个通用的函数你可借鉴用。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:45:03 | 显示全部楼层
你能直接告诉我怎样使用这个函数吗
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 22:48:05 | 显示全部楼层
谢谢您的回答,我是一个新手,我仔细研究一下这个函数,谢谢前辈
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-4-12 23:00:17 | 显示全部楼层
谢谢您的耐心回答

点评

你尝试着写下,如果成功了,希望把代码帖上来,和大家分享下。  详情 回复 发表于 2014-4-12 23:33
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 13个

财富等级: 恭喜发财

发表于 2014-4-12 23:33:22 | 显示全部楼层
minewind 发表于 2014-4-12 23:00
谢谢您的耐心回答

你尝试着写下,如果成功了,希望把代码帖上来,和大家分享下。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-9-24 12:29 , Processed in 0.502734 second(s), 61 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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