C# Help Examples for Drawing Views

Here is another section of VBA procedures from the help file converted to C#. These examples are related to drawing views. There was one example that already had a C# version.   

image

You can find details about how the C# projects can be used in this post. This project has the following functions:

 Download InventorHelpExamples_Drawing_Views

CreateBreakoperationInDrawingView
ModifyDrawingSketchEntityProperties
DrawingSketchFill
CreateDrawingSketchInView
AddBaseViewWithRepresentations
AddFlatPatternDrawingView
CreateDetailView
CreateDraftView
Layer
BreakAlignment
AddUsingSheetFormat

Here is CreateBreakoperationInDrawingView

//Creation of a break operation in a drawing view 
//Demonstrates the creation of a break operation.
//Before running this sample, select a drawing 
//view in the active drawing.
public void CreateBreakoperationInDrawingView()
{
    // Set a reference to the drawing document.
    // This assumes a drawing document is active.
    DrawingDocument oDrawDoc =
(DrawingDocument)ThisApplication.ActiveDocument;
 
    //Set a reference to the active sheet.
    Sheet oSheet = (Sheet)oDrawDoc.ActiveSheet;
 
 
    DrawingView oDrawingView = default(DrawingView);
    // Check to make sure a drawing view is selected.
    try
    {
        // Set a reference to the selected drawing.
        // This assumes that the selected view is
        // not a draft view.
        oDrawingView =
                 (DrawingView)oDrawDoc.SelectSet[1];
    }
    catch
    {
        MessageBox.Show
            ("A drawing view must be selected.");
        return;
    }
 
 
    // Set a reference to the 
    //center of the base view.
    Point2d oCenter =
              (Point2d)oDrawingView.Center;
 
    // Define the start point of the break
    Point2d oStartPoint = ThisApplication.
        TransientGeometry.
        CreatePoint2d(oCenter.X - 1, oCenter.Y);
 
    // Define the end point of the break
    Point2d oEndPoint = default(Point2d);
    oEndPoint = ThisApplication.TransientGeometry.
         CreatePoint2d(oCenter.X + 1, oCenter.Y);
 
    BreakOperation oBreakOperation =
                        default(BreakOperation);
 
    oBreakOperation = oDrawingView.
                           BreakOperations.Add
(BreakOrientationEnum.kHorizontalBreakOrientation,
             oStartPoint, oEndPoint,
         BreakStyleEnum.kRectangularBreakStyle, 5);
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading