Beispiel #1
0
        static void AddLineAndDimension(SolidEdgeDraft.DraftDocument draftDocument)
        {
            SolidEdgeDraft.Sheet sheet = null;
            SolidEdgeFrameworkSupport.Lines2d    lines2d    = null;
            SolidEdgeFrameworkSupport.Line2d     line2d     = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions = null;
            SolidEdgeFrameworkSupport.Dimension  dimension  = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle   = null;

            // Get a reference to the active sheet.
            sheet = draftDocument.ActiveSheet;

            // Get a reference to the Lines2d collection.
            lines2d = sheet.Lines2d;

            // Draw a new line.
            line2d = lines2d.AddBy2Points(
                x1: 0.2,
                y1: 0.2,
                x2: 0.3,
                y2: 0.2);

            // Get a reference to the Dimensions collection.
            dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

            // Add a dimension to the line.
            dimension = dimensions.AddLength(line2d);

            // Get a reference to the dimension style.
            // DimStyle has a ton of options...
            dimStyle = dimension.Style;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application   = null;
            SolidEdgeFramework.Documents         documents     = null;
            SolidEdgeDraft.DraftDocument         draftDocument = null;
            SolidEdgeDraft.Sheet                 sheet         = null;
            SolidEdgeFrameworkSupport.Circles2d  circles2d     = null;
            SolidEdgeFrameworkSupport.Circle2d   circle2d      = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions    = 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 a reference to the documents collection.
                documents = application.Documents;

                // Create a new draft document.
                draftDocument = documents.AddDraftDocument();

                // Get a reference to the active sheet.
                sheet = draftDocument.ActiveSheet;

                // Get a reference to the Circles2d collection.
                circles2d = sheet.Circles2d;

                // Get a reference to the Dimensions collection.
                dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

                double x      = 0.1;
                double y      = 0.1;
                double radius = 0.01;

                for (int i = 0; i < 5; i++)
                {
                    // Add the circle.
                    circle2d = circles2d.AddByCenterRadius(x, y, radius);

                    // Dimension the circle.
                    dimensions.AddRadialDiameter(circle2d);

                    x      += 0.05;
                    y      += 0.05;
                    radius += 0.01;
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application   = null;
            SolidEdgeFramework.Documents         documents     = null;
            SolidEdgeDraft.DraftDocument         draftDocument = null;
            SolidEdgeDraft.Sheet                 sheet         = null;
            SolidEdgeFrameworkSupport.Lines2d    lines2d       = null;
            SolidEdgeFrameworkSupport.Line2d     line2d        = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions    = null;
            SolidEdgeFrameworkSupport.Dimension  dimension     = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle      = 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 a reference to the documents collection.
                documents = application.Documents;

                // Create a new draft document.
                draftDocument = documents.AddDraftDocument();

                // Get a reference to the active sheet.
                sheet = draftDocument.ActiveSheet;

                // Get a reference to the Lines2d collection.
                lines2d = sheet.Lines2d;

                // Draw a new line.
                line2d = lines2d.AddBy2Points(
                    x1: 0.2,
                    y1: 0.2,
                    x2: 0.3,
                    y2: 0.2);

                // Get a reference to the Dimensions collection.
                dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

                // Add a dimension to the line.
                dimension = dimensions.AddLength(line2d);

                // Get a reference to the dimension style.
                // DimStyle has a ton of options...
                dimStyle = dimension.Style;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
Beispiel #4
0
        static void AddPartViewAndDimension(SolidEdgeDraft.DraftDocument draftDocument)
        {
            SolidEdgeDraft.Sheet        sheet        = null;
            SolidEdgeDraft.ModelLinks   modelLinks   = null;
            SolidEdgeDraft.ModelLink    modelLink    = null;
            SolidEdgeDraft.DrawingViews drawingViews = null;
            SolidEdgeDraft.DrawingView  drawingView  = null;
            DirectoryInfo trainingDirectory          = GetTrainingDirectory();
            string        fileName = Path.Combine(trainingDirectory.FullName, "2holebar.par");

            SolidEdgeDraft.DVLines2d             dvLines2d  = null;
            SolidEdgeDraft.DVLine2d              dvLine2d   = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions = null;
            SolidEdgeFrameworkSupport.Dimension  dimension  = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle   = null;

            // Get a reference to the active sheet.
            sheet = draftDocument.ActiveSheet;

            // Get a reference to the ModelLinks collection.
            modelLinks = draftDocument.ModelLinks;

            // Add a new model link.
            modelLink = modelLinks.Add(fileName);

            // Get a reference to the DrawingViews collection.
            drawingViews = sheet.DrawingViews;

            // Add a new part drawing view.
            drawingView = drawingViews.AddPartView(
                From: modelLink,
                Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView,
                Scale: 5.0,
                x: 0.4,
                y: 0.4,
                ViewType: SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView);

            // Get a reference to the DVLines2d collection.
            dvLines2d = drawingView.DVLines2d;

            // Get the 1st drawing view 2D line.
            dvLine2d = dvLines2d.Item(1);

            // Get a reference to the Dimensions collection.
            dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

            // Add a dimension to the line.
            dimension = dimensions.AddLength(dvLine2d.Reference);

            // Few changes to make the dimensions look right.
            dimension.ProjectionLineDirection = true;
            dimension.TrackDistance           = 0.02;

            // Get a reference to the dimension style.
            // DimStyle has a ton of options...
            dimStyle = dimension.Style;
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application       application   = null;
            SolidEdgeFramework.Documents         documents     = null;
            SolidEdgeDraft.DraftDocument         draftDocument = null;
            SolidEdgeDraft.ModelLinks            modelLinks    = null;
            SolidEdgeDraft.ModelLink             modelLink     = null;
            SolidEdgeDraft.Sheet                 sheet         = null;
            SolidEdgeDraft.DrawingViews          drawingViews  = null;
            SolidEdgeDraft.DrawingView           drawingView   = null;
            SolidEdgeDraft.DVLines2d             dvLines2d     = null;
            SolidEdgeDraft.DVLine2d              dvLine2d      = null;
            SolidEdgeFrameworkSupport.Dimensions dimensions    = null;
            SolidEdgeFrameworkSupport.Dimension  dimension     = null;
            SolidEdgeFrameworkSupport.DimStyle   dimStyle      = null;
            string filename = 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 a reference to the documents collection.
                documents = application.Documents;

                // Create a new draft document.
                draftDocument = documents.AddDraftDocument();

                // Get a reference to the ModelLinks collection.
                modelLinks = draftDocument.ModelLinks;

                // Build path to part file.
                filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "2holebar.par");

                // Add a new model link.
                modelLink = modelLinks.Add(filename);

                // Get a reference to the active sheet.
                sheet = draftDocument.ActiveSheet;

                // Get a reference to the DrawingViews collection.
                drawingViews = sheet.DrawingViews;

                // Add a new part drawing view.
                drawingView = drawingViews.AddPartView(
                    From: modelLink,
                    Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView,
                    Scale: 5.0,
                    x: 0.4,
                    y: 0.4,
                    ViewType: SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView);

                // Get a reference to the DVLines2d collection.
                dvLines2d = drawingView.DVLines2d;

                // Get the 1st drawing view 2D line.
                dvLine2d = dvLines2d.Item(1);

                // Get a reference to the Dimensions collection.
                dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions;

                // Add a dimension to the line.
                dimension = dimensions.AddLength(dvLine2d.Reference);

                // Few changes to make the dimensions look right.
                dimension.ProjectionLineDirection = true;
                dimension.TrackDistance           = 0.02;

                // Get a reference to the dimension style.
                // DimStyle has a ton of options...
                dimStyle = dimension.Style;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }