Exemple #1
0
        static void ReportCustomProperties(SolidEdgeFramework.PropertySets propertySets)
        {
            var properties = (SolidEdgeFramework.Properties)propertySets.Item("Custom");

            foreach (var property in properties.OfType<SolidEdgeFramework.Property>())
            {
                System.Runtime.InteropServices.VarEnum nativePropertyType = System.Runtime.InteropServices.VarEnum.VT_EMPTY;
                Type runtimePropertyType = null;

                object value = null;

                nativePropertyType = (System.Runtime.InteropServices.VarEnum)property.Type;

                // Accessing Value property may throw an exception...
                try
                {
                    value = property.get_Value();
                }
                catch (System.Exception ex)
                {
                    value = ex.Message;
                }

                if (value != null)
                {
                    runtimePropertyType = value.GetType();
                }

                Console.WriteLine("\t{0} = '{1}' ({2} | {3}).", property.Name, value, nativePropertyType, runtimePropertyType);
            }

            Console.WriteLine();
        }
Exemple #2
0
        /// <summary>
        /// Called when the addin is first loaded by Solid Edge.
        /// </summary>
        public override void OnConnection(SolidEdgeFramework.Application application, SolidEdgeFramework.SeConnectMode ConnectMode, SolidEdgeFramework.AddIn AddInInstance)
        {
            // If you makes changes to your ribbon, be sure to increment the GuiVersion or your ribbon
            // will not initialize properly.
            AddInEx.GuiVersion = 1;

            // Create an instance of the default connection point controller. It helps manage connections to COM events.
            _connectionPointController = new SolidEdgeCommunity.ConnectionPointController(this);

            // Uncomment the following line to attach to the Solid Edge Application Events.
            _connectionPointController.AdviseSink<SolidEdgeFramework.ISEApplicationEvents>(this.Application);

            // Not necessary unless you absolutely need to see low level windows messages.
            // Uncomment the following line to attach to the Solid Edge Application Window Events.
            //_connectionPointController.AdviseSink<SolidEdgeFramework.ISEApplicationWindowEvents>(this.Application);

            // Uncomment the following line to attach to the Solid Edge Feature Library Events.
            _connectionPointController.AdviseSink<SolidEdgeFramework.ISEFeatureLibraryEvents>(this.Application);

            // Uncomment the following line to attach to the Solid Edge File UI Events.
            //_connectionPointController.AdviseSink<SolidEdgeFramework.ISEFileUIEvents>(this.Application);

            // Uncomment the following line to attach to the Solid Edge File New UI Events.
            //_connectionPointController.AdviseSink<SolidEdgeFramework.ISENewFileUIEvents>(this.Application);

            // Uncomment the following line to attach to the Solid Edge EC Events.
            //_connectionPointController.AdviseSink<SolidEdgeFramework.ISEECEvents>(this.Application);

            // Uncomment the following line to attach to the Solid Edge Shortcut Menu Events.
            //_connectionPointController.AdviseSink<SolidEdgeFramework.ISEShortCutMenuEvents>(this.Application);
        }
    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));
        }
    }
Exemple #4
0
        static void AddCustomProperties(SolidEdgeFramework.PropertySets propertySets)
        {
            var properties = (SolidEdgeFramework.Properties)propertySets.Item("Custom");
            var propertyValues = new object[] { "My text", int.MaxValue, 1.23, true, DateTime.Now };

            foreach (var propertyValue in propertyValues)
            {
                var propertyType = propertyValue.GetType();
                var propertyName = String.Format("My {0}", propertyType);
                var property = properties.Add(propertyName, propertyValue);

                Console.WriteLine("Added {0} - {1}.", property.Name, propertyValue);
            }
        }
