我在界面上弄了个按钮,想让用户点击后加载一个交互工具,选择一个元素。
目前我是使用了一个继承自DgnElementSetTool的子类做的,在_OnElementModify中获取选择集进行操作,但问题是对于参考进来的只读元素无法进行选择,重写了_OnPostLocate函数也无济于事,请问该如何实现?实在不行,就只能让用户先选择了。。。
protected override bool OnDataButton(DgnButtonEvent ev) { if(userstate == CurrentState.none) { HitPath hitPath = DoLocate(ev, true, 1); if (null == hitPath) { return false; } selectedSurface = hitPath.GetHeadElement(); MeshHeaderElement currentmesh = selectedSurface as MeshHeaderElement;
你按这种方法尝试选择一个元素吧。
virtual bool _IsModifyOriginal () override {return false;}
其实搜一下以前的帖子也能找到该问题的答案的。如下:
https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/177401/msce-c-dgnelementsettool
https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/151508/c-msv8i-ilocatecommandevents
Answer Verified By: 程远 李
重写_IsModifyOriginal后确实可以选中只读元素了,但是好像不能正确获取元素的id了。。。我已经改成让用户先选择再点按钮了。。。
你是如何获取元素Id的?注意此时的DgnModelRef已经不是ACTIVEMODEL了,而是指定的参考模型的DgnModelRef了。