Ejemplo n.º 1
0
        private void ProcessAssembly(int level, SolidEdgeAssembly.AssemblyDocument assemblyDocument, Dictionary <string, BomItem> bomItems)
        {
            // Increment level (depth).
            level++;

            // Loop through the Occurrences.
            foreach (SolidEdgeAssembly.Occurrence occurrence in assemblyDocument.Occurrences)
            {
                // Filter out certain occurrences.
                if (!occurrence.IncludeInBom)
                {
                    continue;
                }
                if (occurrence.IsPatternItem)
                {
                    continue;
                }
                if (occurrence.OccurrenceDocument == null)
                {
                    continue;
                }

                // Get a reference to the SolidEdgeDocument.
                SolidEdgeFramework.SolidEdgeDocument document = (SolidEdgeFramework.SolidEdgeDocument)occurrence.OccurrenceDocument;

                // Add the BomItem.
                AddBomItem(level, document, bomItems);

                if (occurrence.Subassembly)
                {
                    // Sub Assembly. Recurisve call to drill down.
                    ProcessAssembly(level, (SolidEdgeAssembly.AssemblyDocument)occurrence.OccurrenceDocument, bomItems);
                }
            }
        }
Ejemplo n.º 2
0
        void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if ((_control != null) && (!_control.IsDisposed))
                    {
                        try
                        {
                            _control.Dispose();
                        }
                        catch
                        {
                        }
                    }
                }

                try
                {
                    ReleaseHandle();
                }
                catch
                {
                }

                _control  = null;
                _document = null;
                _disposed = true;
            }
        }
Ejemplo n.º 3
0
    public static void SaveAsJT(SolidEdgeFramework.SolidEdgeDocument document)
    {
        // Note: Some of the parameters are obvious by their name but we need to work on getting better descriptions for some.
        var NewName                         = String.Empty;
        var Include_PreciseGeom             = 0;
        var Prod_Structure_Option           = 1;
        var Export_PMI                      = 0;
        var Export_CoordinateSystem         = 0;
        var Export_3DBodies                 = 0;
        var NumberofLODs                    = 1;
        var JTFileUnit                      = 0;
        var Write_Which_Files               = 1;
        var Use_Simplified_TopAsm           = 0;
        var Use_Simplified_SubAsm           = 0;
        var Use_Simplified_Part             = 0;
        var EnableDefaultOutputPath         = 0;
        var IncludeSEProperties             = 0;
        var Export_VisiblePartsOnly         = 0;
        var Export_VisibleConstructionsOnly = 0;
        var RemoveUnsafeCharacters          = 0;
        var ExportSEPartFileAsSingleJTFile  = 0;

        if (document == null)
        {
            throw new ArgumentNullException("document");
        }

        switch (document.Type)
        {
        case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
        case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
        case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
        case SolidEdgeFramework.DocumentTypeConstants.igWeldmentAssemblyDocument:
        case SolidEdgeFramework.DocumentTypeConstants.igWeldmentDocument:
            NewName = System.IO.Path.ChangeExtension(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), document.Name), ".jt");
            document.SaveAsJT(
                NewName,
                Include_PreciseGeom,
                Prod_Structure_Option,
                Export_PMI,
                Export_CoordinateSystem,
                Export_3DBodies,
                NumberofLODs,
                JTFileUnit,
                Write_Which_Files,
                Use_Simplified_TopAsm,
                Use_Simplified_SubAsm,
                Use_Simplified_Part,
                EnableDefaultOutputPath,
                IncludeSEProperties,
                Export_VisiblePartsOnly,
                Export_VisibleConstructionsOnly,
                RemoveUnsafeCharacters,
                ExportSEPartFileAsSingleJTFile);
            break;

        default:
            throw new System.Exception(String.Format("'{0}' cannot be converted to JT.", document.Type));
        }
    }