Exemple #5
0
        private void CreateSeparateAppDomainAndExecuteIsolatedTask(SolidEdgeFramework.Application application)
        {
            AppDomain interopDomain = null;

            try
            {
                var thread = new System.Threading.Thread(() =>
                {
                    // Create a custom AppDomain to do COM Interop.
                    interopDomain = AppDomain.CreateDomain("Interop Domain");

                    Type proxyType = typeof(InteropProxy);

                    // Create a new instance of InteropProxy in the isolated application domain.
                    InteropProxy interopProxy = interopDomain.CreateInstanceAndUnwrap(
                        proxyType.Assembly.FullName,
                        proxyType.FullName) as InteropProxy;

                    try
                    {
                        interopProxy.DoIsolatedTask(application);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                });

                // Important! Set thread apartment state to STA.
                thread.SetApartmentState(System.Threading.ApartmentState.STA);

                // Start the thread.
                thread.Start();

                // Wait for the thead to finish.
                thread.Join();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (interopDomain != null)
                {
                    // Unload the Interop AppDomain. This will automatically free up any COM references.
                    AppDomain.Unload(interopDomain);
                }
            }
        }
Exemple #6
0
        static void DeleteCustomProperties(SolidEdgeFramework.PropertySets propertySets)
        {
            var properties = (SolidEdgeFramework.Properties)propertySets.Item("Custom");

            // Query for custom properties that start with "My".
            var query = properties.OfType<SolidEdgeFramework.Property>().Where(x => x.Name.StartsWith("My"));

            // Force ToArray() so that Delete() doesn't interfere with the enumeration.
            foreach (var property in query.ToArray())
            {
                var propertyName = property.Name;
                property.Delete();
                Console.WriteLine("Deleted {0}.", propertyName);
            }
        }
Exemple #7
0
        public static void SaveAsImageUsingBitBlt(SolidEdgeFramework.Window window)
        {
            System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog();
            dialog.FileName = System.IO.Path.ChangeExtension(window.Caption, ".bmp");
            dialog.Filter = "BMP (.bmp)|*.bmp|GIF (.gif)|*.gif|JPEG (.jpeg)|*.jpeg|PNG (.png)|*.png|TIFF (.tiff)|*.tiff|WMF Image (.wmf)|*.wmf";
            dialog.FilterIndex = 1;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                IntPtr handle = new IntPtr(window.DrawHwnd);

                // Capture the window to an Image object.
                using (System.Drawing.Image image = Capture(handle))
                {
                    ImageFormat imageFormat = default(ImageFormat);

                    // Determine the selected image format.
                    // The index is 1-based.
                    switch (dialog.FilterIndex)
                    {
                        case 1:
                            imageFormat = ImageFormat.Bmp;
                            break;
                        case 2:
                            imageFormat = ImageFormat.Gif;
                            break;
                        case 3:
                            imageFormat = ImageFormat.Jpeg;
                            break;
                        case 4:
                            imageFormat = ImageFormat.Png;
                            break;
                        case 5:
                            imageFormat = ImageFormat.Tiff;
                            break;
                        case 6:
                            imageFormat = ImageFormat.Wmf;
                            break;
                    }

                    Console.WriteLine("Saving {0}.", dialog.FileName);

                    image.Save(dialog.FileName, imageFormat);
                }
            }
        }
    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;
            }
        }
    }
Exemple #9
0
        static void CaptureApplicationGlobalConstants(SolidEdgeFramework.Application application, Dictionary<SolidEdgeFramework.ApplicationGlobalConstants, object> dictionary)
        {
            // Get list of SolidEdgeFramework.ApplicationGlobalConstants names and values.
            var enumConstants = Enum.GetNames(typeof(SolidEdgeFramework.ApplicationGlobalConstants)).ToArray();
            var enumValues = Enum.GetValues(typeof(SolidEdgeFramework.ApplicationGlobalConstants)).Cast<SolidEdgeFramework.ApplicationGlobalConstants>().ToArray();

            // Populate the dictionary.
            for (int i = 0; i < enumValues.Length; i++)
            {
                var enumConstant = enumConstants[i];
                var enumValue = enumValues[i];
                object value = null;

                if (enumValue.Equals(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalOpenAsReadOnly3DFile)) continue;

                // We can safely ignore seApplicationGlobalSystemInfo. It's just noise for our purpose.
                if (enumConstant.Equals(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalSystemInfo)) continue;

                application.GetGlobalParameter(enumValue, ref value);
                dictionary.Add(enumValue, value);
            }
        }
