找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 581|回复: 2

[ARX函数]:代码讨论,急!

[复制链接]
发表于 2002-12-21 16:52:21 | 显示全部楼层 |阅读模式

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

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

×
为什么一下代码不能显示填充图案?请各位高手帮我分析一下,谢谢!
  1. [font=courier new]
  2. Adesk::Boolean zmyrectangle::worldDraw(AcGiWorldDraw* mode)
  3. {
  4.         assertReadEnabled();
  5.         // TODO: implement this function.
  6.         AcGePoint3d Pts[2];
  7.         AcGePoint3d pt[4];
  8.         AcDbObjectId lineId0;
  9.         AcDbObjectId lineId1;
  10.         AcDbObjectId lineId2;
  11.         AcDbObjectId lineId3;
  12.         AcDbObjectIdArray dbObjIds;
  13.     AcDbLine *line0;
  14.         AcDbLine *line1;
  15.         AcDbLine *line2;
  16.         AcDbLine *line3;
  17.         point(pt);

  18.         Pts[0].x=pt[0].x;Pts[0].y=pt[0].y;Pts[0].z=0;
  19.         Pts[1].x=pt[1].x;Pts[1].y=pt[1].y;Pts[1].z=0;
  20.         line0=new AcDbLine(Pts[0],Pts[1]);
  21.         line0->worldDraw(mode);
  22.         //line->postToDb(line, lineId);
  23.     dbObjIds.append(lineId0);
  24.        
  25.        
  26.         Pts[0].x=pt[1].x;Pts[0].y=pt[1].y;Pts[0].z=0;
  27.         Pts[1].x=pt[2].x;Pts[1].y=pt[2].y;Pts[1].z=0;
  28.         line1=new AcDbLine(Pts[0],Pts[1]);
  29.         line1->worldDraw(mode);
  30.         //line->postToDb(line, lineId);
  31.     dbObjIds.append(lineId1);

  32.         Pts[0].x=pt[2].x;Pts[0].y=pt[2].y;Pts[0].z=0;
  33.         Pts[1].x=pt[3].x;Pts[1].y=pt[3].y;Pts[1].z=0;
  34.         line2=new AcDbLine(Pts[0],Pts[1]);
  35.         line2->worldDraw(mode);
  36.         //line->postToDb(line, lineId);
  37.     dbObjIds.append(lineId2);

  38.         Pts[0].x=pt[3].x;Pts[0].y=pt[3].y;Pts[0].z=0;
  39.         Pts[1].x=pt[0].x;Pts[1].y=pt[0].y;Pts[1].z=0;
  40.         line3=new AcDbLine(Pts[0],Pts[1]);
  41.         line3->worldDraw(mode);
  42.         //line->postToDb(line, lineId);
  43.     dbObjIds.append(lineId3);
  44.        

  45.         AcDbHatch *pHatch=new AcDbHatch();
  46.         AcGeVector3d normal(0.0, 1.0, 0.0);
  47.     pHatch->setNormal(normal);
  48.     //pHatch->setElevation(0.0);

  49.     // Set hatch pattern to ANSI31 predefined type
  50.     //
  51.     pHatch->setPattern(AcDbHatch::kPreDefined, "ANSI31");

  52.     // Set Associativity
  53.     //
  54.    // pHatch->setAssociative(Adesk::kTrue);
  55.        

  56.     // Append an internal loop (circle) to hatch boundary
  57.     //
  58.     //pHatch->appendLoop(AcDbHatch::kDefault, dbObjIds);
  59.         pHatch->appendLoop(AcDbHatch::kExternal, dbObjIds);
  60.         pHatch->worldDraw(mode);
  61.         // Elaborate hatch lines
  62.     //
  63.     pHatch->evaluateHatch();

  64.         // Post hatch entity to database
  65.     //
  66.     //pHatch->postToDb(pHatch);


  67.        

  68.         delete pHatch;
  69.         delete line0;
  70.         delete line1;
  71.         delete line2;
  72.         delete line3;
  73.         return Acad::eOk;
  74. }Adesk::Boolean zmyrectangle::worldDraw(AcGiWorldDraw* mode)
  75. {
  76.         assertReadEnabled();
  77.         // TODO: implement this function.
  78.         AcGePoint3d Pts[2];
  79.         AcGePoint3d pt[4];
  80.         AcDbObjectId lineId0;
  81.         AcDbObjectId lineId1;
  82.         AcDbObjectId lineId2;
  83.         AcDbObjectId lineId3;
  84.         AcDbObjectIdArray dbObjIds;
  85.     AcDbLine *line0;
  86.         AcDbLine *line1;
  87.         AcDbLine *line2;
  88.         AcDbLine *line3;
  89.         point(pt);

  90.         Pts[0].x=pt[0].x;Pts[0].y=pt[0].y;Pts[0].z=0;
  91.         Pts[1].x=pt[1].x;Pts[1].y=pt[1].y;Pts[1].z=0;
  92.         line0=new AcDbLine(Pts[0],Pts[1]);
  93.         line0->worldDraw(mode);
  94.         //line->postToDb(line, lineId);
  95.     dbObjIds.append(lineId0);
  96.        
  97.        
  98.         Pts[0].x=pt[1].x;Pts[0].y=pt[1].y;Pts[0].z=0;
  99.         Pts[1].x=pt[2].x;Pts[1].y=pt[2].y;Pts[1].z=0;
  100.         line1=new AcDbLine(Pts[0],Pts[1]);
  101.         line1->worldDraw(mode);
  102.         //line->postToDb(line, lineId);
  103.     dbObjIds.append(lineId1);

  104.         Pts[0].x=pt[2].x;Pts[0].y=pt[2].y;Pts[0].z=0;
  105.         Pts[1].x=pt[3].x;Pts[1].y=pt[3].y;Pts[1].z=0;
  106.         line2=new AcDbLine(Pts[0],Pts[1]);
  107.         line2->worldDraw(mode);
  108.         //line->postToDb(line, lineId);
  109.     dbObjIds.append(lineId2);

  110.         Pts[0].x=pt[3].x;Pts[0].y=pt[3].y;Pts[0].z=0;
  111.         Pts[1].x=pt[0].x;Pts[1].y=pt[0].y;Pts[1].z=0;
  112.         line3=new AcDbLine(Pts[0],Pts[1]);
  113.         line3->worldDraw(mode);
  114.         //line->postToDb(line, lineId);
  115.     dbObjIds.append(lineId3);
  116.        

  117.         AcDbHatch *pHatch=new AcDbHatch();
  118.         AcGeVector3d normal(0.0, 1.0, 0.0);
  119.     pHatch->setNormal(normal);
  120.     //pHatch->setElevation(0.0);

  121.     // Set hatch pattern to ANSI31 predefined type
  122.     //
  123.     pHatch->setPattern(AcDbHatch::kPreDefined, "ANSI31");

  124.     // Set Associativity
  125.     //
  126.    // pHatch->setAssociative(Adesk::kTrue);
  127.        

  128.     // Append an internal loop (circle) to hatch boundary
  129.     //
  130.     //pHatch->appendLoop(AcDbHatch::kDefault, dbObjIds);
  131.         pHatch->appendLoop(AcDbHatch::kExternal, dbObjIds);
  132.         pHatch->worldDraw(mode);
  133.         // Elaborate hatch lines
  134.     //
  135.     pHatch->evaluateHatch();

  136.         // Post hatch entity to database
  137.     //
  138.     //pHatch->postToDb(pHatch);


  139.        

  140.         delete pHatch;
  141.         delete line0;
  142.         delete line1;
  143.         delete line2;
  144.         delete line3;
  145.         return Acad::eOk;
  146. }Adesk::Boolean zmyrectangle::worldDraw(AcGiWorldDraw* mode)
  147. {
  148.         assertReadEnabled();
  149.         // TODO: implement this function.
  150.         AcGePoint3d Pts[2];
  151.         AcGePoint3d pt[4];
  152.         AcDbObjectId lineId0;
  153.         AcDbObjectId lineId1;
  154.         AcDbObjectId lineId2;
  155.         AcDbObjectId lineId3;
  156.         AcDbObjectIdArray dbObjIds;
  157.     AcDbLine *line0;
  158.         AcDbLine *line1;
  159.         AcDbLine *line2;
  160.         AcDbLine *line3;
  161.         point(pt);

  162.         Pts[0].x=pt[0].x;Pts[0].y=pt[0].y;Pts[0].z=0;
  163.         Pts[1].x=pt[1].x;Pts[1].y=pt[1].y;Pts[1].z=0;
  164.         line0=new AcDbLine(Pts[0],Pts[1]);
  165.         line0->worldDraw(mode);
  166.         //line->postToDb(line, lineId);
  167.     dbObjIds.append(lineId0);
  168.        
  169.        
  170.         Pts[0].x=pt[1].x;Pts[0].y=pt[1].y;Pts[0].z=0;
  171.         Pts[1].x=pt[2].x;Pts[1].y=pt[2].y;Pts[1].z=0;
  172.         line1=new AcDbLine(Pts[0],Pts[1]);
  173.         line1->worldDraw(mode);
  174.         //line->postToDb(line, lineId);
  175.     dbObjIds.append(lineId1);

  176.         Pts[0].x=pt[2].x;Pts[0].y=pt[2].y;Pts[0].z=0;
  177.         Pts[1].x=pt[3].x;Pts[1].y=pt[3].y;Pts[1].z=0;
  178.         line2=new AcDbLine(Pts[0],Pts[1]);
  179.         line2->worldDraw(mode);
  180.         //line->postToDb(line, lineId);
  181.     dbObjIds.append(lineId2);

  182.         Pts[0].x=pt[3].x;Pts[0].y=pt[3].y;Pts[0].z=0;
  183.         Pts[1].x=pt[0].x;Pts[1].y=pt[0].y;Pts[1].z=0;
  184.         line3=new AcDbLine(Pts[0],Pts[1]);
  185.         line3->worldDraw(mode);
  186.         //line->postToDb(line, lineId);
  187.     dbObjIds.append(lineId3);
  188.        

  189.         AcDbHatch *pHatch=new AcDbHatch();
  190.         AcGeVector3d normal(0.0, 1.0, 0.0);
  191.     pHatch->setNormal(normal);
  192.     //pHatch->setElevation(0.0);

  193.     // Set hatch pattern to ANSI31 predefined type
  194.     //
  195.     pHatch->setPattern(AcDbHatch::kPreDefined, "ANSI31");

  196.     // Set Associativity
  197.     //
  198.    // pHatch->setAssociative(Adesk::kTrue);
  199.        

  200.     // Append an internal loop (circle) to hatch boundary
  201.     //
  202.     //pHatch->appendLoop(AcDbHatch::kDefault, dbObjIds);
  203.         pHatch->appendLoop(AcDbHatch::kExternal, dbObjIds);
  204.         pHatch->worldDraw(mode);
  205.         // Elaborate hatch lines
  206.     //
  207.     pHatch->evaluateHatch();

  208.         // Post hatch entity to database
  209.     //
  210.     //pHatch->postToDb(pHatch);


  211.        

  212.         delete pHatch;
  213.         delete line0;
  214.         delete line1;
  215.         delete line2;
  216.         delete line3;
  217.         return Acad::eOk;
  218. }
  219. [/font]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-12-21 16:59:06 | 显示全部楼层

