﻿using System.IO;
using System.Runtime.InteropServices;

internal static class Example
{
    [STAThread()]
    public static void Main()
    {

        SolidEdgeFramework.Application objApplication = null;
        SolidEdgeDraft.DraftDocument objDraftDocument = null;
        SolidEdgeDraft.Sheet objSheet = null;
        SolidEdgeFrameworkSupport.Line2d objLine2d = null;
        SolidEdgeFrameworkSupport.WeldSymbols objWeldSymbols = null;
        SolidEdgeFrameworkSupport.WeldSymbol objWeldSymbol = null;
        SolidEdgeFrameworkSupport.DimensionStyles objDimensionStyles = null;
        SolidEdgeFrameworkSupport.DimensionStyle objDimensionStyle = null;
        SolidEdgeFrameworkSupport.DimStyle objDimStyle = null;

        try
        {
            OleMessageFilter.Register();

            objApplication = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
            objDraftDocument = objApplication.ActiveDocument;
            objSheet = objDraftDocument.ActiveSheet;

            //Draw line
            objLine2d = objSheet.Lines2d.AddBy2Points(x1:0.1, y1:0.1, x2:0.3, y2:0.1);

            objWeldSymbols = objSheet.WeldSymbols; //Weld Symbol object

            //Add weld symbol
            objWeldSymbol = objWeldSymbols.AddByTerminator(objLine2d, 0.125, 0.1, 0, false);
            objWeldSymbol.TextScale = 3;

            objWeldSymbol.TopNote1 = "Top Note"; //Add top note
            objWeldSymbol.AddVertex(x:0.2, y:0.2, z:0); //Add vertex
            objWeldSymbol.BreakLine = true;

            objWeldSymbol.TopType = SolidEdgeFrameworkSupport.DimWeldTypeConstants.igDimWeldTopFillet;

            //Set top weld modifier as top three sided weld
            objWeldSymbol.TopWeldModifier = SolidEdgeFrameworkSupport.DimWeldModifierConstants.igDimWeldTopThreeSided;

            //Set bottom weld modifier as bottom three sided weld         
            objWeldSymbol.BottomWeldModifier = SolidEdgeFrameworkSupport.DimWeldModifierConstants.igDimWeldBottomThreeSided;

            //Create a dimension style object
            objDimensionStyles = objDraftDocument.DimensionStyles;
            objDimensionStyle = objDimensionStyles(1);

            //Offset gap for Three Sided Weld Symbol
            objDimensionStyle.ThreeSidedSymbolOffsetGap = 2.0;

            //Create a dimension style object for weld symbol
            objDimStyle = objWeldSymbol.Style;

            //Offset gap for Three Sided Weld Symbol
            objDimStyle.ThreeSidedSymbolOffsetGap = 2.0;

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            OleMessageFilter.Revoke();
        }
    }
}