Exemple #10
0
    public static void SaveAsImage(SolidEdgeFramework.Window window)
    {
        string[] extensions = { ".jpg", ".bmp", ".tif" };

        SolidEdgeFramework.View view = null;
        Guid guid = Guid.NewGuid();
        string folder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

        if (window == null) throw new ArgumentNullException("window");

        // Get a reference to the 3D view.
        view = window.View;

        // Save each extension.
        foreach (string extension in extensions)
        {
            // File saved to desktop.
            string filename = Path.ChangeExtension(guid.ToString(), extension);
            filename = Path.Combine(folder, filename);

            double resolution = 1.0;  // DPI - Larger values have better quality but also lead to larger file.
            int colorDepth = 24;
            int width = window.UsableWidth;
            int height = window.UsableHeight;

            // You can specify .bmp (Windows Bitmap), .tif (TIFF), or .jpg (JPEG).
            view.SaveAsImage(
                Filename: filename,
                Width: width,
                Height: height,
                AltViewStyle: null,
                Resolution: resolution,
                ColorDepth: colorDepth,
                ImageQuality: SolidEdgeFramework.SeImageQualityType.seImageQualityHigh,
                Invert: false);

            Console.WriteLine("Saved '{0}'.", filename);
        }
    }
Exemple #11
0
        void DisableAddins(SolidEdgeFramework.Application application)
        {
            SolidEdgeFramework.AddIns addins = null;
            SolidEdgeFramework.AddIn addin = null;

            addins = application.AddIns;

            for (int i = 1; i <= addins.Count; i++)
            {
                addin = addins.Item(i);
                addin.Connect = false;
            }
        }
Exemple #12
0
        public void OnNewFileUI(SolidEdgeFramework.DocumentTypeConstants DocumentType, out string Filename, out string AppendToTitle)
        {
            bool overrideDefaultBehavior = false;

            if (overrideDefaultBehavior)
            {
                // If you get here, you override the default Solid Edge UI.
                Filename = null;
                AppendToTitle = null;
            }
            else
            {
                // Visual Studio will stop on this exception in debug mode. Simply F5 through it when testing.
                throw new NotImplementedException();
            }
        }
Exemple #13
0
        static void ReportRelation(SolidEdgeAssembly.SegmentAngularRelation3d relation3d, SolidEdgeFramework.ObjectType objectType)
        {
            Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType);

            try
            {
                Console.WriteLine("AngleCounterclockwise: {0}", relation3d.AngleCounterclockwise);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("AngleToPositiveDirection: {0}", relation3d.AngleToPositiveDirection);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("Status: {0}", relation3d.Status);
            }
            catch
            {
            }

            Console.WriteLine();
        }
Exemple #14
0
        /// <summary>
        /// Occurs before the user interface is created for the file saved as image by Solid Edge.
        /// </summary>
        public void OnFileSaveAsImageUI(out string Filename, out string AppendToTitle, ref int Width, ref int Height, ref SolidEdgeFramework.SeImageQualityType ImageQuality)
        {
            bool overrideDefaultBehavior = false;

            if (overrideDefaultBehavior)
            {
                // If you get here, you override the default Solid Edge UI.
                Filename = null;
                AppendToTitle = null;
                Width = 100;
                Height = 100;
                ImageQuality = SolidEdgeFramework.SeImageQualityType.seImageQualityHigh;
            }
            else
            {
                // Visual Studio will stop on this exception in debug mode. Simply F5 through it when testing.
                throw new NotImplementedException();
            }
        }
Exemple #15
0
 void ISEAssemblyRecomputeEvents_BeforeDelete(object theDocument, object Object, SolidEdgeFramework.ObjectType Type)
 {
     LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, Type });
 }
Exemple #16
0
 void ISEAssemblyRecomputeEvents_AfterModify(object theDocument, object Object, SolidEdgeFramework.ObjectType Type, SolidEdgeFramework.seAssemblyEventConstants ModifyType)
 {
     LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, ModifyType });
 }
