コード例 #1
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;

            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 the active document.
                assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false);

                if (assemblyDocument != null)
                {
                    // Get a reference to the Occurrences collection.
                    occurrences = assemblyDocument.Occurrences;

                    foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>())
                    {
                        Array MinRangePoint = Array.CreateInstance(typeof(double), 0);
                        Array MaxRangePoint = Array.CreateInstance(typeof(double), 0);
                        occurrence.GetRangeBox(ref MinRangePoint, ref MaxRangePoint);

                        // Convert from System.Array to double[].  double[] is easier to work with.
                        double[] a1 = MinRangePoint.OfType <double>().ToArray();
                        double[] a2 = MaxRangePoint.OfType <double>().ToArray();

                        // Report the occurrence matrix.
                        Console.WriteLine("{0} range box:", occurrence.Name);
                        Console.WriteLine("|MinRangePoint: {0}, {1}, {2}|",
                                          a1[0],
                                          a1[1],
                                          a1[2]);
                        Console.WriteLine("|MaxRangePoint: {0}, {1}, {2}|",
                                          a2[0],
                                          a2[1],
                                          a2[2]);
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application                     application      = null;
            SolidEdgeAssembly.AssemblyDocument                 assemblyDocument = null;
            SolidEdgeAssembly.Occurrences                      occurrences      = null;
            SolidEdgeAssembly.InterferenceStatusConstants      interferenceStatus;
            SolidEdgeConstants.InterferenceComparisonConstants compare    = SolidEdgeConstants.InterferenceComparisonConstants.seInterferenceComparisonSet1vsAllOther;
            SolidEdgeConstants.InterferenceReportConstants     reportType = SolidEdgeConstants.InterferenceReportConstants.seInterferenceReportPartNames;

            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 assembly document.
                assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false);

                if (assemblyDocument != null)
                {
                    // Get a reference to the Occurrences collection.
                    occurrences = assemblyDocument.Occurrences;

                    foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>())
                    {
                        Array  set1                   = Array.CreateInstance(occurrence.GetType(), 1);
                        object numInterferences       = 0;
                        object retSet1                = Array.CreateInstance(typeof(SolidEdgeAssembly.Occurrence), 0);
                        object retSet2                = Array.CreateInstance(typeof(SolidEdgeAssembly.Occurrence), 0);
                        object confirmedInterference  = null;
                        object interferenceOccurrence = null;

                        set1.SetValue(occurrence, 0);

                        // Check interference.
                        assemblyDocument.CheckInterference(
                            NumElementsSet1: set1.Length,
                            Set1: ref set1,
                            Status: out interferenceStatus,
                            ComparisonMethod: compare,
                            NumElementsSet2: 0,
                            Set2: Missing.Value,
                            AddInterferenceAsOccurrence: false,
                            ReportFilename: Missing.Value,
                            ReportType: reportType,
                            NumInterferences: out numInterferences,
                            InterferingPartsSet1: ref retSet1,
                            InterferingPartsOtherSet: ref retSet2,
                            ConfirmedInterference: ref confirmedInterference,
                            InterferenceOccurrence: out interferenceOccurrence,
                            IgnoreThreadInterferences: Missing.Value
                            );

                        // Process status.
                        switch (interferenceStatus)
                        {
                        case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusNoInterference:
                            break;

                        case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedAndProbableInterference:
                        case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusConfirmedInterference:
                        case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusIncompleteAnalysis:
                        case SolidEdgeAssembly.InterferenceStatusConstants.seInterferenceStatusProbableInterference:
                            if (retSet2 != null)
                            {
                                for (int j = 0; j < (int)numInterferences; j++)
                                {
                                    object obj1 = ((Array)retSet1).GetValue(j);
                                    object obj2 = ((Array)retSet2).GetValue(j);

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

                                    SolidEdgeFramework.Reference reference1  = null;
                                    SolidEdgeFramework.Reference reference2  = null;
                                    SolidEdgeAssembly.Occurrence occurrence1 = null;
                                    SolidEdgeAssembly.Occurrence occurrence2 = null;

                                    switch (objectType1)
                                    {
                                    case SolidEdgeFramework.ObjectType.igReference:
                                        reference1 = (SolidEdgeFramework.Reference)obj1;
                                        break;

                                    case SolidEdgeFramework.ObjectType.igPart:
                                    case SolidEdgeFramework.ObjectType.igOccurrence:
                                        occurrence1 = (SolidEdgeAssembly.Occurrence)obj1;
                                        break;
                                    }

                                    switch (objectType2)
                                    {
                                    case SolidEdgeFramework.ObjectType.igReference:
                                        reference2 = (SolidEdgeFramework.Reference)obj2;
                                        break;

                                    case SolidEdgeFramework.ObjectType.igPart:
                                    case SolidEdgeFramework.ObjectType.igOccurrence:
                                        occurrence2 = (SolidEdgeAssembly.Occurrence)obj2;
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;

            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 the active document.
                assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false);

                if (assemblyDocument != null)
                {
                    // Get a reference to the Occurrences collection.
                    occurrences = assemblyDocument.Occurrences;

                    foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>())
                    {
                        // Allocate a new array to hold transform.
                        double[] transform = new double[6];

                        // Get the occurrence transform.
                        occurrence.GetTransform(
                            OriginX: out transform[0],
                            OriginY: out transform[1],
                            OriginZ: out transform[2],
                            AngleX: out transform[3],
                            AngleY: out transform[4],
                            AngleZ: out transform[5]);

                        // Report the occurrence transform.
                        Console.WriteLine("{0} transform:", occurrence.Name);
                        Console.WriteLine("OriginX: {0} (meters)", transform[0]);
                        Console.WriteLine("OriginY: {0} (meters)", transform[1]);
                        Console.WriteLine("OriginZ: {0} (meters)", transform[2]);
                        Console.WriteLine("AngleX: {0} (radians)", transform[3]);
                        Console.WriteLine("AngleY: {0} (radians)", transform[4]);
                        Console.WriteLine("AngleZ: {0} (radians)", transform[5]);
                        Console.WriteLine();

                        // Allocate a new array to hold matrix.
                        Array matrix = Array.CreateInstance(typeof(double), 16);

                        // Get the occurrence matrix.
                        occurrence.GetMatrix(ref matrix);

                        // Convert from System.Array to double[].  double[] is easier to work with.
                        double[] m = matrix.OfType <double>().ToArray();

                        // Report the occurrence matrix.
                        Console.WriteLine("{0} matrix:", occurrence.Name);
                        Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                          m[0],
                                          m[1],
                                          m[2],
                                          m[3]);
                        Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                          m[4],
                                          m[5],
                                          m[6],
                                          m[7]);
                        Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                          m[8],
                                          m[9],
                                          m[10],
                                          m[11]);
                        Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                          m[12],
                                          m[13],
                                          m[14],
                                          m[15]);

                        Console.WriteLine();
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: tecnicoPOLARIA/SE_POLARIA
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.Documents       documents        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;
            SolidEdgeAssembly.Tube             tube             = null;

            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);

                try
                {
                    // Get the active document.
                    assemblyDocument = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false);
                }
                catch
                {
                }

                // If there is not an active assembly, we can use an assembly from the training folder.
                if (assemblyDocument == null)
                {
                    documents = application.Documents;

                    // Build path to part file.
                    string filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), @"Try It\zone_try_it.asm");
                    assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)documents.Open(filename);
                }

                if (assemblyDocument != null)
                {
                    // Get a reference to the Occurrences collection.
                    occurrences = assemblyDocument.Occurrences;

                    foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>())
                    {
                        if (occurrence.IsTube())
                        {
                            tube = occurrence.GetTube();

                            Console.WriteLine("Occurrences[{0}] is a tube.", occurrence.Index);
                            Console.WriteLine("PartFileName: {0}", tube.PartFileName);

                            object CutLength          = 0.0;
                            object NumOfBends         = 0;
                            object FeedLengthArray    = new double[] { };
                            object RotationAngleArray = new double[] { };
                            object BendRadiusArray    = new double[] { };
                            object ReverseBendOrder   = 0;
                            object SaveToFileName     = Missing.Value;
                            object BendAngleArray     = new double[] { };

                            tube.BendTable(
                                CutLength: out CutLength,
                                NumOfBends: out NumOfBends,
                                FeedLength: out FeedLengthArray,
                                RotationAngle: out RotationAngleArray,
                                BendRadius: out BendRadiusArray,
                                ReverseBendOrder: ref ReverseBendOrder,
                                SaveToFileName: SaveToFileName,
                                BendAngle: out BendAngleArray);

                            StringBuilder FeedLength = new StringBuilder();
                            foreach (double d in (double[])FeedLengthArray)
                            {
                                FeedLength.AppendFormat("{0}, ", d);
                            }

                            StringBuilder RotationAngle = new StringBuilder();
                            foreach (double d in (double[])RotationAngleArray)
                            {
                                RotationAngle.AppendFormat("{0}, ", d);
                            }

                            StringBuilder BendRadius = new StringBuilder();
                            foreach (double d in (double[])BendRadiusArray)
                            {
                                BendRadius.AppendFormat("{0}, ", d);
                            }

                            StringBuilder BendAngle = new StringBuilder();
                            foreach (double d in (double[])BendAngleArray)
                            {
                                BendAngle.AppendFormat("{0}, ", d);
                            }

                            Console.WriteLine("BendTable information:");
                            Console.WriteLine("CutLength: {0}", CutLength);
                            Console.WriteLine("NumOfBends: {0}", NumOfBends);
                            Console.WriteLine("FeedLength: {0}", FeedLength.ToString().Trim().TrimEnd(','));
                            Console.WriteLine("RotationAngle: {0}", RotationAngle.ToString().Trim().TrimEnd(','));
                            Console.WriteLine("BendRadius: {0}", BendRadius.ToString().Trim().TrimEnd(','));
                            Console.WriteLine("BendAngle: {0}", BendAngle.ToString().Trim().TrimEnd(','));
                            Console.WriteLine();
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application     application      = null;
            SolidEdgeFramework.SelectSet       selectSet        = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Occurrences      occurrences      = null;

            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();

                // Get a reference to the active selectset.
                selectSet = application.ActiveSelectSet;

                // Temporarily suspend selectset UI updates.
                selectSet.SuspendDisplay();

                // Clear the selectset.
                selectSet.RemoveAll();

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

                if (assemblyDocument != null)
                {
                    // Get a reference to the occurrences collection.
                    occurrences = assemblyDocument.Occurrences;

                    // Loop through the occurrences.
                    foreach (var occurrence in occurrences.OfType <SolidEdgeAssembly.Occurrence>())
                    {
                        // If status equals seOccurrenceStatusUnderDefined, add to selectset.
                        if (occurrence.Status == SolidEdgeAssembly.OccurrenceStatusConstants.seOccurrenceStatusUnderDefined)
                        {
                            selectSet.Add(occurrence);
                        }
                    }
                }
                else
                {
                    throw new System.Exception("No active document");
                }

                // Re-enable selectset UI display.
                selectSet.ResumeDisplay();

                // Manually refresh the selectset UI display.
                selectSet.RefreshDisplay();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }