wweien 发表于 2002-9-25 11:00:00

请教关于AcDb2dPolyline中定点添加的问题?

我现在有以下程序:
AcDb2dPolyline *pLine;
AcGePoint3d startPt;
AcGePoint3d endPt;
AcGePoint3dArray vertices;
   vertices.append(startPt);
        vertices.append(endPt);
pLine->appendVertex(vertices);
以前这段程序好像可以现在却不行了,请问用appendVertex添加起点和终点不行吗?

wweien 发表于 2002-9-26 12:51:00

哪位高手请指点一下

wweien 发表于 2002-9-29 21:54:00

还是没搞定,有没有高手指点一下?

leeyeafu 发表于 2002-9-30 08:00:00

从代码看,不像有问题,可不可以说详细怎么不行

wweien 发表于 2002-10-1 15:23:00

它给我的错误说明是这样的!以前好像没这样的。

error C2664: 'enum Acad::ErrorStatus __thiscall AcDb2dPolyline::appendVertex(class AcDb2dVertex *)' : cannot convert parameter 1 from 'class AcArray<class AcGePoint3d,class AcArrayMemCopyReallocator<class AcGePoint3
d> >' to 'class AcDb2dVertex *'
      No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called。

leeyeafu 发表于 2002-10-8 07:49:00

老兄,早把错误信息帖出来,估计节前就能帮你搞定

本帖最后由 作者 于 2002-10-8 7:49:07 编辑

用pLine->appendVertex(); 可以添加顶点,但你的程序中参数使用不对。应该是这样:
AcGePoint3d *q = pCircle->center();
AcDb2dVertex *pVertex=new AcDb2dVertex(q);
pLine->appendVertex(pVertex);
也就是说,appendVertex()函数需要一个AcDb2dVertex类型的参数。你应该调用AcDb2dVertex类的构造函数AcDb2dVertex *pVertex=new AcDb2dVertex();来实现类型转换。

wweien 发表于 2002-10-8 10:20:00

谢谢,但不知为什么用指针反应器就出错,所以我想试着不用指针。请指点。

我是在做一个pline线和圆相关联。就是移动圆,pline线的起点跟着做相关移动。
line线是可以的。但是pline线就出错。(在vc下过了,但是会使autocad出现调用错误,然后cad就关了。)
所以我以为可能是指针调用错误。就想试试不用指针。
不知道有没有别的解决办法,敬请指教!

leeyeafu 发表于 2002-10-8 10:52:00

好象不用反应器是不行的,你再看看是不是反应器的代码有问题

wweien 发表于 2002-10-8 12:32:00

我就是把line的相关属性用pline的相关属性做了替换就不行了。

leeyeafu 发表于 2002-10-8 14:12:00

我没明白你的意思,给你一个文本反应器的例子,自己参考参考

The following example creates a simple context reactor that responds to a variety of input context events:

#include <adslib.h>
#include <aced.h>
#include <dbmain.h>
#include <rxregsvc.h>
#include <acedinpt.h>
#include <acdocman.h>

// 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::PromptStatus returnStatus,const AcGePoint3d& pointOut, const char*& pKeyword);
  void beginGetOrientation(const AcGePoint3d* pointIn,const char* promptString,int initGetFlags,const char* pKeywords);
  void endGetOrientation(Acad::PromptStatus returnStatus,double& angle,const char*& pKeyword);
  void beginGetCorner(const AcGePoint3d* firstCorner,const char* promptString,int initGetFlags,const char* pKeywords);
    void endGetCorner(Acad::PromptStatus returnStatus,AcGePoint3d& secondCorner,const char*& pKeyword);
    void beginSSGet(const char*pPrompt,int initGetFlags,const char*pKeywords,const char*pSSControls,const Array<AcGePoint3d>& points,const resbuf* entMask);
    void endSSGet(Acad::PromptStatus returnStatus,const AcArray<AcDbObjectId>& 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::PromptStatus 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::PromptStatus 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::PromptStatus 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<AcGePoint3d>& points,const resbuf* entMask)
{
    acutPrintf("beginSSGet:%s\n", NULL != pPrompt ? pPrompt : "");
    for (int i = 0; i < points.length(); i++)
      acutPrintf("%d: %.2f, %.2f, %.2f\n", i, points,
      points, points);
}

void MyContextReactor::endSSGet(Acad::PromptStatus returnStatus,    const AcArray<AcDbObjectId>& ss)
{
    acutPrintf("endSSGet\n");
    for (int i = 0; i < ss.length(); i++)
      acutPrintf("Entity %d: <%x>\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] 2
查看完整版本: 请教关于AcDb2dPolyline中定点添加的问题?