Exemple #17
0
 void ISEAssemblyChangeEvents_BeforeChange(object theDocument, object Object, SolidEdgeFramework.ObjectType Type, SolidEdgeFramework.seAssemblyChangeEventsConstants ChangeType)
 {
     LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, ChangeType });
 }
Exemple #18
0
 /// <summary>
 /// Fires event before CPD Display.
 /// </summary>
 public void SEEC_BeforeCPDDisplay(object pCPDInitializer, SolidEdgeFramework.eCPDMode eCPDMode)
 {
 }
Exemple #19
0
        /// <summary>
        /// Notification of short-cut menu creation.
        /// </summary>
        public void BuildMenu(string EnvCatID, SolidEdgeFramework.ShortCutMenuContextConstants Context, object pGraphicDispatch, out Array MenuStrings, out Array CommandIDs)
        {
            MenuStrings = Array.CreateInstance(typeof(string), 0);
            CommandIDs = Array.CreateInstance(typeof(int), 0);

            switch (Context)
            {
                case SolidEdgeFramework.ShortCutMenuContextConstants.seShortCutForFeaturePathFinder:
                    break;
                case SolidEdgeFramework.ShortCutMenuContextConstants.seShortCutForFeaturePathFinderDocument:
                    break;
                case SolidEdgeFramework.ShortCutMenuContextConstants.seShortCutForGraphicLocate:
                    break;
                case SolidEdgeFramework.ShortCutMenuContextConstants.seShortCutForView:
                    break;
            }
        }
