Grant Zhang said:一条由这些点连接成的空间曲线
您所说的“空间曲线”具体想要哪种的?是直接将这些点连接起来就可以呢?还是说这些点仅仅是控制点,要构造出空间的B样条曲线?
不同的方法需要调用不同的函数来创建的。
Grant Zhang said:不知道有没有能实现这个功能的函数库没有?
如果是直接连接:读取点坐标后调用LineStringHandler::CreateLineStringElement就能创建出一个EditElementHandle,然后调用其下的AddToModel就能添加到MS模型中来查看了。如果想要B样条曲线,会复杂一些,需要研究一下MSBsplineCurve类。
符老师,我的意思不是在MSCE上面二次开发创建曲线。是我有这些数据,如何转成dgn文件?有没有相关的技术?
Work smart, not just work hard!
Grant Zhang said:是我有这些数据,如何转成dgn文件?有没有相关的技术?
您的意思是脱离MSCE软件就要生成一个DGN?这不太现实吧?
如果说你不想让用户看到MSCE的启动界面,可以通过COM技术将MSCE的启动隐藏起来,但从点到DGN的生成还是需要MSCE参与的。
就是必须装上MSCE,整个创建过程在MSCE里面创建,但是隐藏起来看不见。
Yongan.Fu said:可以通过COM技术将MSCE的启动隐藏起来
这个技术有没有相关的资料介绍或者教程?
这是通用技术,可查微软网站或百度了解更多信息。用C# 比较容易写出COM程序来。MSCE的COM对象是Bentley.Interop.MicroStationDGN,需要我们在一个普通的WinForm项目中引用该DLL后用如下示例代码就能往现有的一个DGN文件中增加一条线。MSCE不会在前台出现(通过myApp.Visible = false来控制的)。关键是要花时间学习Bentley.Interop.MicroStationDGN对象模型,这套对象模型不同于.NET下的对象模型。需要我们参考MicroStationVBA.chm帮助文档来学习。因为这个对象模型的最初原因是为MS支持VBA而开发的。
using System.IO; using Bentley.Interop.MicroStationDGN; /* If there are more than one Engines(MicroStation, OBD, ORD etc.) installed, we can start an Engine with -automation parameter first, * and then use below program to find specific engine. */ namespace AutomationMSCE { class Program { static void Main(string[] args) { string dgnFile = @"D:\CETest.DGN"; if (!File.Exists(dgnFile)) return; ApplicationObjectConnector msAppConnector = new ApplicationObjectConnectorClass(); //Always start a new process Application msApp = msAppConnector.Application; //Bentley.Interop.MicroStationDGN.Application msApp = // (Bentley.Interop.MicroStationDGN.Application)Microsoft.VisualBasic.Interaction.GetObject("", "MicroStationDGN.Application"); msApp.Visible = false; msApp.OpenDesignFile(dgnFile, false); Point3d[] ptArr = new Point3d[2]; ptArr[0] = msApp.Point3dZero(); ptArr[1] = msApp.Point3dFromXYZ(10, 0, 0); LineElement lineEle = msApp.CreateLineElement1(null, ptArr); msApp.ActiveModelReference.AddElement(lineEle); msApp.Quit(); } } }