Example #1
0
    //------------------------------------------------------------------------------
    //  NX Startup
    //      This entry point registers the application at NX startup
    //------------------------------------------------------------------------------
    public static int Startup()
    {
        int retValue = 0;

        try
        {
            if (theSession == null)
            {
                theSession = Session.GetSession();
            }
            if (lw == null)
            {
                lw = theSession.ListingWindow;
            }
            theUI.MenuBarManager.RegisterApplication("SAMPLE_CSHARP_APP",
                                                     new NXOpen.MenuBar.MenuBarManager.InitializeMenuApplication(Program.ApplicationInit),
                                                     new NXOpen.MenuBar.MenuBarManager.EnterMenuApplication(Program.ApplicationEnter),
                                                     new NXOpen.MenuBar.MenuBarManager.ExitMenuApplication(Program.ApplicationExit), true, true, true);
            theUI.MenuBarManager.AddMenuAction("SAMPLE_CSHARP_APP__action1", new NXOpen.MenuBar.MenuBarManager.ActionCallback(Program.PrintButtonIdCB));
            theUI.MenuBarManager.AddMenuAction("SAMPLE_CSHARP_APP__action2", new NXOpen.MenuBar.MenuBarManager.ActionCallback(Program.TestCallbackReturnsCB));
            theUI.MenuBarManager.AddMenuAction("SAMPLE_CSHARP_APP__action3", new NXOpen.MenuBar.MenuBarManager.ActionCallback(Program.PrintApplicationIdCB));
            theUI.MenuBarManager.AddMenuAction("SAMPLE_CSHARP_APP__action4", new NXOpen.MenuBar.MenuBarManager.ActionCallback(Program.PrintButtonDataCB));
            theUI.MenuBarManager.AddMenuAction("SAMPLE_CSHARP_APP__action5", new NXOpen.MenuBar.MenuBarManager.ActionCallback(Program.PrintToggleStatusCB));
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
        }
        return(retValue);
    }
Example #2
0
    } //------------------------------------------------------------------------------ /

    // Callback Name: myInfoCB
    // This is a callback method associated with querying information for a UDO.
    // The information is printed in the listing window.
    //------------------------------------------------------------------------------

    public static int myInfoCB(UserDefinedEvent infoEvent)
    {
        try
        {
            ListingWindow
                theLW = theSession.ListingWindow;
            theLW.Open(); theLW.WriteLine(" ");
            theLW.WriteLine("------------------------------------------------------------");
            theLW.WriteLine("Begin Custom Information");
            theLW.WriteLine(" ");
            theLW.WriteLine("UDO Class Name: '" +
                            infoEvent.UserDefinedObject.UserDefinedClass.ClassName + "'");
            theLW.WriteLine("UDO Friendly Name: '" +
                            infoEvent.UserDefinedObject.UserDefinedClass.FriendlyName + "'");
            double[] myUDOdoubles = infoEvent.UserDefinedObject.GetDoubles();
            theLW.WriteLine("myUDOdoubles(0) = " + myUDOdoubles[0]);
            theLW.WriteLine("myUDOdoubles(1) = " + myUDOdoubles[1]);
            theLW.WriteLine("myUDOdoubles(2) = " + myUDOdoubles[2]);
            theLW.WriteLine(" "); theLW.WriteLine("End Custom Information");
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            UI.GetUI().NXMessageBox.Show("Caught exception",
                                         NXMessageBox.DialogType.Error, ex.Message);
        }
        return(0);
    }
Example #3
0
        // Entry point in case of execution of the .dll by NX
        public static void Main(string[] args)
        {
            theSession = Session.GetSession();
            UfSession  = UFSession.GetUFSession();
            lw         = theSession.ListingWindow;
            workPart   = theSession.Parts.Work;

            //HelloWorld(lw);

            //var pts = GetAllPoints(workPart);
            //var pts = AskPoints();
            var pts = AskPointsBlockStyler();

            if (pts.Length > 0)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "CSV-File (*.csv) | *.csv";
                saveFileDialog.Title  = "Export CSV";
                var response = saveFileDialog.ShowDialog();
                if (response == DialogResult.OK && !String.IsNullOrWhiteSpace(saveFileDialog.FileName))
                {
                    WriteCSV(pts, saveFileDialog.FileName);
                }
            }
        }
