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

    private void Button1_Click(object sender, EventArgs e)
    {
        SolidEdgeFramework.Application objApp = null;
        SolidEdgeDraft.DraftDocument objDoc = null;
        SolidEdgeDraft.DraftFilePreferences objFilePrefs = null;
        string objCOMBlockName = null;
        string objCSBlockName = null;
        try
        {
            objApp = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
            objDoc = objApp.ActiveDocument();
            objFilePrefs = objDoc.FilePreferences();

            objCOMBlockName = objFilePrefs.CenterOfMassBlockName();
            objCSBlockName = objFilePrefs.CoordinateSystemBlockName();

            objFilePrefs.CenterOfMassBlockName() = "Center of Mass";
            objFilePrefs.CoordinateSystemBlockName() = "Coordinate System";
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

    public Form1()
    {
    	SubscribeToEvents();
    }

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

		Button1.Click += Button1_Click;
	}

}