就是下图这种:
搜一下以前的帖子看看,以前帖子有讨论过。
我搜过了,最接近的只有下面这些帖子:communities.bentley.com/.../c-ord(这是问螺旋体如何拐角的,没有贴任何代码)communities.bentley.com/.../thread(这帖子提到了mdlKISolid_sweepBodyWire函数,但它是C++的,我没找到C#的函数)communities.bentley.com/.../msce-c-mdlbspline_helix-axis1-axis2(这篇帖子也提到一个C++函数:mdlBspline_helix,但是我也没找到对应的C#的函数)
我用helix关键字在对象浏览器里只有搜到一个Bentley.Interop.MicroStationDGN.BsplineCurve.Helix()的函数,这个是Interop的,本身是个接口,本身不能实例化,也没找到实现它的类,所以不知道怎么用。
Bentley.Interop.MicroStationDGN.Application.CreateBsplineCurveElement1
Bentley.Interop.MicroStationDGN.Application是个接口,CreateBsplineCurveElement1不是它的静态函数,你发的代码是不能运行的,怎么引用interop下的Application实例对象呢?
另外可不可以把interop下的这个螺旋体对象转换成Bentley.DgnPlatformNET.Elements空间下的Element对象呢?
我找到这篇Wiki可以把COM对象的Element转换为NET下的Element:
communities.bentley.com/.../element
但是又有个问题,就是这个BsplineCurveClass怎么转换成Element呢?
已经找到怎么转COM下的Element的方法了:
Bentley.Interop.MicroStationDGN.Point3d startPt = new Bentley.Interop.MicroStationDGN.Point3d(); startPt.X = 0; startPt.Y = 0; startPt.Z = 0; Bentley.Interop.MicroStationDGN.Point3d endPt = new Bentley.Interop.MicroStationDGN.Point3d(); endPt.X = 0; endPt.Y = 0; endPt.Z = 20000; Bentley.Interop.MicroStationDGN.Segment3d axis = new Bentley.Interop.MicroStationDGN.Segment3d(); axis.StartPoint = startPt; axis.EndPoint = endPt; Bentley.Interop.MicroStationDGN.BsplineCurve bsplineCurve = new Bentley.Interop.MicroStationDGN.BsplineCurveClass(); bsplineCurve.Helix(5000, 5000, startPt, axis, 1000); Bentley.Interop.MicroStationDGN.Application app = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp; Bentley.Interop.MicroStationDGN.BsplineCurveElement bsplineCurveElement = app.CreateBsplineCurveElement1(null, bsplineCurve);
再结合上面提到那片COM对象转NET对象的wiki,就可以创建NET下的螺旋体了。
不过我卡在设置别名那一步,这个是无解的啊……因为改了dll程序集的别名,我同一个项目解决方案下的其他*.cs文件都不识别DgnPlatformNet中的对象了,错误一下子多了几百个。
我准备自己重新搞一个用基本数学知识创建螺旋体的函数。
Answer Verified By: 巴燕 史
这样获取Bentley.Interop.MicroStationDGN.Application:Bentley.Interop.MicroStationDGN.Application MsApp = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;