Solid Edge Design Manager Object Library
GetFileAndPropertyDataFromGrid Method
DesignManager ActiveX DLL > Application Object : GetFileAndPropertyDataFromGrid Method
Returns an array conataining propertyname and its values.
Description
Gets the property information for given file from Design Manager grid.
Syntax
Visual Basic
Public Function GetFileAndPropertyDataFromGrid( _
   ByRef pVarListFileInfoAndProperties As Variant _
) As Long
Parameters
pVarListFileInfoAndProperties
Returns an array conataining propertyname and its values.
Example
Imports System.Runtime.InteropServices

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objApp As DesignManager.Application = Nothing
        Dim objDoc As DesignManager.Document = Nothing

        Dim strAsmPath As String = "C:\SEWork\00000055_A.asm"
        Dim strNewPath As String = "C:\SEWork\Newfolder\Revise"

        Try
            'to connect to a running instance of Design Manager 
            Try
                objApp = Marshal.GetActiveObject("DesignManager.Application")
                objApp.DisplayAlerts = False
                objApp.Visible = True

            Catch ex1 As System.Exception

                'SE not running then start it
                Try
                    objApp = Activator.CreateInstance(Type.GetTypeFromProgID("DesignManager.Application"))
                    objApp.DisplayAlerts = False
                    objApp.Visible = True

                Catch ex2 As Exception
                    If objApp Is Nothing Then
                        MessageBox.Show("Error starting the DesignManager Manager Application. The error is " + ex1.Message, "Error starting RevMgr.exe", MessageBoxButtons.OK)
                    End If
                End Try
            End Try

            'Open Assembly file in Design Manager
            objDoc = objApp.OpenFileInDesignManager(strAsmPath)
            Dim nAction As DesignManager.DesignManagerAction = DesignManager.DesignManagerAction.SaveAsAction
            Dim hr As Integer = objApp.SetActionForAllFiles(nAction, strNewPath)
            Dim fileData As Object = Nothing

            Dim m_FileNametoPropsMap As Dictionary(Of String, Object) = New Dictionary(Of String, Object)


            objApp.GetFileAndPropertyDataFromGrid(fileData)



            Dim numofFiles = fileData.GetLength(0)
            Dim propInfo1(,) As Object = Nothing
            Dim FilesNames(numofFiles - 1) As Object

            Dim ii As Integer
            If fileData IsNot Nothing Then

                For ii = 0 To numofFiles - 1
                    FilesNames(ii) = fileData(ii, 0)
                    m_FileNametoPropsMap.Add(fileData(ii, 0), fileData(ii, 1))
                Next
            End If

            Dim DocNumincrementor As Integer = 1
            Dim RevNumincrementor As Integer = 1
            'Dim dt1 As DateTime = Now
            For Each elemDoc In m_FileNametoPropsMap

                Dim nPropertiesCount As Integer = elemDoc.Value.GetLength(0)
                ReDim propInfo1(nPropertiesCount - 1, 1)

                For ii = 0 To nPropertiesCount - 1

                    If String.Equals(elemDoc.Value(ii, 0), "Document Number") Then
                        propInfo1(ii, 0) = elemDoc.Value(ii, 0) 'Prop Name
                        propInfo1(ii, 1) = "CX-ZZ-00300_" + DocNumincrementor.ToString()
                        DocNumincrementor = DocNumincrementor + 1
                    End If
                    If String.Equals(elemDoc.Value(ii, 0), "Revision Number") Then
                        propInfo1(ii, 0) = elemDoc.Value(ii, 0) 'Prop Name
                        propInfo1(ii, 1) = "R" + RevNumincrementor.ToString()
                        RevNumincrementor = RevNumincrementor + 1
                    End If

                Next
                objApp.SetFilePropertyDataToGrid(elemDoc.Key, (propInfo1))
                objApp.PerformAction()
                Exit For
            Next

        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            objDoc.Close()

            objDoc = Nothing
            objApp.Quit()
            objApp = Nothing
        End Try
    End Sub
End Class
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class Form1
{
    private void Button1_Click(object sender, EventArgs e)
    {
        DesignManager.Application objApp = null;
        DesignManager.Document objDoc = null;

        string strAsmPath = "C:\\SEWork\\00000055_A.asm";
        string strNewPath = "C:\\SEWork\\Newfolder\\Revise";

        try
        {
            //to connect to a running instance of Design Manager 
            try
            {
                objApp = (DesignManager.Application)Marshal.GetActiveObject("DesignManager.Application");
                objApp.DisplayAlerts = false;
                objApp.Visible = true;

            }
            catch (System.Exception ex1)
            {

                //SE not running then start it
                try
                {
                    objApp = Activator.CreateInstance(Type.GetTypeFromProgID("DesignManager.Application"));
                    objApp.DisplayAlerts = false;
                    objApp.Visible = true;

                }
                catch (Exception ex2)
                {
                    if (objApp == null)
                    {
                        MessageBox.Show("Error starting the DesignManager Manager Application. The error is " + ex1.Message, "Error starting RevMgr.exe", MessageBoxButtons.OK);
                    }
                }
            }

            //Open Assembly file in Design Manager
            objDoc = objApp.OpenFileInDesignManager(strAsmPath);
            DesignManager.DesignManagerAction nAction = DesignManager.DesignManagerAction.SaveAsAction;
            int hr = objApp.SetActionForAllFiles(nAction, strNewPath);
            dynamic fileData = null;

            Dictionary<string, object> m_FileNametoPropsMap = new Dictionary<string, object>();


            objApp.GetFileAndPropertyDataFromGrid(fileData);



            object numofFiles = fileData.GetLength(0);
            object[,] propInfo1 = null;
            object[] FilesNames = new object[numofFiles];

            int ii = 0;
            if (fileData != null)
            {

                for (ii = 0; ii < Convert.ToInt32(numofFiles); ii++)
                {
                    FilesNames[ii] = fileData(ii, 0);
                    m_FileNametoPropsMap.Add(fileData(ii, 0), fileData(ii, 1));
                }
            }

            int DocNumincrementor = 1;
            int RevNumincrementor = 1;
            //Dim dt1 As DateTime = Now
            foreach (var elemDoc in m_FileNametoPropsMap)
            {

                int nPropertiesCount = elemDoc.Value.GetLength(0);
                propInfo1 = new object[nPropertiesCount, 2];

                for (ii = 0; ii < nPropertiesCount; ii++)
                {

                    if (string.Equals(elemDoc.Value(ii, 0), "Document Number"))
                    {
                        propInfo1[ii, 0] = elemDoc.Value(ii, 0); //Prop Name
                        propInfo1[ii, 1] = "CX-ZZ-00300_" + DocNumincrementor.ToString();
                        DocNumincrementor = DocNumincrementor + 1;
                    }
                    if (string.Equals(elemDoc.Value(ii, 0), "Revision Number"))
                    {
                        propInfo1[ii, 0] = elemDoc.Value(ii, 0); //Prop Name
                        propInfo1[ii, 1] = "R" + RevNumincrementor.ToString();
                        RevNumincrementor = RevNumincrementor + 1;
                    }

                }
                objApp.SetFilePropertyDataToGrid(elemDoc.Key, (propInfo1));
                objApp.PerformAction();
                break;
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        finally
        {
            objDoc.Close();

            objDoc = null;
            objApp.Quit();
            objApp = null;
        }
    }

    public Form1()
    {
        SubscribeToEvents();
    }


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

        Button1.Click += Button1_Click;
        Button1.Click += Button1_Click;
    }

}
See Also

Application Object  | Application Members