private void CopyOptions(SolidEdgeDraft.DraftPrintUtility draftPrintUtility, DraftPrintUtilityOptions options)
        {
            Type fromType = typeof(DraftPrintUtilityOptions);
            Type toType = typeof(SolidEdgeDraft.DraftPrintUtility);
            PropertyInfo[] properties = toType.GetProperties().Where(x => x.CanWrite).ToArray();

            // Copy all of the properties from DraftPrintUtility to this object.
            foreach (PropertyInfo toProperty in properties)
            {
                // Some properties may throw an exception if options are incompatible.
                // For instance, if PrintToFile = false, setting PrintToFileName = "" will cause an exception.
                // Mostly irrelevant but handle it as you see fit.
                try
                {
                    PropertyInfo fromProperty = fromType.GetProperty(toProperty.Name);
                    if (fromProperty != null)
                    {
                        object val = fromProperty.GetValue(options, null);

                        toType.InvokeMember(toProperty.Name, BindingFlags.SetProperty, null, draftPrintUtility, new object[] { val });

                    }
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        public DraftPrintUtilityOptions(SolidEdgeDraft.DraftPrintUtility draftPrintUtility)
        {
            Type thatType = typeof(SolidEdgeDraft.DraftPrintUtility);
            Type thisType = this.GetType();
            PropertyInfo[] properties = thatType.GetProperties().Where(x => x.CanWrite).ToArray();

            // Copy all of the properties from DraftPrintUtility to this object.
            foreach (PropertyInfo property in properties)
            {
                object val = thatType.InvokeMember(property.Name, BindingFlags.GetProperty, null, draftPrintUtility, null);

                PropertyInfo thisProperty = thisType.GetProperty(property.Name);
                if (thisProperty != null)
                {
                    thisProperty.SetValue(this, val, null);
                }
            }
        }
Exemple #3
0
        static void ConvertSection(SolidEdgeDraft.Section section)
        {
            SolidEdgeDraft.SectionSheets sectionSheets = null;
            SolidEdgeFrameworkSupport.Balloons balloons = null;

            // Get a reference to the section sheets collection.
            sectionSheets = section.Sheets;

            // Process all of the sheets in the section.
            foreach (var sheet in sectionSheets.OfType<SolidEdgeDraft.Sheet>())
            {
                // Get a reference to the section balloons collection.
                balloons = (SolidEdgeFrameworkSupport.Balloons)sheet.Balloons;

                // Process all of the balloons in the sheet.
                foreach (var balloon in balloons.OfType<SolidEdgeFrameworkSupport.Balloon>())
                {
                    // If BalloonText has a formula, it will be overriden with BalloonDisplayedText.
                    balloon.BalloonText = balloon.BalloonDisplayedText;
                }

                // Note: There may be other controls that need to be updated...
            }
        }
Exemple #4
0
        static void ReportGraphicMembers(SolidEdgeDraft.GraphicMembers graphicMembers)
        {
            // This is a good example of how to deal with collections that contain different types.
            foreach (var graphicMember in graphicMembers.OfType<object>())
            {
                Console.WriteLine();
                var graphicMemberType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(graphicMember);

                double xKeypoint;
                double yKeypoint;
                double zKeypoint;
                SolidEdgeFramework.KeyPointType keypointType;
                int handleType;

                if (graphicMemberType.Equals(typeof(SolidEdgeDraft.DVLine2d)))
                {
                    var line2d = graphicMember as SolidEdgeDraft.DVLine2d;
                    Console.WriteLine("Processing graphic member '{0}' ({1}).", line2d.Name, graphicMemberType);
                    Console.WriteLine("Angle: {0}.", line2d.Angle);
                    Console.WriteLine("Length: {0}.", line2d.Length);

                    for (int i = 1; i <= line2d.KeyPointCount; i++)
                    {
                        line2d.GetKeyPoint(i, out xKeypoint, out yKeypoint, out zKeypoint, out keypointType, out handleType);
                        Console.WriteLine("Keypoint {0}: x={1} y={2} z={3} type={4} handle={5}", i, xKeypoint, yKeypoint, zKeypoint, keypointType, handleType);
                    }
                }
                else if (graphicMemberType.Equals(typeof(SolidEdgeDraft.DVArc2d)))
                {
                    var arc2d = graphicMember as SolidEdgeDraft.DVArc2d;
                    Console.WriteLine("Processing graphic member '{0}' ({1}).", arc2d.Name, graphicMemberType);
                    Console.WriteLine("BendRadius: {0}.", arc2d.BendRadius);
                    Console.WriteLine("Radius: {0}.", arc2d.Radius);
                    Console.WriteLine("StartAngle: {0}.", arc2d.StartAngle);
                    Console.WriteLine("SweepAngle: {0}.", arc2d.SweepAngle);

                    for (int i = 1; i <= arc2d.KeyPointCount; i++)
                    {
                        arc2d.GetKeyPoint(i, out xKeypoint, out yKeypoint, out zKeypoint, out keypointType, out handleType);
                        Console.WriteLine("Keypoint {0}: x={1} y={2} z={3} type={4} handle={5}", i, xKeypoint, yKeypoint, zKeypoint, keypointType, handleType);
                    }
                }
                else if (graphicMemberType.Equals(typeof(SolidEdgeDraft.DVCircle2d)))
                {
                    var circle2d = graphicMember as SolidEdgeDraft.DVCircle2d;
                    Console.WriteLine("Processing graphic member '{0}' ({1}).", circle2d.Name, graphicMemberType);
                    Console.WriteLine("Area: {0}.", circle2d.Area);
                    Console.WriteLine("BendAngle: {0}.", circle2d.BendAngle);
                    Console.WriteLine("BendRadius: {0}.", circle2d.BendRadius);
                    Console.WriteLine("Circumference: {0}.", circle2d.Circumference);
                    Console.WriteLine("Diameter: {0}.", circle2d.Diameter);

                    for (int i = 1; i <= circle2d.KeyPointCount; i++)
                    {
                        circle2d.GetKeyPoint(i, out xKeypoint, out yKeypoint, out zKeypoint, out keypointType, out handleType);
                        Console.WriteLine("Keypoint {0}: x={1} y={2} z={3} type={4} handle={5}", i, xKeypoint, yKeypoint, zKeypoint, keypointType, handleType);
                    }
                }
            }
        }
Exemple #5
0
 static void ReportItem(SolidEdgeDraft.DrawingView drawingView)
 {
     Console.WriteLine("Name: {0}", drawingView.Name);
 }
 public static void ReportVariables(SolidEdgeDraft.DraftDocument document)
 {
     ReportVariables((SolidEdgeFramework.SolidEdgeDocument)document);
 }
Exemple #7
0
        void DoOpenSave(SolidEdgeDraft.DraftDocument draftDocument, DraftSettings draftSettings)
        {
            SolidEdgeDraft.Sections sections = null;
            SolidEdgeDraft.Section section = null;
            SolidEdgeDraft.SectionSheets sectionSheets = null;
            SolidEdgeDraft.Sheet sheet = null;
            SolidEdgeDraft.DrawingViews drawingViews = null;
            SolidEdgeDraft.DrawingView drawingView = null;

            if (draftSettings.UpdateDrawingViews)
            {
                sections = draftDocument.Sections;
                section = sections.WorkingSection;

                sectionSheets = section.Sheets;

                for (int i = 1; i <= sectionSheets.Count; i++)
                {
                    sheet = sectionSheets.Item(i);
                    drawingViews = sheet.DrawingViews;

                    for (int j = 1; j <= drawingViews.Count; j++)
                    {
                        drawingView = drawingViews.Item(j);
                        drawingView.Update();
                    }
                }
            }
        }