如题,我有许多标准构件放在.cel文件中,现在我想将这些构件取出来放到指定的位置,要如何实现呢?因为我需要对创建设的Eelement做许多自定义操作,不希望用Bentley.Interop.MicrostationDGN.Application中的接口来实现。
貌似还是Introp下的接口最省事容易实现的,您可以通过这个帖子(https://communities.bentley.com/communities/other_communities/bdn_other_communities/w/chinabdn-wiki/41035/c-cli-addins)里边的方法把生成的共享单元元素转换成新的框架下的元素。
我刚找了个前面的帖子,按如下代码:
Segment3d segment1 = new DSegment3d(0, 0, 0, 0, 10000, 0); LineElement lineEeh1 = new LineElement(m_dgnFile.GetDictionaryModel(), null, segment1);
//Create a named shared Cell. SharedCellDefinitionElement scEeh = new SharedCellDefinitionElement(m_dgnFile.GetDictionaryModel(), "NamedCell1"); scEeh.AddChildElement(lineEeh1); scEeh.AddChildComplete(); scEeh.AddToModel();
//Create named Cell instances. DPoint3d origin1 = new DPoint3d(0, 1000, 0); DPoint3d scale = new DPoint3d(1, 1, 1); DMatrix3d rotation = new DMatrix3d(1, 0, 0, 0, 1, 0, 0, 0, 1); SharedCellElement sharedInstanceEeh = new SharedCellElement(dgnModel, null, "NamedCell1", origin1, rotation, scale); sharedInstanceEeh.AddToModel();
但发现scEeh执行AddToModel后elmentId为0,然后我的sharedInstanceEeh执行AddToModel后没有成功,视图上没有显示。请问是什么原因?
您这个扣件是怎么创建的,我将这个共享单元打散后,这个扣件的Range显示貌似不太正常:
构件库.cel这个是我的.cel文件,我用MS的Place Active Cell也会出现同样的问题,但打开.cel文件浏览,显示是正常的,不知道是什么原因!
我用Place Active Cell工具都正常呀
嗯,我刚试了下,MS中确实可以放置,但用上面的代码,还有Interop接口创建,都会有问题,不知是什么原因。
我又仔细看了下,里面没有显示出来的那部分是ParamicSolid类型元素,也就是参数化的实体,是否和这个相关?我经过反复试验,发现用MS自带的工具就可以创建共享实例单元,但用自己的代码,无论是Interop接口,还是非Interop接口,都不行,请问是什么原因呢?我搜索了论坛的贴子,发现有和我类似情况的,里面有提到,说”有参数化的cell貌似是没法创建共享单元的“,不知是不是真的。https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/194927/ms-ce-updt13-c-sharedcell
lingwei liu said:但用上面的代码,还有Interop接口创建,都会有问题
不一回事,从单元库中放单元的话用如下代码:
MsApp.AttachCellLibrary(@"D:\构件库.cel"); BIM.Point3d ori = new BIM.Point3d(); ori.X = 10; MsApp.ActiveModelReference.AddElement(MsApp.CreateSharedCellElement3("P5600", ref ori, false));