Re: [ARX函数]:代码讨论,急!

最初由 zmyqhx 发布
[B]为什么一下代码不能显示填充图案?请各位高手帮我分析一下,谢谢!
[code]
Adesk::Boolean zmyrectangle::worldDraw(AcGiWorldDraw* mode)
{
        assertReadEnabled();
        // TODO: implement this f... [/B]


怎么贴出来3个同名的函数?他们不同吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-12-23 13:08:31 | 显示全部楼层
point(pt); 是什么?算对了吗?
应该出来了,看不出毛病(暂时的)
把下面一句改一改看看,改成填实的
pHatch->setPattern(AcDbHatch::kPreDefined, "ANSI31");

看看我这个
    AcDbHatch* pHatch = new AcDbHatch();
    AcGeVector3d normal(0.0, 0.0, 1.0);
    pHatch->setNormal(normal);
    pHatch->setElevation(0.0);
    pHatch->setAssociative(Adesk::kFalse);
    pHatch->setPattern(AcDbHatch::kPreDefined, "SOLID");
    pHatch->setHatchStyle(AcDbHatch::kNormal);

    AcGePoint2dArray vertexPts;
    AcGeDoubleArray vertexBulges;
    vertexPts.setPhysicalLength(0).setLogicalLength(4);
    vertexPts[0] =
    vertexPts[1] =
    vertexPts[2] =
    vertexPts[3] =

    vertexBulges.setPhysicalLength(0).setLogicalLength(4);
    for (int i = 0; i < 4; i++)
        {
        vertexBulges = 0.0;
        }
    pHatch->appendLoop(AcDbHatch::kExternal, vertexPts, vertexBulges);
    pHatch->evaluateHatch();
    pHatch->worldDraw(mode);
        delete pHatch;
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-28 11:25 , Processed in 0.361572 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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