Example #4
0
 public static void InitializeLogger(Session session)
 {
     if (session == null)
     {
         return;
     }
     _lw = session.ListingWindow;
 }
Example #5
0
        static ClassItem()
        {
            theSession   = Session.GetSession();
            theUi        = UI.GetUI();
            theUFSession = UFSession.GetUFSession();

            lw = theSession.ListingWindow;
            lf = theSession.LogFile;
            mb = theUi.NXMessageBox;
        }
Example #6
0
//        private NxToolsToDbUploaderService _uploaderService;

        public DataService(TechDoc theTechDoc)
        {
            _session = TechDoc.theSession;
            _ui      = TechDoc.theUI;
            _dialog  = theTechDoc;
            _lw      = _session.ListingWindow;

            _data = new NxSession(_session, _ui);
//            _uploaderService = new NxToolsToDbUploaderService(_data);
        }
Example #7
0
    public static void Main(string[] args)
    {
        //Starting UG session
        theSession   = Session.GetSession();
        theUFSession = UFSession.GetUFSession();

        Part workPart = theSession.Parts.Work;

        //open the LOG listening in NX
        ListingWindow lw = theSession.ListingWindow;

        lw.Open();



        //Calling a ReadFile class
        ReadFile readFile = new ReadFile();

        readFile.ReadData();

        lw.WriteLine("Srednica glowicy frezowej: " + readFile.d0);
        lw.WriteLine("Sredni kat zarysu nozy glowicy frezowej: " + readFile.alf2);
        lw.WriteLine("Szerokosc rozstawienia nozy glowicy frezowej: " + readFile.w2);
        lw.WriteLine("Promien zaaokraglenia wierzcholka noza: " + readFile.r02);
        lw.WriteLine("Kat zarysu noza na stronie wkleslej: " + readFile.alf2wk);
        lw.WriteLine("Kat zarysu noza na stronie wypuklej: " + readFile.alf2wp);
        lw.WriteLine("Ustawienie promieniowe glowicy: " + readFile.u);
        lw.WriteLine("ustawienie katowe glowicy: " + readFile.q);
        lw.WriteLine("liczba zebow: " + readFile.z);
        lw.WriteLine("kierunek pochylenia linii zeba: " + readFile.kierunekLinii);
        lw.WriteLine("dlugosc tworzacej stozka podzialowego: " + readFile.re);
        lw.WriteLine("kat stozka podzialowego: " + readFile.del);
        lw.WriteLine("kat stozka glow: " + readFile.delA);
        lw.WriteLine("kat stozka stop: " + readFile.delF);
        lw.WriteLine("szerokosc wienca zebatego: " + readFile.B);
        lw.WriteLine("odleglosc wierzcholka stozka podzialowego od wierzcholkow glow: " + readFile.lwa);
        lw.WriteLine("odleglosc wierzcholka stozka podzialowego od wierzcholkow stop: " + readFile.lwf);
        lw.WriteLine("przesuniecie otoczki do plaszczyzny kolyski po osi otoczki : " + readFile.xp);
        lw.WriteLine("przesuniecie otoczki do plaszczyzny kolyski w kierunku do niej normalnym : " + readFile.xb);
        lw.WriteLine("powiekszenie otoczki : " + readFile.mat2);
        lw.WriteLine("wysokosc glowy zeba : " + readFile.hae);
        lw.WriteLine("wysokosc stopy zeba : " + readFile.hfe);
        lw.WriteLine("jednostkowy kad symulacji oddtaczania : " + readFile.katIteracji);
        lw.WriteLine("liczba krokow symulacji : " + readFile.kroki);
        lw.WriteLine("przelozenie oddataczania : " + readFile.iOdt);
        lw.WriteLine("przesuniecie hipoidalne : " + readFile.A);
        lw.WriteLine("promien zaaokroglenia noza strony wkleslej : " + readFile.r02wk);
        lw.WriteLine("promien zaaokroglenia noza strony wypuklej : " + readFile.r02wp);
        lw.WriteLine("kat skrecenia wrzeciona przedmioto obrabianego : " + readFile.del2);
        lw.WriteLine("obrot glowicy o kat J wynikajacy z TILT-u : " + readFile.tiltJ);
        lw.WriteLine("obrot glowicy o kat I wynikajacy z TILT-u : " + readFile.tiltI);
        lw.WriteLine("strona obrabiana ([1]-wypukla , [0]-wklesla : " + readFile.wyp);
        lw.WriteLine("wspolczynnik modyfikacji oddtaczania : " + readFile.kM);
        lw.WriteLine("wysokosc ostrzy glowicy : " + readFile.wys);
    }
