乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 346|回复: 13

[编程交流] 自定义实体问题

[复制链接]

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-8 09:44:18 | 显示全部楼层 |阅读模式
我有 3 个文件:MyDbxCust.dbx、MyArxCust.arx、MyComCust.dbx
问题:运行我的 ADS 命令
   命令:(custgcd)
   “选择点:”
   选择一个点,画一个点,我的自定义实体 DXF_Name 是“高程点”,我想在对象属性管理器中显示我的 DXF_NAME,怎么做?
回复

使用道具 举报

26

主题

113

帖子

10

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
217
发表于 2010-8-10 02:31:37 | 显示全部楼层
在包装类中 使用函数GetDisplayName 。
例如:
  1. h-file
  2. STDMETHOD(GetDisplayName) (DISPID dispId, BSTR *propName);
  3. cpp-file:
  4. STDMETHODIMP CAcDbRopeWraper::GetDisplayName (DISPID dispId, BSTR *propName)
  5. {
  6.   switch (dispId)
  7.   {
  8.     case (0x401): // this is the object name identifier
  9.       *propName  = ::SysAllocString(_T("高程点"));
  10.       break;
  11. //...
  12.   }
  13. }

回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-10 19:31:00 | 显示全部楼层
SDK中有几个示例,请参见SDK\samples\com中的AsdkSquareWrapper和

samples\entity\polysamp(samples\ entity\polysamp\compoly)

polysample有很多优点,因为它展示了如何构建COM和.NET包装器,以及属性调色板的IOPMPropertyxxx内容。
回复

使用道具 举报

LE3

10

主题

149

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
189
发表于 2010-8-11 07:03:47 | 显示全部楼层
谢谢你,我试试。
回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-12 08:47:15 | 显示全部楼层
按照你的提示,我成功了。
回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-20 07:33:30 | 显示全部楼层
我的自定义实体是 CMyGCD,但是当我运行 (entget ent) 时,返回的列表是:
((-1 . ) (0 . "高程点") (330 . ) (5 . "22F")
(100 . "AcDbEntity ") (67 . 0) (410 . "模型") (8 . "0") (100 . "AcDbCircle")
(10 0.0 0.0 0.0) (40 . 30.0) (210 0.0 0.0 1.0) (90 . 1) )
但它的实际坐标不是 '(0.0 0.0 0.0) ,请给我一些建议。
回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-21 08:49:27 | 显示全部楼层
您可能需要覆盖这些函数

  1. virtual Acad::ErrorStatus  dxfInFields(AcDbDxfFiler* filer);
  2. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const;
回复

使用道具 举报

LE3

10

主题

149

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
189
发表于 2010-8-21 22:14:43 | 显示全部楼层
谢谢,我覆盖了 dxfInFIelds 和 dxfOutFields,

  1. //- Dxf Filing protocol
  2. Acad::ErrorStatus CMyGcd::dxfOutFields (AcDbDxfFiler *pFiler) const {
  3.         assertReadEnabled () ;
  4.         //----- Save parent class information first.
  5.         Acad::ErrorStatus es =AcDbCircle::dxfOutFields (pFiler) ;
  6.         if ( es != Acad::eOk )
  7.                 return (es) ;
  8.         es =pFiler->writeItem (AcDb::kDxfSubclass, _RXST("CMyGcd")) ;
  9.         if ( es != Acad::eOk )
  10.                 return (es) ;
  11.         //----- Object version number needs to be saved first
  12.         if ( (es =pFiler->writeUInt32 (kDxfInt32, CMyGcd::kCurrentVersionNumber)) != Acad::eOk )
  13.                 return (es) ;
  14.         //----- Output params
  15.         //.....
  16.         pFiler->writePoint3d(AcDb::kDxfXCoord, mCenter);   //[b]mycode[/b]
  17.         return (pFiler->filerStatus ()) ;
  18. }

