请教关于AcDb2dPolyline中定点添加的问题?
我现在有以下程序:AcDb2dPolyline *pLine;
AcGePoint3d startPt;
AcGePoint3d endPt;
AcGePoint3dArray vertices;
vertices.append(startPt);
vertices.append(endPt);
pLine->appendVertex(vertices);
以前这段程序好像可以现在却不行了,请问用appendVertex添加起点和终点不行吗? error C2664: 'enum Acad::ErrorStatus __thiscall AcDb2dPolyline::appendVertex(class AcDb2dVertex *)' : cannot convert parameter 1 from 'class AcArray >' to 'class AcDb2dVertex *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called。
用pLine->appendVertex(); 可以添加顶点,但你的程序中参数使用不对。应该是这样:
AcGePoint3d *q = pCircle->center();
AcDb2dVertex *pVertex=new AcDb2dVertex(q);
pLine->appendVertex(pVertex);
也就是说,appendVertex()函数需要一个AcDb2dVertex类型的参数。你应该调用AcDb2dVertex类的构造函数AcDb2dVertex *pVertex=new AcDb2dVertex();来实现类型转换。 我是在做一个pline线和圆相关联。就是移动圆,pline线的起点跟着做相关移动。
line线是可以的。但是pline线就出错。(在vc下过了,但是会使autocad出现调用错误,然后cad就关了。)
所以我以为可能是指针调用错误。就想试试不用指针。
不知道有没有别的解决办法,敬请指教! The following example creates a simple context reactor that responds to a variety of input context events:
#include
#include
#include
#include
#include
#include
// The input context reactor class.
class MyContextReactor : public AcEdInputContextReactor
{
public:
void beginGetPoint(const AcGePoint3d* pointIn,const char* promptString, int initGetFlags,const char* pKeywords);
void endGetPoint(Acad:romptStatus returnStatus,const AcGePoint3d& pointOut, const char*& pKeyword);
void beginGetOrientation(const AcGePoint3d* pointIn,const char* promptString,int initGetFlags,const char* pKeywords);
void endGetOrientation(Acad:romptStatus returnStatus,double& angle,const char*& pKeyword);
void beginGetCorner(const AcGePoint3d* firstCorner,const char* promptString,int initGetFlags,const char* pKeywords);
void endGetCorner(Acad:romptStatus returnStatus,AcGePoint3d& secondCorner,const char*& pKeyword);
void beginSSGet(const char*pPrompt,int initGetFlags,const char*pKeywords,const char*pSSControls,const Array& points,const resbuf* entMask);
void endSSGet(Acad:romptStatus returnStatus,const AcArray& ss);
};
void MyContextReactor::beginGetPoint(const AcGePoint3d* pointIn, const char* promptString,int initGetFlags,const char* pKeywords)
{
acutPrintf("beginGetPoint: pointIn = %.2f,%.2f,%.2f\n",
(*pointIn), (*pointIn), (*pointIn));
if (NULL != promptString)
acutPrintf("%s", promptString);
acutPrintf("initGetFlags: %d\n", initGetFlags);
if (NULL != pKeywords)
acutPrintf("Keywords: %s\n", pKeywords);
}
void MyContextReactor::endGetPoint(Acad:romptStatus returnStatus, const AcGePoint3d& pointOut,const char*& pKeyword)
{
acutPrintf("endGetPoint: %d\n", returnStatus);
acutPrintf("%.2f,%.2f,%.2f\n", pointOut, pointOut,
pointOut);
if (NULL != pKeyword)
acutPrintf("Keyword: %s\n", pKeyword);
}
void MyContextReactor::beginGetOrientation(const AcGePoint3d* pointIn,const char* promptString, int initGetFlags,const char* pKeywords)
{
acutPrintf("beginGetOrientation: %.2f, %.2f, %.2f\n",
(*pointIn), (*pointIn), (*pointIn));
}
void MyContextReactor::endGetOrientation(Acad:romptStatus returnStatus,double& angle,const char*& pKeyword)
{
acutPrintf("endGetOrientation: %.2f\n", angle);
}
void MyContextReactor::beginGetCorner(const AcGePoint3d* firstCorner,const char* promptString,int initGetFlags,const char* pKeywords)
{
if (NULL != firstCorner)
{
acutPrintf(
"beginGetCorner: %.2f, %.2f, %.2f\n",
(*firstCorner),
(*firstCorner),
(*firstCorner));
}
}
void MyContextReactor::endGetCorner(Acad:romptStatus returnStatus,AcGePoint3d& secondCorner,const char*& pKeyword)
{
acutPrintf("endGetCorner\n");
}
void MyContextReactor::beginSSGet(const char*pPrompt,int initGetFlags,const char*pKeywords,const char*pSSControls, const AcArray& points,const resbuf* entMask)
{
acutPrintf("beginSSGet:%s\n", NULL != pPrompt ? pPrompt : "");
for (int i = 0; i & ss)
{
acutPrintf("endSSGet\n");
for (int i = 0; i \n", i, ss.asOldId());
}
// My context reactor object
MyContextReactor my_icr;
extern "C" __declspec(dllexport) AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void *p)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxUnlockApplication(p);
acrxRegisterAppMDIAware(p);
break;
case AcRx::kLoadDwgMsg:
// Attach a context reactor to the current document.
//
curDoc()->inputPointManager()->
addInputContextReactor(&my_icr);
break;
case AcRx::kUnloadAppMsg:
// Warning! This sample attaches a context reactor,
// but it never detaches it. A real-life application
// will need to monitor to which document it attached
// the reactor, and will need to detach it.
//
break;
}
return AcRx::kRetOK;
}
页:
[1]