Exemple #20
0
        private void ConnectDocumentEvents(SolidEdgeFramework.SolidEdgeDocument document)
        {
            _documentEvents = (SolidEdgeFramework.ISEDocumentEvents_Event)document.DocumentEvents;

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

                    _assemblyChangeEvents = (SolidEdgeFramework.ISEAssemblyChangeEvents_Event)assemblyDocument.AssemblyChangeEvents;
                    _assemblyFamilyEvents = (SolidEdgeFramework.ISEAssemblyFamilyEvents_Event)assemblyDocument.AssemblyFamilyEvents;
                    _assemblyRecomputeEvents = (SolidEdgeFramework.ISEAssemblyRecomputeEvents_Event)assemblyDocument.AssemblyRecomputeEvents;

                    break;
                case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument:
                    var draftDocument = (SolidEdgeDraft.DraftDocument)document;

                    _blockTableEvents = (SolidEdgeFramework.ISEBlockTableEvents_Event)draftDocument.BlockTableEvents;
                    _connectorTableEvents = (SolidEdgeFramework.ISEConnectorTableEvents_Event)draftDocument.ConnectorTableEvents;
                    _draftBendTableEvents = (SolidEdgeFramework.ISEDraftBendTableEvents_Event)draftDocument.DraftBendTableEvents;
                    _drawingViewEvents = (SolidEdgeFramework.ISEDrawingViewEvents_Event)draftDocument.DrawingViewEvents;
                    _partsListEvents = (SolidEdgeFramework.ISEPartsListEvents_Event)draftDocument.PartsListEvents;
                    
                    break;
                case SolidEdgeFramework.DocumentTypeConstants.igPartDocument:
                    var partDocument = (SolidEdgePart.PartDocument)document;

                    _dividePartEvents = (SolidEdgeFramework.ISEDividePartEvents_Event)partDocument.DividePartEvents;
                    _familyOfPartsEvents = (SolidEdgeFramework.ISEFamilyOfPartsEvents_Event)partDocument.FamilyOfPartsEvents;
                    _familyOfPartsExEvents = (SolidEdgeFramework.ISEFamilyOfPartsExEvents_Event)partDocument.FamilyOfPartsExEvents;

                    break;
                case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument:
                    var sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document;

                    _dividePartEvents = (SolidEdgeFramework.ISEDividePartEvents_Event)sheetMetalDocument.DividePartEvents;
                    _familyOfPartsEvents = (SolidEdgeFramework.ISEFamilyOfPartsEvents_Event)sheetMetalDocument.FamilyOfPartsEvents;
                    _familyOfPartsExEvents = (SolidEdgeFramework.ISEFamilyOfPartsExEvents_Event)sheetMetalDocument.FamilyOfPartsExEvents;

                    break;
            }

            if (_documentEvents != null)
            {
                _documentEvents.AfterSave += ISEDocumentEvents_AfterSave;
                _documentEvents.BeforeClose += ISEDocumentEvents_BeforeClose;
                _documentEvents.BeforeSave += ISEDocumentEvents_BeforeSave;
                _documentEvents.SelectSetChanged += ISEDocumentEvents_SelectSetChanged;
            }

            if (_assemblyChangeEvents != null)
            {
                _assemblyChangeEvents.AfterChange += ISEAssemblyChangeEvents_AfterChange;
                _assemblyChangeEvents.BeforeChange += ISEAssemblyChangeEvents_BeforeChange;
            }

            if (_assemblyFamilyEvents != null)
            {
                _assemblyFamilyEvents.AfterMemberActivate += ISEAssemblyFamilyEvents_AfterMemberActivate;
                _assemblyFamilyEvents.AfterMemberCreate += ISEAssemblyFamilyEvents_AfterMemberCreate;
                _assemblyFamilyEvents.AfterMemberDelete += ISEAssemblyFamilyEvents_AfterMemberDelete;
                _assemblyFamilyEvents.BeforeMemberActivate += ISEAssemblyFamilyEvents_BeforeMemberActivate;
                _assemblyFamilyEvents.BeforeMemberCreate += ISEAssemblyFamilyEvents_BeforeMemberCreate;
                _assemblyFamilyEvents.BeforeMemberDelete += ISEAssemblyFamilyEvents_BeforeMemberDelete;
            }

            if (_assemblyRecomputeEvents != null)
            {
                _assemblyRecomputeEvents.AfterAdd += ISEAssemblyRecomputeEvents_AfterAdd;
                _assemblyRecomputeEvents.AfterModify += ISEAssemblyRecomputeEvents_AfterModify;
                _assemblyRecomputeEvents.AfterRecompute += ISEAssemblyRecomputeEvents_AfterRecompute;
                _assemblyRecomputeEvents.BeforeDelete += ISEAssemblyRecomputeEvents_BeforeDelete;
                _assemblyRecomputeEvents.BeforeRecompute += ISEAssemblyRecomputeEvents_BeforeRecompute;
            }

            if (_blockTableEvents != null)
            {
                _blockTableEvents.AfterUpdate += ISEBlockTableEvents_AfterUpdate;
            }

            if (_connectorTableEvents != null)
            {
                _connectorTableEvents.AfterUpdate += ISEConnectorTableEvents_AfterUpdate;
            }

            if (_draftBendTableEvents != null)
            {
                _draftBendTableEvents.AfterUpdate += ISEDraftBendTableEvents_AfterUpdate;
            }

            if (_drawingViewEvents != null)
            {
                _drawingViewEvents.AfterUpdate += ISEDrawingViewEvents_AfterUpdate;
            }

            if (_partsListEvents != null)
            {
                _partsListEvents.AfterUpdate += ISEPartsListEvents_AfterUpdate;
            }

            if (_dividePartEvents != null)
            {
                _dividePartEvents.AfterDividePartDocumentCreated += ISEDividePartEvents_AfterDividePartDocumentCreated;
                _dividePartEvents.AfterDividePartDocumentRenamed += ISEDividePartEvents_AfterDividePartDocumentRenamed;
                _dividePartEvents.BeforeDividePartDocumentDeleted += ISEDividePartEvents_BeforeDividePartDocumentDeleted;
            }

            if (_familyOfPartsEvents != null)
            {
                _familyOfPartsEvents.AfterMemberDocumentCreated += ISEFamilyOfPartsEvents_AfterMemberDocumentCreated;
                _familyOfPartsEvents.AfterMemberDocumentRenamed += ISEFamilyOfPartsEvents_AfterMemberDocumentRenamed;
                _familyOfPartsEvents.BeforeMemberDocumentDeleted += ISEFamilyOfPartsEvents_BeforeMemberDocumentDeleted;
            }

            if (_familyOfPartsExEvents != null)
            {
                _familyOfPartsExEvents.AfterMemberDocumentCreated += ISEFamilyOfPartsExEvents_AfterMemberDocumentCreated;
                _familyOfPartsExEvents.AfterMemberDocumentRenamed += ISEFamilyOfPartsExEvents_AfterMemberDocumentRenamed;
                _familyOfPartsExEvents.BeforeMemberDocumentDeleted += ISEFamilyOfPartsExEvents_BeforeMemberDocumentDeleted;
            }
        }