Example #8
0
//------------------------------------------------------------------------------
// initUDO // Checks to see which (if any) of the application's static variables are
// uninitialized, and sets them accordingly.
// Initializes the UDO class and registers all of its callback methods.
//------------------------------------------------------------------------------
    static int initUDO(bool alertUser)
    {
        try
        {
            if (theSession == null)
            {
                theSession = Session.GetSession();
            }
            if (theUI == null)
            {
                theUI = UI.GetUI();
            }
            if (theUFSession == null)
            {
                theUFSession = UFSession.GetUFSession();
            }
            if (myUDOclass == null)
            {
                if (alertUser)
                {
                    ListingWindow theLW = theSession.ListingWindow;
                    theLW.Open();
                    theLW.WriteLine("Registering C# UDO Class");
                }
                // Define your custom UDO class
                myUDOclass = theSession.UserDefinedClassManager.CreateUserDefinedObjectClass
                                 ("Sample_CSharp_UDO", "Sample C# UDO");
                // Setup properties on the custom UDO class
                myUDOclass.AllowQueryClassFromName = UserDefinedClass.AllowQueryClass.On;
                // Register callbacks for the UDO class
                myUDOclass.AddDisplayHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB));
                myUDOclass.AddAttentionPointHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB));
                myUDOclass.AddFitHandler(new UserDefinedClass.DisplayCallback
                                             (Program.myDisplayCB));
                myUDOclass.AddSelectionHandler(new
                                               UserDefinedClass.DisplayCallback(Program.myDisplayCB));
                myUDOclass.AddEditHandler(new UserDefinedClass.GenericCallback(Program.myEditCB));
                myUDOclass.AddInformationHandler(new
                                                 UserDefinedClass.GenericCallback(Program.myInfoCB));
                // Add this class to the list of object types available for selection in NX.
                // If you skip this step you won't be able to select UDO's of this class,
                // even though you registered a selection callback. theUI.SelectionManager.SetSelectionStatusOfUserDefinedClass(myUDOclass, true);
            }
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            UI.GetUI().NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message);
        }
        return(0);
    }
    //------------------------------------------------------------------------------
    //  NX Startup
    //      This entry point activates the application at NX startup
    //
    //  Will work when complete path of the dll is provided to Environment Variable
    //  USER_STARTUP or USER_DEFAULT
    //------------------------------------------------------------------------------
    public static int Startup()
    {
        theSession   = Session.GetSession();
        theUFSession = UFSession.GetUFSession();
        theUI        = UI.GetUI();
        lw           = theSession.ListingWindow;

        theUI.MenuBarManager.RegisterConfigureContextMenuCallback(
            "ConfigureContextMenu.cs",
            "An example of context menu customization demonstrating various functions.",
            new NXOpen.MenuBar.MenuBarManager.ConfigureContextMenu(CustomizeMenu));

        return(0);
    }
Example #10
0
    //------------------------------------------------------------------------------
    //Constructor for NX Styler class
    //------------------------------------------------------------------------------

    public DataService(ToolHolderDialog dialogObject) // конструктор
    {
        checkR();

        _theSession = ToolHolderDialog.theSession;
        _ui         = ToolHolderDialog.theUI;
        _dialog     = dialogObject;
        _lw         = _theSession.ListingWindow;
        //_dialog.SetVisibleNodes(5);
        data        = new thNXSession(_theSession, _ui);
        _xmlService = new XmlService(Data, _dialog);
        if (XmlService._tempoXmlDocPath != null)
        {
            _dialog.SetTempoDlxFile(XmlService._tempoXmlDocPath);
        }
        _dialog.buildDialog();
    }
