找传奇、传世资源到传世资源站!

UG二次开发中nxopen测量距离

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

在UG二次开发中用NXOPEN测量距离的例子很难找到,在上传一个供大家砸砖
from clipboard
using System;using NXOpen;using NXOpen.UF;using NXOpen.Utilities;public class Program{ // class members private static Session theSession; private static UI theUI; private static UFSession theUfSession; public static Program theProgram; public static bool isDisposeCalled; public static double ada,adb; static TaggedObject body1, body2; static Point3d point1, point2; public static Part workpart = null; public static ListingWindow lw = null; bool dir; //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ public Program() { try { theSession = Session.GetSession(); theUI = UI.GetUI(); theUfSession = UFSession.GetUFSession(); lw = theSession.ListingWindow; workpart = theSession.Parts.Work; isDisposeCalled = false; } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- // UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message); } } //------------------------------------------------------------------------------ // Explicit Activation // This entry point is used to activate the application explicitly //------------------------------------------------------------------------------ public static int Main(string[] args) { int retValue = 0; try { theProgram = new Program(); int ii, jj; ii = 2; jj = 3; string[] sta = { "保持当前Z轴", "Z轴反向", "3" }; jj=theUfSession.Ui.DisplayMenu("确认坐标系", 1, sta, 2); lw.Open();lw.WriteLine(jj.ToString()); int face_1 = 1;double re; int face_2 = 5; int c;Point3d pt1, pt2; fun k = new fun(); k.theSession = theSession;k.workPart = workpart;k.theUI = theUI;k.theUfSession = theUfSession; theUI.SelectionManager.SelectTaggedObject("选择实体", "选择", Selection.SelectionScope.WorkPart, false, false, out body1, out point1); theUI.SelectionManager.SelectTaggedObject("选择实体", "选择", Selection.SelectionScope.WorkPart, false, false, out body2, out point2); // Measurement.GetMinimumDistance((NXObject)body1, (NXObject)body2, out point1, out point2, out ccs); re=k.measu_dist(body1, body2, out c, out pt1, out pt2);lw.Open(); lw.WriteLine(re.ToString()); theProgram.Dispose(); } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- } return retValue; } //------------------------------------------------------------------------------ // Following method disposes all the class members //------------------------------------------------------------------------------ public void Dispose() { try { if (isDisposeCalled == false) { //TODO: Add your application code here } isDisposeCalled = true; } catch (NXOpen.NXException ex) { // ---- Enter your exception handling code here ----- } } public static int GetUnloadOption(string arg) { //Unloads the image explicitly, via an unload dialog //return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly); //Unloads the image immediately after execution within NX return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately); //Unloads the image when the NX session terminates // return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination); }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复