但是entget数据列表是:
((-1 . ) (0 . "高程点") (330 . ) (5 . "22F")
(100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbCircle")
(10 0.0 0.0 0.0)  (40 . 0.0) (210 0.0 0.0 1.0) (100 . "CMyGcd") (90 . 1)
(10 2228.71 1228.61 0.0) )
有两个 10 DXF 码!
回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-22 08:02:33 | 显示全部楼层
只是一个想法,因为你是从 AcDbCircle 派生的,你可能不需要另一个变量来保持中心,而是使用 AcDbCircle 的中心。
回复

使用道具 举报

19

主题

53

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
129
发表于 2010-8-22 08:53:39 | 显示全部楼层
谢谢你的建议,你是对的!
当我创建我的自定义实体时:
  1.         static int ads_mygcd()
  2.         {
  3.                 Acad::ErrorStatus es;
  4.                 ads_point center, normal;
  5.                 if (acedGetPoint(NULL, _T("\n选择点:"), center) != RTNORM)
  6.                         return RSERR;
  7.                 AcDbObjectId tsId = 0;
  8.                 TCHAR styleBuf[133];
  9.                 // Get default text style
  10.                 struct resbuf result;
  11.                 if ( acedGetVar(_T("TEXTSTYLE"), &result) != RTNORM ) {
  12.                         acutPrintf(_T("\nError while reading default AutoCAD text style setting"));
  13.                         return RSERR;
  14.                 }
  15.                 _tcscpy(styleBuf, result.resval.rstring);
  16.                 acdbFree(result.resval.rstring);
  17.                 if ( rx_getTextStyleId(styleBuf,acdbHostApplicationServices()->workingDatabase(),tsId) != Acad::eOk)
  18.                 {
  19.                         acutPrintf(_T("\nInvalid text style name"));
  20.                         return RSERR;
  21.                 }
  22.                 CString txt = _T("");
  23.                 txt.Format(_T("%.2f"), center[Z]);
  24.                 TCHAR nameBuf[133];
  25.                 _tcscpy(nameBuf, txt);
  26.                 // Set the normal to the plane of the GCD to be the same as the
  27.                 // z direction of the current ucs, i.e. (0, 0, 1) since we also got the
  28.                 // center and start point in the current UCS.
  29.                 normal[X] = 0.0; normal[Y] = 0.0; normal[Z] = 1.0;
  30.                 acdbUcs2Wcs(normal, normal, Adesk::kTrue);
  31.                 acdbUcs2Ecs(center, center, normal, Adesk::kFalse);
  32.                 AcGePoint3d cen = asPnt3d(center);
  33.                 AcGePoint3d pt = AcGePoint3d(center[X]+2.0,center[Y],center[Z]);
  34.                 AcGeVector3d norm = asVec3d(normal);
  35.                 CMyGcd *pGcd = new CMyGcd();
  36.                 if (pGcd->set(cen, pt, nameBuf, tsId, norm, 0.5, 4.0) != Acad::eOk) {
  37.                         delete pGcd;
  38.                         acutPrintf(_T("\nCannot create CMyGcd with given parameters."));
  39.                         return RSERR;
  40.                 }
  41.                 pGcd->setDatabaseDefaults(curDoc()->database());
  42.                 pGcd->transformBy(AcGeMatrix3d::translation(AcGeVector3d(center[X],center[Y],center[Z])));                //在Dbx中怎么写才能代替这行代码?
  43.                 AcDbBlockTable* pBT = NULL;
  44.                 AcDbDatabase* pDB = acdbHostApplicationServices()->workingDatabase();
  45.                 pDB->getSymbolTable(pBT, AcDb::kForRead);
  46.                 AcDbBlockTableRecord* pBTR = NULL;
  47.                 pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite);
  48.                 pBT->close();
  49.                 AcDbObjectId Id;
  50.                 pBTR->appendAcDbEntity(Id, pGcd);
  51.                 pBTR->close();
  52.                 pGcd->close();
  53.                 return (RSRSLT);
  54.         }
代码行:
pGcd->transformBy(AcGeMatrix3d::translation(AcGeVector3d(center[X],center[Y],center[Z])));
将使上述“(10 0.0 0.0 0.0)”项变为正确的值:
((-1 . ) (0 . "高程点") (330 . ) (5 . "22F")
(100 . "AcDbEntity") (67 . 0) (410 . "模型") (8 . "0") (100 . "AcDbCircle")
(10 2228.71 1228.61 0.0) (40 . 0.0) (210 0.0 0.0 1.0) (100 . "CMyGcd") (90 . 1)
)
我只想知道如何在我的 DBX 项目中实现这些目标。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-2 00:10 , Processed in 1.672413 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表