Exemple #21
0
        private void UpdateTreeView(SolidEdgeFramework.SelectSet selectSet)
        {
            var rootNode = tvSelectSet.Nodes[0];
            rootNode.Nodes.Clear();
            lvAttributes.Items.Clear();

            for (int i = 1; i <= selectSet.Count; i++)
            {
                dynamic item = null;
                Type itemType = null;

                try
                {
                    item = selectSet.Item(i);
                    itemType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(item);
                }
                catch
                {
                }

                if ((item != null) && (itemType != null))
                {
                    TreeNode itemNode = new TreeNode(String.Format("Item {0} ({1})", i, itemType.FullName));
                    var property = itemType.GetProperty("AttributeSets");

                    if (property != null)
                    {
                        itemNode.ImageIndex = 1;
                    }
                    else
                    {
                        itemNode.ImageIndex = 2;
                    }
                    
                    itemNode.SelectedImageIndex = itemNode.ImageIndex;
                    itemNode.Tag = item;

                    rootNode.Nodes.Add(itemNode);
                }
            }

            if (rootNode.Nodes.Count > 0)
            {
                tvSelectSet.SelectedNode = rootNode.Nodes[0];
            }

            rootNode.ExpandAll();
        }
Exemple #22
0
        static void DemoApplicationExtensionMethods(SolidEdgeFramework.Application application, SolidEdgeFramework.Documents documents)
        {
            // Note the extension methods are only available when you use:
            // using SolidEdgeContrib.Extensions;

            // Add an assembly document.
            var assemblyDocument = documents.AddAssemblyDocument();

            // Always good to call DoIdle() after creating a new document.
            application.DoIdle();

            // Get a SolidEdgeFramework.SolidEdgeDocument typed reference to the active document.
            var activeDocument = application.GetActiveDocument();

            // Demonstrate generic GetActiveDocument extension method.
            var activeAssemblyDocument = application.GetActiveDocument<SolidEdgeAssembly.AssemblyDocument>();

            // Always good to call DoIdle() after creating a new document.
            application.DoIdle();

            // Add a draft document.
            var draftDocument = documents.AddDraftDocument();

            // Always good to call DoIdle() after creating a new document.
            application.DoIdle();

            // Demonstrate generic GetActiveDocument extension method.
            var activeDraftDocument = application.GetActiveDocument<SolidEdgeDraft.DraftDocument>();

            // Add a part document.
            var partDocument = documents.AddPartDocument();

            // Always good to call DoIdle() after creating a new document.
            application.DoIdle();

            // Demonstrate generic GetActiveDocument extension method.
            var activePartDocument = application.GetActiveDocument<SolidEdgePart.PartDocument>();

            // Get a reference to the RefPlanes collection.
            var refPlanes = activePartDocument.RefPlanes;

            // Demonstrate using extension methods to easily get specific RefPlanes.
            var frontPlane = refPlanes.GetFrontPlane();
            var rightPlane = refPlanes.GetRightPlane();
            var topPlane = refPlanes.GetTopPlane();

            // Add a sheet metal document.
            var sheetMetalDocument = documents.AddSheetMetalDocument();

            // Always good to call DoIdle() after creating a new document.
            application.DoIdle();

            // Demonstrate generic GetActiveDocument extension method.
            var activeSheetMetalDocument = application.GetActiveDocument<SolidEdgePart.SheetMetalDocument>();

            // Demonstrate StartCommand extension methods.
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewBackView);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewBottomView);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewClipping);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewDimetricView);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewFrontView);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewISOView);
            application.StartCommand(SolidEdgeConstants.SheetMetalCommandConstants.SheetMetalViewLeftView);

            // Get a strongly typed SolidEdgeFramework.ISEApplicationEvents_Event.
            var applicationEvents = application.GetApplicationEvents();

            // Get a strongly typed reference to the active environment.
            var environment = application.GetActiveEnvironment();

            // Get the seApplicationGlobalSystemInfo global parameter. Return type is an object.
            var globalSystemInfoObject = application.GetGlobalParameter(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalSystemInfo);

            // Get the seApplicationGlobalSystemInfo global parameter. Using the generic overload, return type is a string.
            var globalSystemInfoString = application.GetGlobalParameter<string>(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalSystemInfo);

            // Get an instance of a System.Diagnostics.Process that represents the Edge.exe process.
            var process = application.GetProcess();

            // Get an instance of a System.Version that represents the version of Solid Edge rather than just a string.
            var version = application.GetVersion();
        }
