Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using NXOpen;
- using NXOpen.UF;
- 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;
- //------------------------------------------------------------------------------
- // Constructor
- //------------------------------------------------------------------------------
- public Program()
- {
- try
- {
- theSession = Session.GetSession();
- theUI = UI.GetUI();
- theUfSession = UFSession.GetUFSession();
- 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();
- //TODO: Add your application code here
- Tag UFPart1;
- string modelName = "test";
- int meterSystem = 1;
- theUfSession.Part.New(modelName, meterSystem, out UFPart1);
- //Создание массива точек для замкнутого объекта
- double[,] pointMassive = new double[8, 3]
- {
- {20, 0, 0 },
- {20, 48, 0 },
- {36, 48, 0 },
- {36, 37, 0 },
- {26, 37, 0 },
- {26, 11, 0 },
- {36, 11, 0 },
- {36, 0, 0 }
- };
- UFCurve.Line[] line = new UFCurve.Line[pointMassive.Length];
- for (int i = 0; i < (pointMassive.Length); i++)
- {
- line[i] = new UFCurve.Line();
- }
- for (int i = 0; i < (pointMassive.Length - 1); i++)
- {
- line[i].start_point = new double[3];
- line[i].end_point = new double[3];
- for (int j = 0; j < 3; j++)
- {
- line[i].start_point[j] = pointMassive[i, j];
- line[i].end_point[j] = pointMassive[i + 1, j];
- }
- }
- for (int j=0; j<3; j++)
- {
- line[pointMassive.Length - 1].start_point[j] = pointMassive[pointMassive.Length - 1, j];
- line[pointMassive.Length - 1].end_point[j] = pointMassive[0, j];
- }
- Tag[] array2D = new Tag[pointMassive.Length];
- for (int i=0; i<(pointMassive.Length); i++)
- {
- theUfSession.Curve.CreateLine(ref line[i], out array2D[i]);
- }
- double[] refPoint = { 0.00, 0.00, 0.00 };
- double[] dirPoint = { 1.00, 0.00, 0.00 };
- string[] limit = { "0", "360" };
- Tag[] features;
- theUfSession.Modl.CreateRevolved(array2D, limit, refPoint, dirPoint, FeatureSigns.Nullsign, out features);
- theUfSession.Part.Save();
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment