复杂的实体。
它在ARX文档中说不要将Aced Jig与复杂的实体(例如折线)一起使用LwPolyine怎么样?
**** Hidden Message ***** 棒!谢谢保罗。
这里有一个示例,如果有人需要一个(AcDbPolyLine)
.h
#pragma once
class RectJig : public AcEdJig
{
// fields
private:
Adesk::Boolean m_append;
AcGePoint3d m_cur;
AcGePoint3d m_last;
const CString m_msg;
AcDbPolyline *m_line;
AcDbObjectId m_id;
public:
// ctor && dtor
RectJig(double width, double height, const CString &msg, Adesk::Boolean append = Adesk::kTrue);
virtual ~RectJig(void);
// methods
void doIt();
Adesk::Boolean cursorHasMoved(void);
virtual AcEdJig::DragStatus sampler(void);
virtual Adesk::Boolean update(void);
virtual AcDbEntity* entity(void) const;
AcGePoint2d getPoint2d(void) const;
AcGePoint3d getPoint3d(void) const;
AcDbObjectId getObjectId(void)const;
__declspec(property(get = getPoint2d))AcGePoint2d Point2d;
__declspec(property(get = getPoint3d))AcGePoint3d Point3d;
__declspec(property(get = getObjectId))AcDbObjectId ObjectId;
};
.cpp
#include "StdAfx.h"
#include "JigTest.h"
RectJig::RectJig(double width, double height, const CString &msg, Adesk::Boolean append /*= Adesk::kTrue*/)
:m_append(append), m_line(new AcDbPolyline(4)), m_cur(AcGePoint3d::kOrigin),
m_last(AcGePoint3d::kOrigin) , m_msg(msg) , m_id(AcDbObjectId::kNull)
{
AcGePoint2d pt0(m_cur.x, m_cur.y);
AcGePoint2d pt1(pt0.x + width,pt0.y);
AcGePoint2d pt2(pt0.x + width, pt0.y + height);
AcGePoint2d pt3(pt0.x, pt0.y + height);
this->m_line->addVertexAt(0,pt0);
this->m_line->addVertexAt(1,pt1);
this->m_line->addVertexAt(2,pt2);
this->m_line->addVertexAt(3,pt3);
this->m_line->setClosed(Adesk::kTrue);
}
RectJig::~RectJig(void)
{
if(!m_append)
{
delete m_line;
}
}
inline Adesk::Boolean RectJig::cursorHasMoved( void )
{
return this->m_cur != this->m_last;
}
AcEdJig::DragStatus RectJig::sampler()
{
setUserInputControls(UserInputControls(kAccept3dCoordinates));
if(acquirePoint(m_cur) != AcEdJig::kNormal)
{
return AcEdJig::kCancel;
}
if(this->cursorHasMoved())
{
return AcEdJig::kNormal;
}
return AcEdJig::kNoChange;
}
Adesk::Boolean RectJig::update(void)
{
if(this->m_line->transformBy(AcGeMatrix3d::translation(AcGeVector3d(m_cur - m_last))) != Acad::eOk)
{
return Adesk::kFalse;
}
m_last = m_cur;
return Adesk::kTrue;
}
AcDbEntity* RectJig::entity(void) const
{
return this->m_line;
}
void RectJig::doIt(void)
{
setDispPrompt(m_msg);
if(drag() != AcEdJig::kNormal)
{
m_append = Adesk::kFalse;
}
if(m_append)
{
m_id = append();
m_line->close();
}
}
AcGePoint2d RectJig::getPoint2d(void) const
{
return AcGePoint2d(m_last.x, m_last.y);
}
AcGePoint3d RectJig::getPoint3d(void) const
{
return m_last;
}
AcDbObjectId RectJig::getObjectId( void ) const
{
return m_id;
}
和命令
static void CabDraw_RectJig(void)
{
RectJig jig(100,100, _T("Pick Start Point: "));
jig.doIt();
acutPrintf(_T("\n%g,%g"),jig.Point2d.x, jig.Point2d.y);
}
编辑添加了objectid属性 函数“doIt”肯定会在你的代码中有很多浮雕 Ah FooBar 丹尼尔,
关于不使用示例的原因,例如用于命令RECT?
无论如何,我不是AcedJig的忠实粉丝 - 已经将这个类用于一些命令,但是例如,尝试编写一个模拟命令PLINE的类 - 在我的情况下,我最终做了一个单独的函数。
有一个MPOLY由Kean W.完成,但不能作为PLINE工作。顺便说一句
,只是想让它评论它.... 嗨,路易斯,
我不记得在那里。我用椭圆示例作为指导
页:
[1]