点击查看详细介绍

NXOpen C# 创建曲线

hiboboloo1988 2年前 8402 6

UG NX 二次开发(C、C#、WPF)技术交流群:641226372      UG二次开发(C、C#、WPF)


using System;
using System.IO;
using NXOpen;
using NXOpen.UF;
namespace NetExample
{

 /// <summary>

 /// Summary description for EX_Curve_CreateArc.

 /// </summary>

 public class EX_Curve_CreateArc

 {
        private static FileStream fs; 
        private static StreamWriter w;
        private static UFSession theUfSession;
        private static Session theSession;
        public int Execute()
        {
            Tag UFPart;
            string part_name = "EX_Curve_CreateArc";
            int units =2; 
            string name;
          
            theUfSession.Part.New(part_name, units, out UFPart);
            theUfSession.Part.AskPartName(UFPart, out name);
            w.WriteLine("Loaded: " + name);
            
            Tag arc, wcs;
            UFCurve.Arc arc_coords = new UFCurve.Arc();

●●●请先 登陆注册 后查看●●●

        }
        public static void Main(string[] args)
        {
            theSession=Session.GetSession();
            theUfSession= UFSession.GetUFSession();
            fs = new FileStream("EX_Curve_CreateArc.log", FileMode.Create, FileAccess.Write);
            w = new StreamWriter(fs); // create a stream writer 
            w.Write("Log Entry : \r\n");
            w.WriteLine("--Log entry goes here--"); 
            w.Flush(); // update underlying file
   if ( File.Exists("EX_Curve_CreateArc.prt") ) 
   {
    w.WriteLine("Remove EX_Curve_CreateArc.prt file from <Project Folder>\\bin\\Debug !!");
    w.WriteLine("EX_Curve_CreateArc.prt already exists. !!");
    w.Close();
    return;
   }
            try
            {
                EX_Curve_CreateArc curveTest1 = new EX_Curve_CreateArc();
                if (curveTest1.Execute()==0)
                {
                    w.WriteLine("Successful");
                }
                else
                {
                    w.WriteLine("Failed");
                }
            }
            catch(NXException e)
            {   
                w.WriteLine("Exception is: {0}", e.Message);
            }
            w.WriteLine("End of Log File");
            w.Close();
        }
  public static int GetUnloadOption(string dummy) 
  {
   return UFConstants.UF_UNLOAD_IMMEDIATELY;
  }

 }
}


1

最新回复 (6)
  • hiboboloo1988 2年前
    1

    谢谢........... 谢谢

  • 桃花一笑 4月前
    2

    好资料,慢慢看,感谢分享

  • 雪夜流萤 4月前
    3

    学习了。谢谢。非常感谢。

  • wangzhen 3月前
    4

    谢谢,学习一下,感谢感谢

  • 序曲 2月前
    5

    学习学习学习学习

  • yy306683560 2月前
    6

    感谢楼主分享,多谢楼主!

请登录后发表新帖