[CONNECT C#] how to change a dgn file properties (title, comments)

Trying to figure out how to update a dgnfile's title and comments. I'm talking about the extended file properties. See image below. you get to this by going to the backstage and selecting properties.

this was really easy to do in VBA. it was simply ActiveDesignFile.Title and ActiveDesignfile.Comments.

but trying to use the DGNPlatform NET I cant seem find it.

I have the this so far...been searching the help doc for a while now.

BD.DgnDocument dgndoc = BD.DgnDocument.CreateForLocalFile(fullpath);
BD.DgnFileOwner newfileowner = BD.DgnFile.Create(dgndoc,BD.DgnFileOpenMode.ReadWrite);
BD.DgnFile newfile = newfileowner.DgnFile;
BD.StatusInt openstatus;
newfile.LoadDgnFile(out openstatus);

Parents
  • got this from Artur Goldsweer from Bentley Support. He said to get it from the EC data.

    here is some code sample he gave me.

                                using BD = Bentley.DgnPlatformNET;
                                ----------------------------------------
                                
                                BD.DgnEC.DgnECManager dgnECManager = BD.DgnEC.DgnECManager.Manager;
                                BD.DgnEC.DgnECInstanceCollection ecInstances = dgnECManager.GetFileProperties(curfile, BD.DgnEC.ECQueryProcessFlags.SearchAllClasses);
    
                                BD.DgnEC.IDgnECInstance queriedLevelInstance = null;
                                foreach (BD.DgnEC.IDgnECInstance foundInstance in ecInstances)
                                {
                                    queriedLevelInstance = foundInstance as BD.DgnEC.IDgnECInstance;
                                    if ("DgnFileProperties" == queriedLevelInstance.ClassDefinition.Name)
                                    {
                                        Console.WriteLine("Class name: " + queriedLevelInstance.ClassDefinition.Name);
                                        Console.WriteLine("Comments old: " + queriedLevelInstance.GetAsString("Comments"));
                                        Console.WriteLine("Title old: " + queriedLevelInstance.GetAsString("Title"));
                                        queriedLevelInstance.SetAsString("Comments", "Another Comment");
                                        queriedLevelInstance.SetAsString("Title", "Another Title");
                                        queriedLevelInstance.WriteChanges();
                                        break;
                                    }
                                }

    Answer Verified By: John Drsek 

Reply
  • got this from Artur Goldsweer from Bentley Support. He said to get it from the EC data.

    here is some code sample he gave me.

                                using BD = Bentley.DgnPlatformNET;
                                ----------------------------------------
                                
                                BD.DgnEC.DgnECManager dgnECManager = BD.DgnEC.DgnECManager.Manager;
                                BD.DgnEC.DgnECInstanceCollection ecInstances = dgnECManager.GetFileProperties(curfile, BD.DgnEC.ECQueryProcessFlags.SearchAllClasses);
    
                                BD.DgnEC.IDgnECInstance queriedLevelInstance = null;
                                foreach (BD.DgnEC.IDgnECInstance foundInstance in ecInstances)
                                {
                                    queriedLevelInstance = foundInstance as BD.DgnEC.IDgnECInstance;
                                    if ("DgnFileProperties" == queriedLevelInstance.ClassDefinition.Name)
                                    {
                                        Console.WriteLine("Class name: " + queriedLevelInstance.ClassDefinition.Name);
                                        Console.WriteLine("Comments old: " + queriedLevelInstance.GetAsString("Comments"));
                                        Console.WriteLine("Title old: " + queriedLevelInstance.GetAsString("Title"));
                                        queriedLevelInstance.SetAsString("Comments", "Another Comment");
                                        queriedLevelInstance.SetAsString("Title", "Another Title");
                                        queriedLevelInstance.WriteChanges();
                                        break;
                                    }
                                }

    Answer Verified By: John Drsek 

Children
No Data