[ABDV8i C#]如何通过接口 创建一个孔?

我是个二次开发的新手,C# 中想通过调用API 创建一个孔洞对象,我找到了

STFHoleListClass stfHoleListClass=new STFHoleListClass();
STFHole stfHole = stfHoleListClass.AsSTFHole;

但好象在New 的时候就报错了,想请教下各位老师应该怎么做?

  • 谢谢您的回复!
    再想请教你一下如何在ABD V8i C# 的二次开发如何在WALL或者Floor上实现孔洞呢?还是目前实现不了?
  • ABD的C#接口目前没有公开,也没有任何资料可参考。但ABD有SDK(需要BDN用户才能下载)中有C/C++接口可实现墙体开洞。实例代码如下:

    void addOpeningToWall (void)
    {
    	ElementID        wallId = 7977, shapeId = 10868;
    	MSElementDescr   *shapeEdP = NULL;
    	TFBrepList       *pBrepList = NULL;
    	TFFormRecipeList *pFormList = NULL;
    	TFFormRecipe     *pForm = NULL;
    	mdlTFModelRef_readFormRecipeListToMasterById (ACTIVEMODEL, &pFormList, wallId);
    	pForm = mdlTFFormRecipeList_getFormRecipe (pFormList);
    	mdlAssoc_getElementDescr (&shapeEdP, NULL, shapeId,  ACTIVEMODEL, FALSE);
    	mdlTFBrepList_constructFromElmdscr2(&pBrepList, shapeEdP, ACTIVEMODEL);
    	mdlElmdscr_freeAll (&shapeEdP);
    	mdlTFFormRecipe_addOpeningByBrepNode (pForm, NULL, L"OPENING_1", &pBrepList, 0, TRUE, NULL);
    	mdlTFFormRecipe_synchronize (pForm);
    	mdlTFModelRef_rewriteFormRecipe (ACTIVEMODEL, pForm);
    	mdlTFFormRecipeList_free (&pFormList);
    }
    



    Answer Verified By: yan liu 

  • 参考MDL的代码,试了一下,下面这种方法是可行的。

    TFPolyList _poly = new TFPolyList();

    TFPoly poly = _poly.AsTFPoly;

    poly.SetPoints(lstVertex/*Point[],围成切割区域的平面点坐标数组*/);

    TFBrepList lstBrep = new TFBrepList();

    lstBrep.Init();

    lstBrep.InitFromPolyListPlanar(polyList, 0.0, 0.0);

    TFFeature oFeature = null;

    oRecipe.AddOpeningByBrepNode(out oFeature, "OpeningTest", ref lstBrep, dHeight * 0.5, true, ref ptNorm/*拉伸方向*/);

    打出来的代码,可能有拼写错误,不过测试是通过的,可以完成切割。

    不过现在有一个问题是,这种方式创建出来的切割我不知道怎么删除,所以不是很敢用……MDL里有一个free的函数,.NET里没有找到对应的。

  • 【移动墙体的孔洞】:FormReciptList > FormRecipe > FeatureList > Feature > mdlTFFeature_move
    【缩放墙体的孔洞】:mdlTFFeaure_transform
    【删除墙体的孔洞】:mdlTFFeatureList_unlinkNode
    您可以按此思路用C#改写。



  • 感谢符工,真给力,的确是这个unlinkNode函数。今天测试了一下,可以完成洞口的删除。

    //  取出Feature, oRecipe为TFFormRecipe实例

    var lstFeature = oRecipe.GetFeatureList();

    //  这里可以遍历,筛选出需要删除的Feature

    //  示例代码直接写删除第一个了

    TFFeatureList lstToDel = lstFeature.GetNode(0);

    if (-1 != lstFeature.GetIndex(lstToDel)) {

        lstFeature.UnlinkNode(lstToDel);

    }

    //  还要手动设置回去

    oRecipe.SetFeatureList(lstFeature);

    这么看来如果能手动构造一个lstFeature也可以通过这个SetFeatureList函数直接开洞,不过可能要费事一些。

    再次感谢符工。