- 积分
- 170
- 明经币
- 个
- 注册时间
- 2002-1-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2002-6-20 21:34:00
|
显示全部楼层
aaa
这段代码可以动态拉出一个SPLINE橡皮筋, 并以RButtonDown结束.
但存在一些问题. 谁知道如果解决请一定告诉我:
1.无法Osnap 2.如果想使用键盘回车结束绘制,如果检测?
void drag()
{
int track, type;
struct resbuf result;
AcGePoint3d pt;
//spline的橡皮筋
AcDbBlockTable *pBlockTable;
AcDbBlockTableRecord *pBlockTableRecord;
AcDbObjectId idSpline;
AcDbSpline *pSpline;
AcGePoint3dArray pts;
pts.append(AcGePoint3d(0, 0, 0));
acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead);
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTable->close();
track = 1;
while (track > 0)
{
acedGrRead(track, &type, &result);
pt.x = result.resval.rpoint[X];
pt.y = result.resval.rpoint[Y];
pt.z = result.resval.rpoint[Z];
//acutPrintf("\n(track = %d, type = %d, %lf,%lf, %lf)", track, type, pt.x, pt.y, pt.z);
if (type == 2) // keyboard
{
//result.resval
}
if (type == 3) // LButtonDown
{
pts[pts.length() - 1] = pt;
pts.append(pt);
}
else if (type == 5) // MouseMove
{
if (pts.length() >= 2)
{
if (acdbOpenObject(pSpline, idSpline, AcDb::kForWrite) == Acad::eOk)
{
pSpline->erase();
pSpline->close();
}
pts[pts.length() - 1] = pt;
pSpline = new AcDbSpline(pts);
pBlockTableRecord->appendAcDbEntity(idSpline, pSpline);
pSpline->close();
}
}
else if (type == 25) // RButtonDown
{
if (acdbOpenObject(pSpline, idSpline, AcDb::kForWrite) == Acad::eOk)
{
pSpline->erase();
pSpline->close();
}
pts.removeLast();
if (pts.length() >= 2)
{
pSpline = new AcDbSpline(pts);
pBlockTableRecord->appendAcDbEntity(idSpline, pSpline);
pSpline->close();
}
track = 0;
}
}
pBlockTableRecord->close();
} |
|