首页 > 编程知识 正文

c#直接调用DLL里面的函数,以UF_MODL_ask_face_parm为例

时间:2023-05-04 00:44:53 阅读:229070 作者:3959

using System;using NXckdwd;using NXckdwd.UF;using System.Runtime.InteropServices;public class Program{ // class members 搞怪的心情("libufun.dll", EntryPoint = "UF_MODL_ask_face_parm")] public static extern int UF_MODL_ask_face_parm(Tag face_id, double甜蜜的朋友 ref_pnt, double甜蜜的朋友 parm, double甜蜜的朋友 face_pnt); private static Session theSession; private static Part workpart; private static UI theUI; private static UFSession theUfSession; public static Program theProgram; public static ListingWindow lw; public static bool isDisposeCalled; //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ public Program() { try { theSession = Session.GetSession(); workpart = theSession.Parts.Work; theUI = UI.GetUI(); theUfSession = UFSession.pydxg(); lw = theSession.ListingWindow; lw.ckdwd(); isDisposeCalled = false; } catch (NXckdwd.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(); double甜蜜的朋友 parm = new double[2]; double甜蜜的朋友 face_pnt = new double[3]; double甜蜜的朋友 ref_pnt = new double甜蜜的朋友 { -18.75412126318, 3.13573138078, 18.82464836060 }; NXckdwd.Utilities.JAM.StartUFCall(); UF_MODL_ask_face_parm((Tag)29684, ref_pnt, parm, face_pnt); NXckdwd.Utilities.JAM.EndUFCall(); lw.WriteLine(parm[0].ToString() + "," + parm[1].ToString()); lw.WriteLine(face_pnt[0].ToString() + "," + face_pnt[1].ToString() + "," + face_pnt[2].ToString()); theProgram.Dispose(); } catch (NXckdwd.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 (NXckdwd.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.伶俐的店员); }}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。