【MSCE C++】如何放置注释文本、单元等元素

采用编程的方式放置文本、单元等元素,如何使其成为注释文本或注释单元?最好附有一段简单的代码,谢谢!

Parents Reply
  • 通过IAnnotationHandlerP annoHandlerP = dynamic_cast<IAnnotationHandler*>(&eeh.GetHandler());可以获取到,不过这里对Cell有特殊要求,这个Cell必须是一个Annotation Cell,刚刚在Mstn里边试了一下,只有从单元库中放置出来的Cell才能放置为一个Annotation Cell,而且单元库中Cell制作时,其所在的Model的As Annotation Cell也要选中,如下图所示。

    Answer Verified By: mz z 

Children
  • 郭老师好!

    我看共享单元类中有注释比例,为什么我生成的共享单元加上注释比例属性后体现不出来(在改变模型的注释比例是)?

    struct          SharedCellHandler : DisplayHandler,
                                        ISharedCellQuery,
                                        IAnnotationHandler

    我的代码如下:

    void createSharedCellOnTheFly (DPoint3dR org)
    {
     MSElement           sharedCell;
     DPoint3d            scale = {1.0, 1.0, 1.0}; //, org = {10000, 10000, 0};
     WCharCP             wCellName = L"My-SharedCell";

     mdlSharedCell_create (&sharedCell, NULL, &org, NULL, &scale, wCellName, NULL, FALSE, 0, NULL);
        if (SUCCESS != mdlSharedCell_makeSureDefExists (&sharedCell))
        {
      MSElement           el;
            MSElementDescrP     edP = NULL;
      mdlSharedCell_createDefinitionElement (&el, wCellName, FALSE);
            mdlElmdscr_new (&edP, NULL, &el);
      mdlEllipse_create (&el, NULL, NULL, 1000, 1000, NULL, -1);
      mdlElmdscr_appendElement (edP, &el);
      mdlSharedCell_setOriginAndRange (edP, NULL);
      mdlSharedCell_addDefinitionElements (edP, NULL,NULL);
            mdlElmdscr_freeAll (&edP);
        }
     mdlSharedCell_setRange (&sharedCell, ACTIVEMODEL);

        EditElementHandle   cellEeh(&sharedCell, ACTIVEMODEL);
        SharedCellHandler *ah = dynamic_cast<SharedCellHandler*>(&cellEeh.GetHandler());
       

        if(ah->AddAnnotationScale(cellEeh, ACTIVEMODEL) != SUCCESS)
          NotificationManager::OutputMessage (NotifyMessageDetails(OutputMessagePriority::Info, L"添加注释失败 !"));

        mdlElement_add (&sharedCell);
    }

  • 试试用mdlCell_placeCell从单元库中放置共享单元,倒数第三个参数控制是普通单元还是共享单元。程序中创建出来的共享单元可能不支持注释比例,