找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1221|回复: 1

[填充] 创建填充对象并设置比例

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-8 13:01:42 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

问题:
How do I create a hatch object and set its scale? I had a function in my ARX
application that was used to create HATCH pattern. However, I found that it was
useless to set scale in my application because I had to set the scale manually
once again in AutoCAD. Why did this happen?解答:
This might be caused by the wrong placement of setPatternScale() function. Note
that you have to set hatch pattern properties, such as, pattern angle, pattern
scale, associativity, and pattern name just after AcDbHatch has been created.
After appending loops to the hatch object, you can set its other properties,
such as layer name, color index, hatch style and so on. Then evaluateHatch()
method must be used to evaluate if it can be properly displayed on the screen.
And lastly it should be appended to AutoCAD database and closed. The following
code shows how to do this exactly. For detailed information, refer to AcDbHatch
class explanation in ObjectARX documentation.

  1. #define AOK(es) if(es != Acad::eOk) throw es;
  2. void createHatch(void)
  3. {         
  4.             AcDbObjectId objId;
  5.             AcDbEntity* pEnt;
  6.             ads_name ent;
  7.             ads_point point;

  8.             if (RTNORM != acedEntSel("SELECT AN ENTITY TO BE HATCHED: ", ent,
  9. point))
  10.                         return;
  11.             assert(objId.setFromOldId(ent[0]));
  12.             AOK( acdbOpenObject(pEnt,objId,AcDb::kForRead) );

  13.             AcDbHatch *pHatch = new AcDbHatch;
  14.             assert(pHatch);
  15.             try
  16.             {
  17.                         AcDbBlockTableRecordPointer pBtr(ACDB_MODEL_SPACE,
  18. curDoc()->database(), AcDb::kForWrite);
  19.                         AOK(pBtr.openStatus());

  20.                         AOK(pHatch->setPatternAngle(0));
  21.                         AOK(pHatch->setPatternScale(10));
  22.                         AOK(pHatch->setAssociative(Adesk::kFalse));
  23.                         AOK(pHatch->setPattern(AcDbHatch::kPreDefined, "ANSI32"));

  24.                         // append loop to hatch
  25.                         AcDbObjectIdArray dbObjIds;
  26.                         int objNum = dbObjIds.append(pEnt->objectId());
  27.                         acutPrintf("\nOBJ number is %d.", objNum);
  28.                         AOK(pHatch->appendLoop(AcDbHatch::kExternal, dbObjIds));

  29.                         AOK(pHatch->setLayer(pEnt->layer()));
  30.                         AOK(pHatch->setColorIndex(256));     //bylayer
  31.                         AOK(pHatch->setHatchStyle(AcDbHatch::kNormal));
  32.                         AOK(pHatch->evaluateHatch());
  33.                         AOK(pBtr->appendAcDbEntity(pHatch));
  34.                         AOK(pHatch->close());
  35.             }
  36.             catch (const Acad::ErrorStatus es)
  37.             {
  38.                         acutPrintf("Error: %s", acadErrorStatusText(es));
  39.                         delete pHatch;
  40.             }
  41. }




论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2021-3-17 09:51:57 | 显示全部楼层
学习学习,谢谢
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-3-28 18:35 , Processed in 0.249020 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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