TFFormRecipe函数,是ABD支持的最基本的几何数据操作的接口。
这个函数是在内存中构造新的FormRecipeLinearList。这个是很多函数需要用到的参数类型。
这个函数从List中提取一个FormRecipe,进行操作。
这个函数负责保存在内存中创建的List.
不同于上面介绍的函数,这个函数的功能是,从文件中构造List,从而可以用其他的函数来修改现有的元素的属性。
这个函数用来得到保存的FormRecipe的ElementId。
创建几何数据的第一步是,建立FormRecipeList,然后找到第一个FormRecipe,设置他的属性,最后写入到文件中。下面的代码就是描述这个过程。
TFFormRecipeLinearList* pRecipeNode = mdlTFFormRecipeLinearList_construct (); TFFormRecipeLinear* pRecipe = mdlTFFormRecipeLinearList_getFormRecipeLinear (pRecipeNode); mdlTFFormRecipeLinear_setTopFixedHeight (pRecipe, 10000); mdlTFFormRecipeLinear_setThickness (pRecipe, 200); mdlTFFormRecipeLinear_setOffsetType (pRecipe, FormRecipeOffsetTypeEnum_Left); mdlTFFormRecipeLinear_setSweepDirection (pRecipe, &sweepDir); mdlTFFormRecipeLinear_setEndPoints2 (pRecipe, &startPoint, &endPoint); mdlTFFormRecipeList_synchronize (pRecipeNode); mdlTFModelRef_addFormRecipeList (ACTIVEMODEL, pRecipeNode);
再写入文件之后,不要删除这个FormRecipe,这是在这个FormRecipe中保存着写入文件之后的元素的id。我们使用这个id,加载这个元素,给这个元素增加DataGroup属性。
另外一种用法是,修改现有文件中的元素的属性。那么就需要用到上面提到的函数:mdlTFFormRecipeList_constructFromElmdscr。这里有一段测试代码可以参考他的用法。
TFFormRecipeLinearList* pRecipeNode mdlTFFormRecipeList_constructFromElmdscr(&pRecipeNode, &pInputEdP); TFFormRecipeLinear* pRecipe = mdlTFFormRecipeLinearList_getFormRecipeLinear (pRecipeNode); mdlTFFormRecipeLinear_setTopFixedHeight (pRecipe, 10000); mdlTFFormRecipeList_synchronize (pRecipeNode); TFApplication_modelReferenceRewriteFormRecipeList (ACTIVEMODEL, pRecipeNode);
代码中的pInputEdP,是一个从ACTIVEMODEL加载的对象,修改属性之后,又写回到ACTIVEMODEL中。