Example #11
0
    //------------------------------------------------------------------------------
    // Constructor
    //------------------------------------------------------------------------------
    public Program()
    {
        try
        {
            theSession   = Session.GetSession();
            theUfSession = UFSession.GetUFSession();
            lw           = theSession.ListingWindow;
            workPart     = theSession.Parts.BaseWork;


            isDisposeCalled = false;
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            // UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
        }
    }
 //------------------------------------------------------------------------------
 //Constructor for NX Styler class
 //------------------------------------------------------------------------------
 public SheetMetalDetector()
 {
     try
     {
         theSession     = Session.GetSession();
         theUI          = UI.GetUI();
         lw             = theSession.ListingWindow;
         theDlxFileName = "SheetMetalDetector.dlx";
         theDialog      = theUI.CreateDialog(theDlxFileName);
         theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
         theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
         theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         throw ex;
     }
 }
Example #13
0
 //-----------------------------------------------------
 //  Main()
 //    Called manually from File->Execute->NX Open
 //-----------------------------------------------------
 public static void Main()
 {
     //
     // TODO: Add application code here
     //
     if (theSession == null)
     {
         theSession = Session.GetSession();
     }
     if (lw == null)
     {
         lw = theSession.ListingWindow;
     }
     if (registered == 0)
     {
         System.Windows.Forms.MessageBox.Show("Registering CS callbacks");
         Startup();
         registered = 1;
     }
 }
Example #14
0
 //-----------------------------------------------------
 // Called when NX starts up
 // registers the part callbacks with NX
 //-----------------------------------------------------
 public static int Startup()
 {
     if (theSession == null)
     {
         theSession = Session.GetSession();
     }
     if (lw == null)
     {
         lw = theSession.ListingWindow;
     }
     if (registered == 0)
     {
         idPartCreated1     = theSession.Parts.AddPartCreatedHandler(new NXOpen.PartCollection.PartCreatedHandler(MyClass.PartCreated1));
         idPartOpened1      = theSession.Parts.AddPartOpenedHandler(new NXOpen.PartCollection.PartOpenedHandler(MyClass.PartOpened1));
         idPartSaved1       = theSession.Parts.AddPartSavedHandler(new NXOpen.PartCollection.PartSavedHandler(MyClass.PartSaved1));
         idPartSavedAs1     = theSession.Parts.AddPartSavedAsHandler(new NXOpen.PartCollection.PartSavedAsHandler(MyClass.PartSavedAs1));
         idPartClosed1      = theSession.Parts.AddPartClosedHandler(new NXOpen.PartCollection.PartClosedHandler(MyClass.PartClosed1));
         idPartModified1    = theSession.Parts.AddPartModifiedHandler(new NXOpen.PartCollection.PartModifiedHandler(MyClass.PartModified1));
         idPartRenamed1     = theSession.Parts.AddPartRenamedHandler(new NXOpen.PartCollection.PartRenamedHandler(MyClass.PartRenamed1));
         idWorkPartChanged1 = theSession.Parts.AddWorkPartChangedHandler(new NXOpen.PartCollection.WorkPartChangedHandler(MyClass.WorkPartChanged1));
         registered         = 1;
     }
     return(0);
 }
