﻿using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Add
{

    private void Button1_Click(object sender, EventArgs e)
    {
        SolidEdgeFramework.Application objApplication = null;
        SolidEdgePart.SheetMetalDocument objDoc = null;
        SolidEdgeGeometry.Edges objEdges = null;
        object objTargetBody = null;
        object[] objToolBodies = new object[1];
        SolidEdgePart.EmbossFeatures objEmbossFeatures = null;
        SolidEdgePart.EmbossFeature objEmbossFeature = null;
        dynamic objModel = null;
        Type objType = null;

        object[] objFeatureSetToolBodies = new object[2];
        object[] objFeatureToolBodies = new object[2];
        object[] objFeatureGetToolBodies = new object[2];

        try
        {
            // Create/get the application with specific settings
            objApplication = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");

            if (objApplication == null)
            {
                // Get the type from the Solid Edge ProgID
                objType = Type.GetTypeFromProgID("SolidEdge.Application");
                // Start Solid Edge
                objApplication = Activator.CreateInstance(objType);
                // Make Solid Edge visible
                objApplication.Visible = true;
            }
            // Get the active document.
            objDoc = objApplication.ActiveDocument();


            //Creation API:-
            objModel = objDoc.Models.Item(1);
            objTargetBody = objModel.Body();
            objToolBodies[0] = objDoc.Models.Item(2).Body();

            objEmbossFeatures = objModel.EmbossFeatures;
            if (objEmbossFeatures == null)
            {
                MessageBox.Show("Failed to get the EmbossFeatures collection");

            }

            objEmbossFeature = objEmbossFeatures.Add(objTargetBody, 1, objToolBodies, true, true, 0.001, 0.005, SolidEdgePart.FeaturePropertyConstants.igAddRound, SolidEdgePart.FeaturePropertyConstants.igCornerRound, 0.002, 0.003);
            if (objEmbossFeature == null)
            {
                MessageBox.Show("Failed to Add Emboss Feature");
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            Clipboard.SetText(ex.ToString());
        }
    }



    public Add()
    {
    	SubscribeToEvents();
    }

	private bool EventsSubscribed = false;
	private void SubscribeToEvents()
	{
		if (EventsSubscribed)
			return;
		else
			EventsSubscribed = true;

		Button1.Click += Button1_Click;
	}

}