我现在已经实现了一个3d模型中的标注工具,它能够实现类似于textfield的效果,并且除此之外能够随标注对象的移动而移动。
可是,似乎dependency功能在obd剖出的绘图中就不管用了,标注元素对应dependency的OnRootChange似乎只在元素创建和删除时触发(link.data中保存的是另一个model的elementid)。
是不是还有什么操作,必须要在link.data中标记,才能使得两个不同model中的元素关联在一起
请注意DependencyManager::InitLinkage函数中的第三个参数的用法。该参数叫做dataType,即数据类型。在SDK中的例子其实是用错了,随便定义了一个1。该参数应该是DEPENDENCY_DATA_TYPE开头的一些常数。在函数说明中有提到:
那么,我们查询头文件能得到如下信息:
// Identifies type of root data in DependencyLinkage: #define DEPENDENCY_DATA_TYPE_ELEM_ID 0 //!< Type of root data in DependencyLinkage: ElementId - an element in the same model #define DEPENDENCY_DATA_TYPE_ELEM_ID_V 1 //!< Type of root data in DependencyLinkage: ElementID_V - an an element in the same model paired with a data value #define DEPENDENCY_DATA_TYPE_ASSOC_POINT 2 //!< Type of root data in DependencyLinkage: AssocPoint - an associative point on an element in the same or a different model. #define DEPENDENCY_DATA_TYPE_ASSOC_POINT_I 3 //!< Type of root data in DependencyLinkage: AssocPoint_I - an associative point paired with a data value. #define DEPENDENCY_DATA_TYPE_FAR_ELEM_ID 4 //!< Type of root data in DependencyLinkage: FarElementID - an element in the same or a different model. #define DEPENDENCY_DATA_TYPE_FAR_ELEM_ID_V 5 //!< Type of root data in DependencyLinkage: FarElementID_V - an element in the same or a different model, paired with a data value. #define DEPENDENCY_DATA_TYPE_PATH_V 6 //!< Type of root data in DependencyLinkage: Path_V - a path to an element in the same or a different m
其中1就是DEPENDENCY_DATA_TYPE_ELEM_ID_V,后面的解释是an element in the same model paired with a data value,也就是只能支持同一个模型中,同时附带有一个数据值。
那么不附带数据值的是0,即DEPENDENCY_DATA_TYPE_ELEM_ID
可以支持跨模型的应该是:DEPENDENCY_DATA_TYPE_FAR_ELEM_ID (就是4),跨模型同时还附带一个数据值的是DEPENDENCY_DATA_TYPE_FAR_ELEM_ID_V(就是5)。针对您的情况,选4即可。
MS学习资源:
MicroStation Wednesday视频分享
深入探讨MicroStation DGN基本概念系列
一步步学习MicroStation CE Addin开发
一步步学习MicroStation CE MDL开发
Answer Verified By: lblk dug
Nice大fu!