Example #15
0
        public static void Main(string[] args)
        {
            try
            {
                session = Session.GetSession();
                ufs     = UFSession.GetUFSession();
                var ui = UI.GetUI();

                lw = session.ListingWindow;
                //                lw.Open();
                var part = session.Parts.Work;

                //if (!theSession.IsCamSessionInitialized()) theSession.CreateCamSession();

                bool answer;
                ufs.Cam.IsSessionInitialized(out answer);
                if (!answer)
                {
                    ufs.Cam.InitSession();
                }
                var selectedTaggedObject = ui.SelectionManager.GetSelectedTaggedObject(0);
                if (selectedTaggedObject == null)
                {
                    throw new Exception("Не выбрана операция или группа операций!");
                }

                var group = new NxOperationGroup(selectedTaggedObject.Tag, "<выбранный в диалоге станок>");
                var operationDescriptions = @group.GetOperationDescriptions();
                if (operationDescriptions == null)
                {
                    throw new ArgumentNullException("Не удалось получить информацию ни об одном инструменте!");
                }

                int columnNums, rowNums, row = 0;
                var tableNote = GetTableInSheet(part, true);
                ufs.Tabnot.AskNmColumns(tableNote, out columnNums);
                ufs.Tabnot.AskNmRows(tableNote, out rowNums);

                foreach (string[] descr in operationDescriptions)
                {
                    Tag rowTag;
                    ufs.Tabnot.AskNthRow(tableNote, row++, out rowTag);
                    var col = 0;
                    foreach (var s in descr)
                    {
                        Tag colTag, cell;
                        ufs.Tabnot.AskNthColumn(tableNote, col++, out colTag);
                        ufs.Tabnot.AskCellAtRowCol(rowTag, colTag, out cell);
                        ufs.Tabnot.SetCellText(cell, s);
                        if (col > columnNums)
                        {
                            break;
                        }
                    }

                    if (row >= rowNums)
                    {
                        tableNote = GetTableInSheet(part, true);
                        ufs.Tabnot.AskNmColumns(tableNote, out columnNums);
                        ufs.Tabnot.AskNmRows(tableNote, out rowNums);
                        row = 0;
                    }
                }


//                for (var i = 0; i < 16; i++)
//                {
//                    Tag row, col, cell;
//                    ufs.Tabnot.AskNthRow(tableNote, i++, out row);
//                    ufs.Tabnot.AskNthColumn(tableNote, 3, out col);
//                    ufs.Tabnot.AskCellAtRowCol(row, col, out cell);
//                    ufs.Tabnot.SetCellText(cell, "Наименование сложной операции по обработке заготовки.Наименование сложной операции.");
//
//                    ufs.Tabnot.AskNthRow(tableNote, i++, out row);
//                    ufs.Tabnot.AskCellAtRowCol(row, col, out cell);
//                    ufs.Tabnot.SetCellText(cell, "Инструмент 1");
//
//                    ufs.Tabnot.AskNthRow(tableNote, i++, out row);
//                    ufs.Tabnot.AskCellAtRowCol(row, col, out cell);
//                    ufs.Tabnot.SetCellText(cell, "Инструмент 2");
//
//                    ufs.Tabnot.AskNthRow(tableNote, i, out row);
//                    ufs.Tabnot.AskCellAtRowCol(row, col, out cell);
//                    ufs.Tabnot.SetCellText(cell, "Инструмент 3");
//                }


                //                const double baseX = 50.5;
                //                const double baseY = 135.5;
                //                const double deltaY = 8.5;
                //                const double minY = 16.5;
                //
                //                const string filename = @"\\Data2\SAPR\UGS\NX 9.0\MACH\resource\tech_doc_plus\txt\карта_инструментов\фильтр_по_атрибутам.txt";
                //                var attributeFilter = GetAttributeFilter(filename);
                //                var positionX = baseX;
                //                var positionY = baseY;
                //
                //                var enumerator = part.DrawingSheets.GetEnumerator();
                //                enumerator.Reset();
                //                enumerator.MoveNext();
                //
                //                foreach (Tool tool in tools)
                //                {
                //                    var sheet = (DrawingSheet) enumerator.Current;
                //                    if(!sheet.IsActiveForSketching) sheet.Open();
                //
                //                    var attributeCount = 0;
                //                    foreach (var attribute in tool.GetUserAttributes())
                //                    {
                //                        if(attributeFilter.Contains(attribute.Title)) continue;
                //                        attributeCount += 1;
                //                    }
                //
                //                    var description = part.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool).Description;
                //
                //                    var noteBuilder = part.Annotations.CreateDraftingNoteBuilder(null);
                //                    noteBuilder.Text.TextBlock.SetText(new []{description});
                //                    noteBuilder.Origin.Anchor = OriginBuilder.AlignmentPosition.BottomLeft;
                //                    noteBuilder.Origin.Plane.PlaneMethod = PlaneBuilder.PlaneMethodType.XyPlane;
                //                    noteBuilder.Origin.OriginPoint = new Point3d(positionX, positionY, 0.0);
                //                    noteBuilder.Commit();
                //                    noteBuilder.Destroy();
                //
                //                    positionY = positionY - deltaY * (4 + attributeCount);
                //
                //                    if (!(positionY <= minY)) continue;
                //
                //                    positionY = baseY;
                //                    enumerator.MoveNext();
                //                }
            }
            catch (Exception e)
            {
                UI.GetUI().NXMessageBox.Show("Exception", NXMessageBox.DialogType.Error, e.ToString());
            }
        }