Exemple #23
0
        static void ReportRelation(SolidEdgeAssembly.SegmentTangentRelation3d relation3d, SolidEdgeFramework.ObjectType objectType)
        {
            Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType);

            try
            {
                Console.WriteLine("Status: {0}", relation3d.Status);
            }
            catch
            {
            }

            Console.WriteLine();
        }
Exemple #24
0
        static void ReportRelation(SolidEdgeAssembly.TangentRelation3d relation3d, SolidEdgeFramework.ObjectType objectType)
        {
            Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType);

            try
            {
                Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("HalfSpacePositive: {0}", relation3d.HalfSpacePositive);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("Offset: {0}", relation3d.Offset);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("RangedOffset: {0}", relation3d.RangedOffset);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("RangeHigh: {0}", relation3d.RangeHigh);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("RangeLow: {0}", relation3d.RangeLow);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("Status: {0}", relation3d.Status);
            }
            catch
            {
            }

            try
            {
                Console.WriteLine("Suppress: {0}", relation3d.Suppress);
            }
            catch
            {
            }

            Console.WriteLine();
        }
 public DraftPrintUtilityOptions(SolidEdgeFramework.Application application)
     : this((SolidEdgeDraft.DraftPrintUtility)application.GetDraftPrintUtility())
 {
 }
        public ApplicationEventWatcher(Form1 form, SolidEdgeFramework.Application application)
        {
            _form = form;

            this.AdviseSink<SolidEdgeFramework.ISEApplicationEvents>(application);
        }
Exemple #27
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;
            }
        }
Exemple #28
0
 /// <summary>
 /// Called when the addin is about to be unloaded by Solid Edge.
 /// </summary>
 public override void OnDisconnection(SolidEdgeFramework.SeDisconnectMode DisconnectMode)
 {
     // Disconnect from all COM events.
     _connectionPointController.UnadviseAllSinks();
 }
Exemple #29
0
 /// <summary>
 /// Called when the addin first connects to a new Solid Edge environment.
 /// </summary>
 public override void OnConnectToEnvironment(SolidEdgeFramework.Environment environment, bool firstTime)
 {
 }
        public static string ResolveCommandId(SolidEdgeFramework.Application application, int theCommandID)
        {
            ComVariableInfo variableInfo = null;

            if (_environmentConstantsMap.Count == 0)
            {
                Initialize();
            }

            try
            {
                ComEnumInfo enumInfo = null;
                SolidEdgeFramework.Environment environment = application.GetActiveEnvironment();
                Guid environmentGuid = environment.GetGuid();

                if (_environmentConstantsMap.TryGetValue(environmentGuid, out enumInfo))
                {
                    variableInfo = enumInfo.Variables.Where(x => x.ConstantValue != null).Where(x => x.ConstantValue.Equals(theCommandID)).FirstOrDefault();

                    if (variableInfo != null)
                    {
                        return String.Format("{0} [{1}.{2}]", theCommandID, variableInfo.ComTypeInfo.Name, variableInfo.Name);
                    }
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            return String.Format("{0} [Undefined]", theCommandID);
        }