ug12.0的草图选择框UI非常的智能,例如选择平面中的自动判断,当我们选择两个面,他会自动推断选择两个面之间的中面,还有其他许多高级智能推断等等.在拉伸,旋转等等命令中的内部草图中都有这个智能草图选择框可以调用,加上旧草图约束算法,工作效率是新版西门子软件的4-5倍以上.
西门子ug软件在18系列以后放弃了机械设计模块,草图框架也改得面目全非,可以说从18系列以后的所有ug版本软件,全部无法用于正常工作.最显著的影响就是草图框架的封装,无论是新建草图,还是拉伸,旋转等内部草图,在选择工作草图平面时的逻辑被改得极其弱智,工作效率直接归0.
虽然,新版本ug软件有种种不堪,但底层的技术毕竟更新了10几年,不能因为他不堪重用就一直使用旧软件.本节内容主要解决的痛点就是:"用插件去模拟ug12.0的草图选择框ui,快速新建出智能判断草图平面的草图,结合旧草图约束设置,实现高版本ug像ug12.0一样提高4-5倍的工作效率"
高版本ug的拉伸,旋转等等命令的内部草图ui基本封装了弱智的草图选择框ui,我们不可能每一个命令都去写一套代码,插件,于是,我们用曲线救国的方法,让我们的插件只模拟新建外部草图,有了草图后我们再用这个草图去完成拉伸或旋转,效果是一样的
一.接009篇内容,将给ui界面加上功能
优化ui类,主要优化是 回调函数apply_cb(),这个函数是ui界面的确认按键按下后会触发这个回调函数,我们在中国回调函数中将选择是平面,矢量,点传给草图,并new一个草图,就实现了ug12.0的高级草图选择框
using NXOpen; using NXOpen.BlockStyler; using NXOpen.CAE; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace UG_Sketsh { public class BlockStyler001 { //class members private static Session theSession = null; private static UI theUI = null; private string theDlxFileName; private NXOpen.BlockStyler.BlockDialog theDialog; private NXOpen.BlockStyler.Label label0;//标签 private NXOpen.BlockStyler.SpecifyPlane plane0;// Block type: 指定平面 private NXOpen.BlockStyler.Separator separator0;// Block type: 分割线 private NXOpen.BlockStyler.Label label01;// 标签 private NXOpen.BlockStyler.SpecifyVector vector0;// Block type: 指定矢量 private NXOpen.BlockStyler.Separator separator01;// Block type: 分割线 private NXOpen.BlockStyler.Label label02;// Block type:标签 private NXOpen.BlockStyler.Separator separator02;// Block type: 分割线 private NXOpen.BlockStyler.SpecifyPoint point0;// Block type: 指定点 private NXOpen.BlockStyler.ScrolledWindow scrolledWindow;// Block type: 滚动窗口 public static readonly int SnapPointTypesOnByDefault_UserDefined = (1 << 0); public static readonly int SnapPointTypesOnByDefault_Inferred = (1 << 1); public static readonly int SnapPointTypesOnByDefault_ScreenPosition = (1 << 2); public static readonly int SnapPointTypesOnByDefault_EndPoint = (1 << 3); public static readonly int SnapPointTypesOnByDefault_MidPoint = (1 << 4); public static readonly int SnapPointTypesOnByDefault_ControlPoint = (1 << 5); public static readonly int SnapPointTypesOnByDefault_Intersection = (1 << 6); public static readonly int SnapPointTypesOnByDefault_ArcCenter = (1 << 7); public static readonly int SnapPointTypesOnByDefault_QuadrantPoint = (1 << 8); public static readonly int SnapPointTypesOnByDefault_ExistingPoint = (1 << 9); public static readonly int SnapPointTypesOnByDefault_PointonCurve = (1 << 10); public static readonly int SnapPointTypesOnByDefault_PointonSurface = (1 << 11); public static readonly int SnapPointTypesOnByDefault_PointConstructor = (1 << 12); public static readonly int SnapPointTypesOnByDefault_TwocurveIntersection = (1 << 13); public static readonly int SnapPointTypesOnByDefault_TangentPoint = (1 << 14); public static readonly int SnapPointTypesOnByDefault_Poles = (1 << 15); public static readonly int SnapPointTypesOnByDefault_BoundedGridPoint = (1 << 16); public static readonly int SnapPointTypesOnByDefault_FacetVertexPoint = (1 << 17); public static readonly int SnapPointTypesOnByDefault_DefiningPoint = (1 << 18); //------------------------------------------------------------------------------ //Bit Option for Property: SnapPointTypesEnabled //------------------------------------------------------------------------------ public static readonly int SnapPointTypesEnabled_UserDefined = (1 << 0); public static readonly int SnapPointTypesEnabled_Inferred = (1 <&l