Example #16
0
        /**
         *   Callback method that gets invoked when a custom menu
         *   is selected.
         */
        public int CustomPopupMenuInvokedCallback()
        {
            // m_UI.NXMessageBox.Show("MenuCreator", NXOpen.NXMessageBox.DialogType.Information, "CAME HERE");
            //
            // The invoked menu item can be queried. Menu Item can be again queried for
            // ID and name.
            //
            CustomPopupMenuItem menuItem = m_MenuHandler.GetInvokedCommand();

            //
            // The List of object selected in the Tree  can be queried.
            //
            TreeListNode[] treeListNode;
            m_MenuHandler.GetSelectedNodes(out treeListNode);

            if (treeListNode == null || treeListNode.Length == 0)
            {
                // No selected nodes
                return(0);
            }

            string[] uids      = new string[treeListNode.Length];
            string[] nodeTypes = new string[treeListNode.Length];
            for (int i = 0; i < treeListNode.Length; i++)
            {
                //
                // For each Object returned in the List the UID and Object Type can be queried. Need
                // to cast the object to NXOpen::TcModelObjectItem before quering the UID and Type.
                //
                String uid  = ((NXOpen.PDM.PdmNavigatorNode)treeListNode[i]).GetUid();
                String type = ((NXOpen.PDM.PdmNavigatorNode)treeListNode[i]).GetNodeType();
                uids[i]      = uid;
                nodeTypes[i] = type;
            }
            ListingWindow lw = m_Session.ListingWindow;

            lw.Open();
            lw.WriteLine(" ");
            lw.WriteLine("Inside popupMenuInvokedCallBack Callback ");
            lw.WriteLine("COMMAND NAME: ");
            lw.WriteLine(menuItem.GetName());
            lw.WriteLine("SELECTED NODE UIDS: ");
            for (int i = 0; i < uids.Length; i++)
            {
                lw.WriteLine(uids[i]);
            }

            lw.WriteLine("SELECTED NODE TYPES: ");
            for (int i = 0; i < nodeTypes.Length; i++)
            {
                lw.WriteLine(nodeTypes[i]);
            }


            if (menuItem.GetName().Equals("Revise"))
            {
                lw.WriteLine("NEW REVISION ID: ");
                lw.WriteLine("Implement Teamcenter user exits function to show output");
                //
                // Uncomment code below after implementing the user exits method
                //
                // int errorCode = 0;
                // string name = null;
                // m_ugMgr.InvokePdmServer(2, uids[0], out errorCode, out name);
                // lw.WriteLine(name);
            }
            else
            {
                lw.WriteLine("SELECTED NODE NAMES: ");
                lw.WriteLine("Implement Teamcenter user exits function to show output");
                //
                // Uncomment code below after implementing the user exits method
                //

                // for (int i = 0; i < uids.Length; i++)
                // {
                //     int errorCode = 0;
                //     string name = null;
                //     m_ugMgr.InvokePdmServer(1, uids[i], out errorCode, out name);
                //     lw.WriteLine(name);
                // }
            }

            return(0);
        }
