Write/Add ProjectInformation propertie Document Number in C#

Valued Contributor
Valued Contributor

Hi,

 

I want to write a value to the propertie "Document Number" in ProjectInformation properties.

I can't get this to work the way I think it should. I knew how to do it in VB, but now that I'm writing all my programs in C#, I can't do it the same way.

 

Does anyone know how to do this? It feels like a "Should have known that"-situation.

 

Thanks in advance!

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9
2 REPLIES

Re: Write/Add ProjectInformation propertie Document Number in C#

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hello JanWillem,

you can find example code here: Github SE Samples

Generally there is no difference whether calling from vb.net or c#.

Since c# is more strict you have to do more casting (in VB set Option Strict ON).

Also in c# you have to call the getter and setter of the Property object (this is hidden in vb). 

regards

JB
VS2015, SE ST10

Re: Write/Add ProjectInformation propertie Document Number in C#

Genius
Genius

Hello Jan Willem,

 

I show in the video below how to write / read the file properties, including the Document Number.

This tutorial is in C#.

 

 

Also the code below:

 

 

class Program
    {
        [STAThread]                         // Work with file properties
        static void Main(string[] args)
        {
            // Declare your main variables
            SolidEdgeFramework.Application seApplication = null;
            SolidEdgeFramework.Documents seDocuments = null;

            // Declare your document variables
            SolidEdgePart.PartDocument sePartDoc = null;

            // Declare variables about file properties collection
            SolidEdgeFramework.PropertySets propertySets = null;

            // Declare variable about Summary Information properties
            SolidEdgeFramework.Properties propertiesSummary = null;
            SolidEdgeFramework.Property title = null;
            SolidEdgeFramework.Property subject = null;
            SolidEdgeFramework.Property author = null;
            SolidEdgeFramework.Property comments = null;

            // Declare variable about Project Information properties
            SolidEdgeFramework.Properties propertiesProject = null;
            SolidEdgeFramework.Property documentNumber = null;
            SolidEdgeFramework.Property revision = null;
            SolidEdgeFramework.Property projectName = null;

            try
            {
                // Register
                OleMessageFilter.Register();

                // Connect your Solid Edge
                seApplication = SolidEdgeUtils.Connect(true);

                // Get your Document Collection
                seDocuments = seApplication.Documents;

                // Get Active Document
                sePartDoc = (PartDocument)seApplication.ActiveDocument;

                // Get collection of Property Sets
                propertySets = (PropertySets)sePartDoc.Properties;

                // Get collection of Sumary Information properties
                propertiesSummary = propertySets.Item("SummaryInformation");

                // Get properties
                title = propertiesSummary.Item("Title");
                subject = propertiesSummary.Item("Subject");
                author = propertiesSummary.Item("Author");
                comments = propertiesSummary.Item("Comments");

                // Write the value of each property
                title.set_Value("Write here the new title");
                subject.set_Value("Write here the text to subject");
                author.set_Value("Write here the author");
                comments.set_Value("Write the comment of your part document");

                // Now, the same thing to project properties
                propertiesProject = propertySets.Item("ProjectInformation");

                // Get properties
                documentNumber = propertiesProject.Item("Document Number");
                revision = propertiesProject.Item("Revision");
                projectName = propertiesProject.Item("Project Name");

                // Define the text of each property
                documentNumber.set_Value("012345");
                revision.set_Value("A");
                projectName.set_Value("Your project name");

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                // Ungister
                OleMessageFilter.Unregister();
            }
        }
    }

 



==========================
Kabir Costa
Industrial Designer
kabircosta@gmail.com