Ejemplo n.º 4
0
        public void Add(SolidEdgeFramework.SolidEdgeDocument document, EdgeBarControl control, int imageId)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            var options = (int)SolidEdgeConstants.EdgeBarConstant.DONOT_MAKE_ACTIVE;
            int hWnd    = 0;

            if (_addIn.EdgeBarEx2 != null)
            {
                hWnd = _addIn.EdgeBarEx2.AddPageEx(document, _addIn.NativeResourcesDllPath, imageId, control.ToolTip, options);
            }
            else if (_addIn.EdgeBarEx != null)
            {
                hWnd = _addIn.EdgeBarEx.AddPageEx(document, _addIn.NativeResourcesDllPath, imageId, control.ToolTip, options);
            }

            if (hWnd != 0)
            {
                var edgeBarPage = new EdgeBarPage(hWnd, document, control);
                _edgeBarPages.Add(edgeBarPage);
            }
        }
Ejemplo n.º 5
0
        private void UpdateExternalValue()
        {
            SolidEdgeFramework.Application       application    = null;
            SolidEdgeFramework.SolidEdgeDocument document       = null;
            SolidEdgeFramework.UnitsOfMeasure    unitsOfMeasure = null;

            try
            {
                application    = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
                document       = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                unitsOfMeasure = document.UnitsOfMeasure;
                _externalValue = unitsOfMeasure.FormatUnit((int)_unitType, _internalValue, _precision);
            }
            catch (System.Exception ex)
            {
                _externalValue = ex.Message;
            }
            finally
            {
                if (unitsOfMeasure != null)
                {
                    Marshal.ReleaseComObject(unitsOfMeasure);
                }
                if (document != null)
                {
                    Marshal.ReleaseComObject(document);
                }
                if (application != null)
                {
                    Marshal.ReleaseComObject(application);
                }
            }
        }
