static void ReportRelations3d(SolidEdgeAssembly.Relations3d relations3d)
        {
            SolidEdgeAssembly.GroundRelation3d groundRelation3d = null;
            SolidEdgeAssembly.AxialRelation3d  axialRelation3d  = null;
            SolidEdgeAssembly.PlanarRelation3d planarRelation3d = null;

            for (int i = 1; i <= relations3d.Count; i++)
            {
                object relation3d = relations3d.Item(i);

                // GetInteropType() is a custom method extension!
                Type t = relation3d.GetInteropType();

                Console.WriteLine("Relations3d[{0}] is of type '{1}'.", i, t);

                // Determine the ObjectType.
                SolidEdgeFramework.ObjectType relationType =
                    (SolidEdgeFramework.ObjectType)relation3d.GetType().InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, relation3d, null);

                switch (relationType)
                {
                case SolidEdgeFramework.ObjectType.igGroundRelation3d:
                    groundRelation3d = (SolidEdgeAssembly.GroundRelation3d)relation3d;
                    break;

                case SolidEdgeFramework.ObjectType.igAxialRelation3d:
                    axialRelation3d = (SolidEdgeAssembly.AxialRelation3d)relation3d;
                    break;

                case SolidEdgeFramework.ObjectType.igPlanarRelation3d:
                    planarRelation3d = (SolidEdgeAssembly.PlanarRelation3d)relation3d;
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        static void ReportRelation(SolidEdgeAssembly.PlanarRelation3d relation3d, SolidEdgeFramework.ObjectType objectType)
        {
            Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType);

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

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

            try
            {
                Console.WriteLine("NormalsAligned: {0}", relation3d.NormalsAligned);
            }
            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();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Relations3d      relations3d      = null;
            SolidEdgeAssembly.GroundRelation3d groundRelation3d = null;
            SolidEdgeAssembly.AxialRelation3d  axialRelation3d  = null;
            SolidEdgeAssembly.PlanarRelation3d planarRelation3d = null;
            SolidEdgeAssembly.Occurrence       occurrence1      = null;
            SolidEdgeAssembly.Occurrence       occurrence2      = null;
            SolidEdgeAssembly.Relation3dDetailedStatusConstants detailedStatus;
            SolidEdgeAssembly.Relation3dStatusConstants         status;

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

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

                // Get a reference to the active document.
                assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false);

                // Get a reference to the Relations3d collection.
                relations3d = assemblyDocument.Relations3d;

                foreach (var relation3d in relations3d.OfType <object>())
                {
                    try
                    {
                        // Not used in this sample but a good example of how to get the runtime type.
                        var relationType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(relation3d);

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

                        // Reset statuses.
                        detailedStatus = (SolidEdgeAssembly.Relation3dDetailedStatusConstants) 0;
                        status         = (SolidEdgeAssembly.Relation3dStatusConstants) 0;

                        // Handle specific object type. There are other possible relation types...
                        switch (relationObjectType)
                        {
                        case SolidEdgeFramework.ObjectType.igGroundRelation3d:
                            // Cast relation3d object to GroundRelation3d type.
                            groundRelation3d = (SolidEdgeAssembly.GroundRelation3d)relation3d;

                            // Get a reference to the grounded occurrence.
                            occurrence1 = groundRelation3d.Occurrence;

                            // Get the detailed status.
                            detailedStatus = groundRelation3d.DetailedStatus;

                            // Get the status.
                            status = groundRelation3d.Status;

                            break;

                        case SolidEdgeFramework.ObjectType.igAxialRelation3d:
                            // Cast relation3d object to AxialRelation3d type.
                            axialRelation3d = (SolidEdgeAssembly.AxialRelation3d)relation3d;

                            // Get a reference to the related occurrences.
                            occurrence1 = axialRelation3d.Occurrence1;
                            occurrence2 = axialRelation3d.Occurrence2;

                            // Get the detailed status.
                            detailedStatus = axialRelation3d.DetailedStatus;

                            // Get the status.
                            status = axialRelation3d.Status;

                            break;

                        case SolidEdgeFramework.ObjectType.igPlanarRelation3d:
                            // Cast relation3d object to PlanarRelation3d type.
                            planarRelation3d = (SolidEdgeAssembly.PlanarRelation3d)relation3d;

                            // Get a reference to the related occurrences.
                            occurrence1 = planarRelation3d.Occurrence1;
                            occurrence2 = planarRelation3d.Occurrence2;

                            // Get the detailed status.
                            detailedStatus = planarRelation3d.DetailedStatus;

                            // Get the status.
                            status = planarRelation3d.Status;
                            break;

                        default:
                            break;
                        }

                        // Analyze the detailed status.
                        switch (detailedStatus)
                        {
                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusBetweenFixed:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusBetweenSetMembers:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusMissingGeometry:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusSolved:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusSuppressed:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusUnknown:
                            break;

                        case SolidEdgeAssembly.Relation3dDetailedStatusConstants.igRelation3dDetailedStatusUnsatisfied:
                            break;
                        }

                        // Analyze the status.
                        switch (status)
                        {
                        case SolidEdgeAssembly.Relation3dStatusConstants.igRelation3dStatusSolved:
                            break;

                        case SolidEdgeAssembly.Relation3dStatusConstants.igRelation3dStatusUnsolved:
                            break;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }