明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1840|回复: 1

请各位帮忙

[复制链接]
发表于 2006-8-10 12:54:00 | 显示全部楼层 |阅读模式

提示 用户选择两个点,将两点联成直线

为何不能实现啊 ,代码如下:

ads_point startPt, endPt;

 acedGetPoint(NULL,"\nLocate start point : ", startPt);

 acedGetPoint(NULL,"\nLocate end point : ", endPt);

  AcDbLine *pLine = new AcDbLine(startPt,endPt);

//error C2664: '__thiscall AcDbLine::AcDbLine(const class AcGePoint3d &,const class AcGePoint3d &)' : cannot convert parameter 1 from 'double [3]' to 'const class AcGePoint3d &'
        Reason: cannot convert from 'double [3]' to 'const class AcGePoint3d'
        No constructor could take the source type, or constructor overload resolution was ambiguous

请各位帮忙指点一二

发表于 2006-8-13 23:09:00 | 显示全部楼层

第一点,AcDbLine接受的不是ads_point而是AcGePoint3d,要把ads_point 转换为AcGePoint3d,可以这样写:

(假定 ads_point s;AcGePoint3d p;)

p.set(s[0],s[1],s[2]);

但是你得程序可以有更快的写法:

AcDbLine *pLine = new AcDbLine(*(AcGePoint3d*)startPt,*(AcGePoint3d*)endPt);

第二点,你必须把你的图元加入到数据库中才行,这个可以参考SDK上的写法:

 AcDbBlockTable *pBlockTable;
  acdbHostApplicationServices()->workingDatabase()
   ->getSymbolTable(pBlockTable, AcDb::kForRead);

  AcDbBlockTableRecord *pBlockTableRecord;
  pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
   AcDb::kForWrite);
  pBlockTable->close();

  AcDbObjectId lineId;
  pBlockTableRecord->appendAcDbEntity(lineId, pLine);

  pBlockTableRecord->close();
  pLine->close();

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 23:50 , Processed in 0.143117 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表