Ejemplo n.º 6
0
        static void AddItemsToSelectSet(SolidEdgeFramework.SolidEdgeDocument document)
        {
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.AsmRefPlanes     asmRefPlanes     = null;
            SolidEdgeDraft.DraftDocument       draftDocument    = null;
            SolidEdgeDraft.Sheet             sheet              = null;
            SolidEdgeDraft.DrawingViews      drawingViews       = null;
            SolidEdgePart.PartDocument       partDocument       = null;
            SolidEdgePart.SheetMetalDocument sheetMetalDocument = null;
            SolidEdgePart.EdgebarFeatures    edgeBarFeatures    = null;

            switch (document.Type)
            {
            case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)document;
                asmRefPlanes     = assemblyDocument.AsmRefPlanes;

                for (int i = 1; i <= asmRefPlanes.Count; i++)
                {
                    assemblyDocument.SelectSet.Add(asmRefPlanes.Item(i));
                }
                break;

            case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
                draftDocument = (SolidEdgeDraft.DraftDocument)document;
                sheet         = draftDocument.ActiveSheet;
                drawingViews  = sheet.DrawingViews;

                for (int i = 1; i <= drawingViews.Count; i++)
                {
                    draftDocument.SelectSet.Add(drawingViews.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                partDocument    = (SolidEdgePart.PartDocument)document;
                edgeBarFeatures = partDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }

                break;

            case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document;
                edgeBarFeatures    = sheetMetalDocument.DesignEdgebarFeatures;

                for (int i = 1; i <= edgeBarFeatures.Count; i++)
                {
                    partDocument.SelectSet.Add(edgeBarFeatures.Item(i));
                }
                break;
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application  = null;
            SolidEdgeFramework.Documents         documents    = null;
            SolidEdgeFramework.SolidEdgeDocument document     = null;
            SolidEdgeFramework.PropertySets      propertySets = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to or start Solid Edge.
                application = SolidEdgeUtils.Connect(true);

                // Make sure user can see the GUI.
                application.Visible = true;

                // Bring Solid Edge to the foreground.
                application.Activate();

                // Get a reference to the Documents collection.
                documents = application.Documents;

                // Note: these two will throw exceptions if no document is open.
                //application.ActiveDocument
                //application.ActiveDocumentType;

                if (documents.Count > 0)
                {
                    // Get a reference to the documents collection.
                    document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                }
                else
                {
                    throw new System.Exception("No document open.");
                }

                propertySets = (SolidEdgeFramework.PropertySets)document.Properties;

                ProcessPropertySets(propertySets);

                AddCustomProperties(propertySets);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;
            SolidEdgeFramework.Variables         variables   = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to or start Solid Edge.
                application = SolidEdgeUtils.Connect(true);

                // Make sure user can see the GUI.
                application.Visible = true;

                // Bring Solid Edge to the foreground.
                application.Activate();

                // Get a reference to the Documents collection.
                documents = application.Documents;

                // This check is necessary because application.ActiveDocument will throw an
                // exception if no documents are open...
                if (documents.Count > 0)
                {
                    // Attempt to connect to ActiveDocument.
                    document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                }

                // Make sure we have a document.
                if (document == null)
                {
                    throw new System.Exception("No active document.");
                }

                variables = (SolidEdgeFramework.Variables)document.Variables;

                ProcessVariables(variables);
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application       = null;
            SolidEdgeFramework.SolidEdgeDocument solidEdgeDocument = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to Solid Edge.
                application = SolidEdgeUtils.Connect();

                if (application != null)
                {
                    // Get a reference to the documents collection.
                    solidEdgeDocument = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;

                    Console.WriteLine("Determining document type.");

                    switch (solidEdgeDocument.Type)
                    {
                    case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                    case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                    case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                    case SolidEdgeFramework.DocumentTypeConstants.igWeldmentAssemblyDocument:
                    case SolidEdgeFramework.DocumentTypeConstants.igWeldmentDocument:
                        SaveAsJT(solidEdgeDocument);
                        break;

                    default:
                        Console.WriteLine("'{0}' cannot be converted to JT.", solidEdgeDocument.Type);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Solid Edge is not running.");
                }
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 10
0
    public static void ReportVariables(SolidEdgeFramework.SolidEdgeDocument document)
    {
        SolidEdgeFramework.Variables        variables    = null;
        SolidEdgeFramework.VariableList     variableList = null;
        SolidEdgeFramework.variable         variable     = null;
        SolidEdgeFrameworkSupport.Dimension dimension    = null;

        if (document == null)
        {
            throw new ArgumentNullException("document");
        }

        // Get a reference to the Variables collection.
        variables = (SolidEdgeFramework.Variables)document.Variables;

        // Get a reference to the variablelist.
        variableList = (SolidEdgeFramework.VariableList)variables.Query(
            pFindCriterium: "*",
            NamedBy: SolidEdgeConstants.VariableNameBy.seVariableNameByBoth,
            VarType: SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth);

        // Process variables.
        foreach (var variableListItem in variableList.OfType <object>())
        {
            // Not used in this sample but a good example of how to get the runtime type.
            var variableListItemType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(variableListItem);

            // Use helper class to get the object type.
            var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variableListItem, "Type", (SolidEdgeFramework.ObjectType) 0);

            // Process the specific variable item type.
            switch (objectType)
            {
            case SolidEdgeFramework.ObjectType.igDimension:
                // Get a reference to the dimension.
                dimension = (SolidEdgeFrameworkSupport.Dimension)variableListItem;
                Console.WriteLine("Dimension: '{0}' = '{1}' ({2})", dimension.DisplayName, dimension.Value, objectType);
                break;

            case SolidEdgeFramework.ObjectType.igVariable:
                variable = (SolidEdgeFramework.variable)variableListItem;
                Console.WriteLine("Variable: '{0}' = '{1}' ({2})", variable.DisplayName, variable.Value, objectType);
                break;

            default:
                // Other SolidEdgeConstants.ObjectType's may exist.
                break;
            }
        }
    }
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;
            string[] progIds =
            {
                "SolidEdge.AssemblyDocument",
                "SolidEdge.DraftDocument",
                "SolidEdge.PartDocument",
                "SolidEdge.SheetMetalDocument"
            };
            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to or start Solid Edge.
                application = SolidEdgeUtils.Connect(true);

                // Ensure Solid Edge GUI is visible.
                application.Visible = true;

                // Bring Solid Edge to the foreground.
                application.Activate();

                // Get a reference to the documents collection.
                documents = application.Documents;

                // Create a new document for each ProgId.
                foreach (string progId in progIds)
                {
                    Console.WriteLine("Creating a new '{0}'.  No template specified.", progId);

                    // Create the new document.
                    document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add(progId);
                }
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 12
0
        //public static object SafeGetGetGlobalParameter(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
        //{
        //    object returnVal = null;
        //    object val = null;

        //    using (ComPtr p = ComPtr.FromRCW(application))
        //    {
        //        if (p.IsInvalid == false)
        //        {
        //            object[] args = { globalConstant, new VariantWrapper(null) };
        //            if (MarshalEx.Succeeded(p.TryInvokeMethod("GetGlobalParameter", args, out returnVal)))
        //            {
        //                val = args[1];
        //            }

        //        }
        //    }

        //    return val;
        //}

        //public static bool GetGetGlobalParameterAsBoolean(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
        //{
        //    object val = null;

        //    try
        //    {
        //        application.GetGlobalParameter(globalConstant, ref val);
        //    }
        //    catch
        //    {
        //        GlobalExceptionHandler.HandleException();
        //    }

        //    return val == null ? false : (bool)val;
        //}

        //public static Color GetGlobalParameterAsColor(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
        //{
        //    object val = null;

        //    try
        //    {
        //        application.GetGlobalParameter(globalConstant, ref val);
        //        byte[] rgb = BitConverter.GetBytes((int)val);
        //        return Color.FromArgb(255, rgb[0], rgb[1], rgb[2]);
        //    }
        //    catch
        //    {
        //        GlobalExceptionHandler.HandleException();
        //    }

        //    return Color.Transparent;
        //}

        //public static int GetGlobalParameterAsInteger(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
        //{
        //    object val = null;

        //    try
        //    {
        //        application.GetGlobalParameter(globalConstant, ref val);
        //    }
        //    catch
        //    {
        //        GlobalExceptionHandler.HandleException();
        //    }

        //    return val == null ? -1 : (int)val;
        //}

        //public static string GetGetGlobalParameterAsString(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
        //{
        //    object val = null;

        //    try
        //    {
        //        application.GetGlobalParameter(globalConstant, ref val);
        //    }
        //    catch
        //    {
        //        GlobalExceptionHandler.HandleException();
        //    }

        //    return (string)val;
        //}

        #endregion

        #region SolidEdgeFramework.SolidEdgeDocument Extensions

        public static bool IsTemporary(this SolidEdgeFramework.SolidEdgeDocument document)
        {
            try
            {
                DirectoryInfo fileDirectory = new DirectoryInfo(Path.GetDirectoryName(Path.GetFullPath(document.FullName)));
                DirectoryInfo tempDirectory = new DirectoryInfo(System.IO.Path.GetDirectoryName(System.IO.Path.GetTempPath()));
                return(fileDirectory.FullName.Equals(tempDirectory.FullName, StringComparison.OrdinalIgnoreCase));
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            return(false);
        }
Ejemplo n.º 13
0
        internal EdgeBarPage(IntPtr hWnd, SolidEdgeFramework.SolidEdgeDocument document, EdgeBarControl control)
        {
            _document = document;

            _control = control;
            _control.Initialize(this);

            this.AssignHandle(hWnd);

            // Reparent child control to this hWnd.
            SetParent(_control.Handle, this.Handle);

            // Show the child control and maximize it to fill the entire EdgeBarPage region.
            ShowWindow(_control.Handle, 3 /* SHOWMAXIMIZED */);
        }
        public EdgeBarPage(IntPtr hWnd, SolidEdgeFramework.SolidEdgeDocument document, EdgeBarControl edgeBarControl)
        {
            _document       = document;
            _edgeBarControl = edgeBarControl;

            _edgeBarControl.EdgeBarPage = this;

            // Assign the hWnd to this class.
            AssignHandle(hWnd);

            // Reparent child control to this hWnd.
            NativeMethods.SetParent(_edgeBarControl.Handle, Handle);

            // Show the child control.
            NativeMethods.ShowWindow(_edgeBarControl.Handle, ShowWindowCommands.Maximize);
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.Documents         documents   = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to or start Solid Edge.
                application = SolidEdgeUtils.Connect(true);

                // Ensure Solid Edge GUI is visible.
                application.Visible = true;

                // Bring Solid Edge to the foreground.
                application.Activate();

                // Get a reference to the documents collection.
                documents = application.Documents;

                Console.WriteLine("Creating a new part document.  No template specified.");
                document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument");

                //string template = "your template.par";
                //Console.WriteLine("Creating a new part document.  Template '{0}' specified.", template);
                //document = (SolidEdgeFramework.SolidEdgeDocument)documents.Add("SolidEdge.PartDocument", template);

                //Console.WriteLine("Quitting Solid Edge.");

                // Quit Solid Edge.
                //application.Quit();
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 16
0
        private void ReleaseDocument()
        {
            if (_documentEvents != null)
            {
                _documentEvents.SelectSetChanged -= _documentEvents_SelectSetChanged;
                _documentEvents.BeforeClose -= _documentEvents_BeforeClose;

                Marshal.FinalReleaseComObject(_documentEvents);
                _documentEvents = null;
            }

            if (_document != null)
            {
                Marshal.FinalReleaseComObject(_document);
                _document = null;
            }
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application = null;
            SolidEdgeFramework.SolidEdgeDocument document    = null;
            SolidEdgeFramework.SelectSet         selectSet   = null;

            try
            {
                Console.WriteLine("Registering OleMessageFilter.");

                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                Console.WriteLine("Connecting to Solid Edge.");

                // Connect to or start Solid Edge.
                application = SolidEdgeUtils.Connect();

                if (application != null)
                {
                    document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;

                    selectSet = application.ActiveSelectSet;

                    // Report anything that is already in the SelectSet.
                    ReportSelectSet(selectSet);

                    // Clear the SelectSet.
                    ClearSelectSet(selectSet);

                    // Depending on the document type, will add items to select set.
                    AddItemsToSelectSet(document);
                }
                else
                {
                    Console.WriteLine("Solid Edge is not running.");
                }
            }
            catch (System.Exception ex)
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 18
0
        public void BeforeDocumentClose(object theDocument)
        {
            string eventString        = Resources.BeforeDocumentCloseFormat;
            string environmentName    = String.Empty;
            string environmentCaption = String.Empty;
            string environmentCATID   = String.Empty;

            try
            {
                SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment();
                environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID);
            }
            catch
            {
            }

            try
            {
                eventString = String.Format(eventString, theDocument.SafeInvokeGetProperty("Name", "IUnknown"));
            }
            catch
            {
            }

            _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID));

            try
            {
                SolidEdgeFramework.SolidEdgeDocument document = theDocument as SolidEdgeFramework.SolidEdgeDocument;

                if ((document != null) && (document.IsTemporary() == false))
                {
                    this.BeginInvokeIfRequired(frm =>
                    {
                        frm.HandleAutoResetEvent();
                    });

                    _uiAutoResetEvent.WaitOne(2000);
                    _uiAutoResetEvent.Reset();
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 19
0
        void DoOpenCloseInternal(string fileName)
        {
            //SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents         documents = null;
            SolidEdgeFramework.SolidEdgeDocument document  = null;

            // Register with OLE to handle concurrency issues on the current thread.
            SolidEdgeCommunity.OleMessageFilter.Register();

            try
            {
                // Get reference to application object.
                var application = this.Application;

                // Get reference to documents collection.
                documents = application.Documents;

                // Open the document.
                document = (SolidEdgeFramework.SolidEdgeDocument)documents.Open(fileName);

                // Not sure why but as of ST8, I had to add a Sleep() call to prevent crashing...
                System.Threading.Thread.Sleep(500);

                // Do idle processing.
                application.DoIdle();

                // Close the document.
                document.Close(false);

                //System.Threading.Thread.Sleep(500);

                // Do idle processing.
                application.DoIdle();

                documents.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
        static void SaveAsJT(SolidEdgeFramework.SolidEdgeDocument solidEdgeDocument)
        {
            // Note: Some of the parameters are obvious by their name but we need to work on getting better descriptions for some.
            var NewName                         = Path.ChangeExtension(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), solidEdgeDocument.Name), ".jt");
            var Include_PreciseGeom             = 0;
            var Prod_Structure_Option           = 1;
            var Export_PMI                      = 0;
            var Export_CoordinateSystem         = 0;
            var Export_3DBodies                 = 0;
            var NumberofLODs                    = 1;
            var JTFileUnit                      = 0;
            var Write_Which_Files               = 1;
            var Use_Simplified_TopAsm           = 0;
            var Use_Simplified_SubAsm           = 0;
            var Use_Simplified_Part             = 0;
            var EnableDefaultOutputPath         = 0;
            var IncludeSEProperties             = 0;
            var Export_VisiblePartsOnly         = 0;
            var Export_VisibleConstructionsOnly = 0;
            var RemoveUnsafeCharacters          = 0;
            var ExportSEPartFileAsSingleJTFile  = 0;

            Console.WriteLine("Saving '{0}'", NewName);

            solidEdgeDocument.SaveAsJT(
                NewName,
                Include_PreciseGeom,
                Prod_Structure_Option,
                Export_PMI,
                Export_CoordinateSystem,
                Export_3DBodies,
                NumberofLODs,
                JTFileUnit,
                Write_Which_Files,
                Use_Simplified_TopAsm,
                Use_Simplified_SubAsm,
                Use_Simplified_Part,
                EnableDefaultOutputPath,
                IncludeSEProperties,
                Export_VisiblePartsOnly,
                Export_VisibleConstructionsOnly,
                RemoveUnsafeCharacters,
                ExportSEPartFileAsSingleJTFile);
        }
Ejemplo n.º 21
0
        private void UpdateTreeView()
        {
            if (_application == null)
            {
                try
                {
                    _application = SolidEdgeUtils.Connect();
                }
                catch
                {
                    MessageBox.Show("Solid Edge is not running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (_document == null)
            {
                try
                {
                    _document = (SolidEdgeFramework.SolidEdgeDocument)_application.ActiveDocument;
                }
                catch
                {
                }
            }

            if (_document != null)
            {
                try
                {
                    _documentEvents = (SolidEdgeFramework.ISEDocumentEvents_Event)_document.DocumentEvents;
                    _documentEvents.BeforeClose += _documentEvents_BeforeClose;
                    _documentEvents.SelectSetChanged += _documentEvents_SelectSetChanged;

                    UpdateTreeView(_application.ActiveSelectSet);
                }
                catch (System.Exception ex)
                {
                    _document = null;
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 22
0
        private void AddBomItem(int level, SolidEdgeFramework.SolidEdgeDocument document, Dictionary <string, BomItem> bomItems)
        {
            BomItem bomItem = new BomItem(document.FullName);

            SolidEdgeFramework.SummaryInfo summaryInfo = null;

            if (!bomItems.ContainsKey(document.FullName))
            {
                summaryInfo            = (SolidEdgeFramework.SummaryInfo)document.SummaryInfo;
                bomItem.Level          = level;
                bomItem.DocumentNumber = summaryInfo.DocumentNumber;
                bomItem.Title          = summaryInfo.Title;
                bomItem.Revision       = summaryInfo.RevisionNumber;
                bomItem.IsSubassembly  = document.Type == SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument;
                bomItems.Add(bomItem.FullName, bomItem);
            }
            else
            {
                bomItems[bomItem.FullName].Quantity++;
            }
        }
        static void ProcessDrawingViewModelLink(SolidEdgeDraft.DrawingView drawingView)
        {
            Console.WriteLine("--> {0}", System.Reflection.MethodBase.GetCurrentMethod().ToString());

            SolidEdgeDraft.ModelLink             modelLink         = null;
            SolidEdgeFramework.SolidEdgeDocument solidEdgeDocument = null;

            try
            {
                // drawingView.ModelLink will throw exception if link is not found.
                modelLink = drawingView.ModelLink as SolidEdgeDraft.ModelLink;
                Console.WriteLine("\tModelLink.FileName: {0}", modelLink.FileName);

                solidEdgeDocument = modelLink.ModelDocument as SolidEdgeFramework.SolidEdgeDocument;

                if (solidEdgeDocument != null)
                {
                    Console.WriteLine("\tModelDocument.Type: {0}", solidEdgeDocument.Type);
                    switch (solidEdgeDocument.Type)
                    {
                    case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
                        break;

                    case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                        break;

                    case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                        break;
                    }
                }
            }
            catch
            {
                Console.WriteLine("\tModelLink.FileName: Not found");
            }

            Console.WriteLine("<-- {0}", System.Reflection.MethodBase.GetCurrentMethod().ToString());
        }
Ejemplo n.º 24
0
        ///// <summary>
        ///// Called during SolidEdgeFramework.ISEAddInEdgeBarEventsEx.AddPage() event.
        ///// </summary>
        ///// <param name="controller"></param>
        ///// <remarks>
        ///// Use this override for creating EdgeBar pages that are not document specific.
        ///// </remarks>
        //public virtual void OnCreateEdgeBarPage(EdgeBarController controller)
        //{
        //}

        /// <summary>
        /// Called during SolidEdgeFramework.ISEAddInEdgeBarEventsEx.AddPage() event.
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="document"></param>
        /// <remarks>
        /// Use this override for creating EdgeBar pages that are document specific.
        /// </remarks>
        public virtual void OnCreateEdgeBarPage(EdgeBarController controller, SolidEdgeFramework.SolidEdgeDocument document)
        {
        }
Ejemplo n.º 25
0
 internal EdgeBarPage(int hWnd, SolidEdgeFramework.SolidEdgeDocument document, EdgeBarControl control)
     : this(new IntPtr(hWnd), document, control)
 {
 }
 /// <summary>
 /// Returns the summary information property set for the referenced document.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SolidEdgeFramework.SummaryInfo GetSummaryInfo(this SolidEdgeFramework.SolidEdgeDocument document)
 {
     return(document.SummaryInfo as SolidEdgeFramework.SummaryInfo);
 }
Ejemplo n.º 27
0
 public override void OnCreateEdgeBarPage(EdgeBarController controller, SolidEdgeFramework.SolidEdgeDocument document)
 {
     controller.Add <MyEdgeBarControl>(document, 1);
     //controller.Add<MyEdgeBarControl2>(document, 1);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Called when Solid Edge raises the SolidEdgeFramework.ISEAddInEdgeBarEvents[Ex].AddPage() event.
        /// </summary>
        public override void OnCreateEdgeBarPage(SolidEdgeCommunity.AddIn.EdgeBarController controller, SolidEdgeFramework.SolidEdgeDocument document)
        {
            // Note: Confirmed with Solid Edge development, OnCreateEdgeBarPage does not get called when Solid Edge is first open and the first document is open.
            // i.e. Under the hood, SolidEdgeFramework.ISEAddInEdgeBarEvents[Ex].AddPage() is not getting called.
            // As an alternative, you can call DemoAddIn.Instance.EdgeBarController.Add() in some other event if you need.

            // Get the document type of the passed in document.
            var documentType = document.Type;
            var imageId      = 1;

            // Depending on the document type, you may have different edgebar controls.
            switch (documentType)
            {
            case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument:
            case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
            case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
            case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                controller.Add <MyEdgeBarControl>(document, imageId);
                break;
            }
        }
 /// <summary>
 /// Returns a collection of variables for the referenced document.
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SolidEdgeFramework.Variables GetVariables(this SolidEdgeFramework.SolidEdgeDocument document)
 {
     return(document.Variables as SolidEdgeFramework.Variables);
 }
Ejemplo n.º 30
0
        public EdgeBarPage AddWpfEdgeBarPage <TControl>(EdgeBarPageConfiguration config, SolidEdgeFramework.SolidEdgeDocument document) where TControl : System.Windows.Controls.Page, new()
        {
            uint WS_VISIBLE  = 0x10000000;
            uint WS_CHILD    = 0x40000000;
            uint WS_MAXIMIZE = 0x01000000;

            TControl control = Activator.CreateInstance <TControl>();

            var edgeBarPage = AddEdgeBarPage(
                config: config,
                controlHandle: IntPtr.Zero,
                document: document);

            var hwndSource = new System.Windows.Interop.HwndSource(new System.Windows.Interop.HwndSourceParameters
            {
                PositionX    = 0,
                PositionY    = 0,
                Height       = 0,
                Width        = 0,
                ParentWindow = edgeBarPage.Handle,
                WindowStyle  = (int)(WS_VISIBLE | WS_CHILD | WS_MAXIMIZE)
            })
            {
                RootVisual = control
            };

            edgeBarPage.ChildObject = hwndSource;

            return(edgeBarPage);
        }