Addin程序集接口扩充


使用MicroStation SDK Addin接口开发的程序员应该会碰到过C/C++API中有的接口函数但在C#中却找不到的情况。为了解决这个问题,我们单独创建了一个程序集MstnMixedAssistant.DLL,将还未封装到Addin框架中的C++接口封装到我们这个单独的程序集中供大家使用。以后会不断地扩充这个程序集,欢迎大家下载使用。

目前该程序集中封装的内容有:

命名空间 函数原型 功能描述

MstnMixedAssistant      .AssistantFunctions
 
 
public static bool CurveCurveClosestApproach(out Bentley.GeometryNET.CurveLocationDetail pointOnA, out Bentley.GeometryNET.CurveLocationDetail pointOnB, Bentley.GeometryNET.CurveVector chainA, Bentley.GeometryNET.CurveVector chainB) 求两个CurveVector(chainA和chainB)之间的最近距离。返回的是位于这两条曲线上的点pointOnA和pointOnB。
MstnMixedAssistant       .AssistantFunctions public static Bentley.DgnPlatformNET.BentleyStatus MinDistBetweenElms(out double dis, out Bentley.GeometryNET.DPoint3d point1, out Bentley.GeometryNET.DPoint3d point2, Bentley.DgnPlatformNET.Elements.Element ele1, Bentley.DgnPlatformNET.Elements.Element ele2) 求两个三维元素间的最近距离。这两个三维元素可以是实体、曲面也可以是空间的曲线和点。底层调用了C++函数mdlSolid_minimumDistanceBetweenEntities。因此执行效率上可能会低于CurveCurveClosestApporach。所以,如果是求两条曲线间最近距离,继续推荐上面的函数。如果是求三维实体和曲面间最近距离,则必须调用该函数。
MstnMixedAssistant       .AssistantFunctions public static NamedView[] GetNamedViews(DgnFile dgnFile); 获取指定DgnFile中的所有NamedView(或叫SavedView)。原C# 接口有误,总是无法获取到第一个NamedView。
MstnMixedAssistant       .ElementOperation public static Bentley.DgnPlatformNET.Elements.Element ConvertToDgnNetEle
(Bentley.Interop.MicroStationDGN.Element ele)
Interop(即VBA COM)编程对象中的元素(Element)转为.NET编程对象中的元素。该函数支持内存中元素的转换。如果是已经存在于模型中的元素,还可以直接通过在新的编程对象模型中读取元素ID来实现转换。比调用这个函数更简单。
MstnMixedAssistant      .ElementOperation public static Bentley.Interop.MicroStationDGN.Element ConvertToInteropEle
(Bentley.DgnPlatformNET.Elements.Element ele)
.NET编程对象中的元素(Element)转为Interop(即VBA COM)编程对象中的元素。如果是已经存在于模型中的元素,还可以直接通过在新的编程对象模型中读取元素ID来实现转换。比调用这个函数更简单。
MstnMixedAssistant      .ElementOperation public static StatusInt DropElement(Bentley.DgnPlatformNET.Elements.Element ele, out ElementAgenda dropGeom, DropGeometry geometry); 打散元素,底层调用了DisplayHandler::Drop。
MstnMixedAssistant      .ElementOperation public static ulong ElementSize(ulong elementId); 根据元素的ElementId返回其元素的字节大小。请注意,元素属性中显示的元素大小是以字(word)为单位的,所以,该返回值需要除以2才能匹配元素属性中显示的元素大小。该函数仅从当前模型中读取ElementId。
MstnMixedAssistant      .AssistantFunctions public static BentleyStatus CreateBodyFromSweep(out SolidKernelEntity entityOut, CurveVector profileIn, CurveVector pathIn, DgnModelRef modelRefIn, bool alignParallelIn, bool selfRepairIn, bool createSheetIn, DVector3d? lockDirectionIn, double? twistAngleIn, double? scaleIn, DPoint3d? scalePoint); 沿指定路径扫掠轮廓来构造体。原C#接口有误。
MstnMixedAssistant      .AssistantFunctions public static IntPtr MDLPlaceCell(DPoint3d origin, DPoint3d scale, bool trueScale, DMatrix3d matrix, ushort[] attributes, uint ggroup, bool relativeMode, uint baseLevel, int sharedFlag, string cellName, DgnFile dgnFile); 从当前链接的单元库中获取单元定义并在当前Model中放置一个单元,底层调用了C函数:mdlCell_placeCell,返回值为ElementRefP。
MstnMixedAssistant      .AssistantFunctions public static LineStyleParameters CreateLineStyleParameters(); 创建LineStyleParameters实例,由于当前托管程序集中LineStyleParameters类未提供构造函数,故封装此函数创建LineStyleParameters实例。
MstnMixedAssistant      .AssistantFunctions public static bool SolidUtilRayTestFace(SubEntity subEntity, ref DRay3d boresite, out DPoint3d[] intersectPts, out DPoint2d[] intersectParams); 获取射线与面的交点。原C#接口有误。
MstnMixedAssistant      .AssistantFunctions public static BentleyStatus ModifyChamferEdges(ref SolidKernelEntity target, SubEntity[] edgesIn, double[] values1In, double[] values2In, int nEdgesIn, Modify.ChamferMode modeIn, bool propagateSmoothIn); 对实体的边导角。原C# 接口有误,不支持vaules2为不同的值。
MstnMixedAssistant      .AssistantFunctions public static BentleyStatus PropagateAnnotationScale(DgnModelRef dgnModelRef); 通过ModelInfo修改了模型的AnnotationScale后需要调用该函数才能将注释比例应用到所有的注释元素上去。

使用该程序集的步骤为:

1、下载本文附件中的压缩包,解压MstnMixedAssistant.dll到您C# 项目的文件夹下;

2、在您的C# 项目中引用该DLL,并将该引用属性中的"Copy Local(复制到本地)"设置为True。这样编译项目后该DLL会随着您的DLL一起放入目标文件夹下。

3、按照文章开头的表格选择合适的函数(或叫方法)调用即可。