ObjectArx-C++实现 坡度编辑命令-指定基点的情况下提示用户拾取另一个点
C++实现坡度编辑命令,指定基点的情况下提示用户拾取一个点。
主要思路是:
- 先画一个坡度块。
- 绘制参考线,参考线能够进行极轴跟踪。
- 坡度编辑,选中坡度块,画出参考线,根据参考线延伸坡度长度。
图例如下:

示例如下:
- 程序入口点代码
```c++
//zhaoanan 坡度绘制
// - zndraw_thslope command (do not rename)
//自定义实体绘制坡度
static void zndraw_thslope(void)
{
AcDbDatabase * m_pDb = acdbHostApplicationServices()->workingDatabase();
//添加块定义
acutPrintf(_T("\n坡度绘制")) ;
CUserSystem *mysys = new CUserSystem();
mysys->m_pDb = m_pDb;
//声明左边插入点
ads_point pt_insert;
AcGePoint3d pt_3d_insert;
int iOldOsMode = 0 ;
BOOL bReturn = false ;
while (bReturn == false)
{
int iReturn = acedGetPoint(NULL,_T("\n 指定坡度的插入点:"),pt_insert) ;
//int iReturn = acedEntSel(_T("\n选择实体对象"), en, pt) ;
if(iReturn == RTNORM)
{
bReturn = true ;
pt_3d_insert =asPnt3d(pt_insert);
acutPrintf(_T("\n坡度插入点坐标:x坐标为:%f,y坐标为:%f"), pt_3d_insert.x, pt_3d_insert.y);
//实例化轨道坡度对象
CthRailSlope *cthRailSlope = new CthRailSlope();
//指定坡度位置为插入点坐标
cthRailSlope->setPosition(pt_3d_insert);
//添加坡度组件
CthComponent *lineCp = new CthComponent();
//thComponent c = new thComponent();
//根据插入点,画坡度上面的横线
lineCp->addLine(AcGePoint3d(-26, 7.5, 0), AcGePoint3d(0, 7.5, 0));
//根据插入点,画坡度下面的横线
lineCp->addLine(AcGePoint3d(-26, -7.5, 0), AcGePoint3d(0, -7.5, 0));
//以插入点横坐标X=-26为基准向上和向下画竖线
lineCp->addLine(AcGePoint3d(-26, 7.5, 0), AcGePoint3d(-26, -7.5

这篇博客介绍了如何使用C++在ObjectArx中实现坡度编辑命令。在指定基点后,程序引导用户拾取另一个点来延伸坡度长度。内容包括绘制坡度块、参考线以及坡度编辑的详细步骤,并提供了程序入口点和编辑代码示例。
最低0.47元/天 解锁文章
2338

被折叠的 条评论
为什么被折叠?