Example #17
0
        public thNXSession(Session theSession, UI theUi)
        {
            if (theSession == null)
            {
                throw new Exception("Сессия не запущена!");
            }
            InnerSession = theSession;

            WorkPart = theSession.Parts.Work;
            if (WorkPart == null)
            {
                throw new Exception("Не найден открытая деталь!");
            }

            Ufs = UFSession.GetUFSession();
            if (Ufs == null)
            {
                throw new Exception("GetUFSession!");
            }

            UGII_CAM_LIBRARY_TOOL_DIR = theSession.GetEnvironmentVariableValue("UGII_CAM_LIBRARY_TOOL_DIR");
            if (UGII_CAM_LIBRARY_TOOL_DIR == null)
            {
                throw new Exception("Не удалось получить путь к библиотеке инструмента!");
            }
            UGII_CAM_LIBRARY_TOOL_METRIC_DIR = theSession.GetEnvironmentVariableValue("UGII_CAM_LIBRARY_TOOL_METRIC_DIR");
            if (UGII_CAM_LIBRARY_TOOL_METRIC_DIR == null)
            {
                throw new Exception("Не удалось получить путь к библиотеке инструмента(metric)!");
            }

            initilizeMachineType();

            lw = theSession.ListingWindow;

            lw.Open();
            var startTime = System.Diagnostics.Stopwatch.StartNew();

            lw.WriteLine("Начинаем отсчёт времени выоления метода");

            // initializeHolderfromLibrary();

            //  startTime.Stop();
            //    var result = startTime.Elapsed;


            //   lw.WriteLine(String.Format("Время работы initializeHolderfromLibrary() {0} секунд ", result.Seconds));

            startTime.Reset();
            startTime.Start();

            initHolderFromLibraryByStreamReader();

            startTime.Stop();
            var result = startTime.Elapsed;

            lw.WriteLine(String.Format("Время работы initHolderFromLibraryByStreamReader() {0} секунд ", result.Seconds));


            startTime.Reset();
            startTime.Start();

            initializeTools();

            startTime.Stop();
            result = startTime.Elapsed;

            lw.WriteLine(String.Format("Время работы initializeTools() {0} секунд ", result.Seconds));
        }
Example #18
0
        public void ExportClsfToNX(string pathClsf, string fileName, bool latheMode)
        {
            if (_ufsession != null)
            {
                listWindow = _session.ListingWindow;

                _ufsession.Cam.AskConfigFile(out _configFile);


                // Program view
                _ufsession.Setup.AskSetup(out setupTag);
                _ufsession.Setup.AskProgramRoot(setupTag, out programGroupTag);
                _ufsession.Ncgroup.AskMemberList(programGroupTag, out _countProg, out listProgTag);
                _ufsession.Obj.AskName(programGroupTag, out programName);
                // Geometry view
                _ufsession.Setup.AskGeomRoot(setupTag, out geomGroupTag);
                _ufsession.Ncgroup.AskMemberList(geomGroupTag, out _countGeom, out listGeomTag);
                // Method view
                _ufsession.Setup.AskMthdRoot(setupTag, out methodGroupTag);

                // Create Lathe_user_op

                if (latheMode)
                {
                    _ufsession.Oper.Create("turning", "LATHE_CONTROL", out templateOperTag);
                    _ufsession.Oper.AskNameFromTag(templateOperTag, out operName);
                    _ufsession.Obj.SetName(templateOperTag, "LATHE_USER_OP");
                }


                // DELETE OLD PROGRAM
                try
                {
                    NXObject[] programObj = new NXObject[_countProg];

                    for (int i = 0; i < _countProg; i++)
                    {
                        _ufsession.Obj.AskName(listProgTag[i], out programName);

                        if (programName.Equals(fileName.ToUpper()))
                        {
                            currentProg = listProgTag[i];
                            //	programObj[i] = workPart.CAMSetup.CAMGroupCollection.FindObject(programName) ;
                            _ufsession.Obj.DeleteObject(currentProg);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

//				_ufsession.Cam.UpdateSingleObjectCustomization(programGroupTag) ;
//				_ufsession.Cam.ReinitSession(_configFile) ;
                _ufsession.Disp.Refresh();
                // Generate program
                //	_ufsession.Param.Reinit();
                _ufsession.Clsf.Import(partTag, pathClsf);
                _ufsession.Ncgroup.AskMemberList(programGroupTag, out _countProg, out listProgTag);

                for (int i = 0; i < _countProg; i++)
                {
                    _ufsession.Obj.AskName(listProgTag[i], out programName);

                    if (programName.Equals(fileName.ToUpper()))
                    {
                        currentProg = listProgTag[i];
                        _ufsession.Param.ReplayPath(currentProg);
                    }
                }

                //Refresh Manufacturing Program Navigator

                RefreshOperationNavigator();
            }
            //		UFSession.Param.ReplayPath(Tag.Null) ;
            //	UFSession.Cam.UpdateSingleObjectCustomization(PartTag) ;

            if (_session != null)
            {
            }
        }
Example #19
0
 public static void HelloWorld(ListingWindow lw)
 {
     lw.Open();
     lw.WriteFullline("Hello World!");
 }