[MSCE C++]请问如何给用代码创建的NormalCellHandler增加IsAnnotation属性?

从*.cel库中取出的cell,在cell所在的model中设置Can be placed as AnnotationCell为True时,通过IAnnotationHandler结构下面的AddAnnotationScale()方法可以实现,但是用代码创建的NormalCellHander不知道要如何实现,麻烦老师解答下,谢谢。

Parents
  • 这一部分内容在新的C++编程模型中有问题。我切换到老的C函数可以实现。用到了三个未公开函数。由于办公室网络问题,通过QQ群图片发给你代码



  • 电脑网络恢复了。贴出代码如下:

    /*--------------------------------------------------------
    | createAnnotationCell
    +-------------------------------------------------------*/
    extern "C" void mdlCell_applyAnnotationScale(MSElementDescrH cellEdPP, MSElementDescrH tagEdPP, DgnModelRefP modelRef);
    extern "C" StatusInt mdlCell_setAnnotationScale(MSElementDescrP cellEdP, double * annotationScale);
    extern "C" StatusInt mdlCell_setIsAnnotation (MSElementDescrP cellEdP, bool isAnnotation);
    void createAnnotationCell(WCharCP)
    {
    	BeFileName rtnCellLib, inputCellLib(L"sample2.cel");
    	if (SUCCESS != mdlCell_attachLibrary(rtnCellLib, &inputCellLib, NULL, true))
    	{
    		mdlDialog_dmsgsPrint(L"Can't find sample2.cel");
    		return;
    	}
    	MSElementDescrP cellEdP = NULL;
    	DPoint3d        origin{ 0, 0, 0 }, scale{ 1,1,1 };
    	double          annoScale = 2.0;
    	mdlCell_getElmDscr(&cellEdP, NULL, &origin, &scale, true, NULL, NULL, 0, false, true, L"ARROW", NULL);
    	mdlCell_setIsAnnotation(cellEdP, true);
    	mdlCell_applyAnnotationScale(&cellEdP, NULL, ACTIVEMODEL);
    	mdlCell_setAnnotationScale(cellEdP, &annoScale);
    	mdlElmdscr_add(cellEdP);
    	mdlElmdscr_freeAll(&cellEdP);
    }



    Answer Verified By: Zemin.Li 

Reply
  • 电脑网络恢复了。贴出代码如下:

    /*--------------------------------------------------------
    | createAnnotationCell
    +-------------------------------------------------------*/
    extern "C" void mdlCell_applyAnnotationScale(MSElementDescrH cellEdPP, MSElementDescrH tagEdPP, DgnModelRefP modelRef);
    extern "C" StatusInt mdlCell_setAnnotationScale(MSElementDescrP cellEdP, double * annotationScale);
    extern "C" StatusInt mdlCell_setIsAnnotation (MSElementDescrP cellEdP, bool isAnnotation);
    void createAnnotationCell(WCharCP)
    {
    	BeFileName rtnCellLib, inputCellLib(L"sample2.cel");
    	if (SUCCESS != mdlCell_attachLibrary(rtnCellLib, &inputCellLib, NULL, true))
    	{
    		mdlDialog_dmsgsPrint(L"Can't find sample2.cel");
    		return;
    	}
    	MSElementDescrP cellEdP = NULL;
    	DPoint3d        origin{ 0, 0, 0 }, scale{ 1,1,1 };
    	double          annoScale = 2.0;
    	mdlCell_getElmDscr(&cellEdP, NULL, &origin, &scale, true, NULL, NULL, 0, false, true, L"ARROW", NULL);
    	mdlCell_setIsAnnotation(cellEdP, true);
    	mdlCell_applyAnnotationScale(&cellEdP, NULL, ACTIVEMODEL);
    	mdlCell_setAnnotationScale(cellEdP, &annoScale);
    	mdlElmdscr_add(cellEdP);
    	mdlElmdscr_freeAll(&cellEdP);
    }



    Answer Verified By: Zemin.Li 

Children