Re: SetCustomProperty Question

Good afternoon,

When setting custom properties in a DGN (using SetCustomProperty), What is the maximum length a string could be?

Thank you.

Parents
  • For SetCustomProperty, I see no practical limits imposed on the length when modifying a Microsoft's FMTID_UserDefinedProperties PROPVARIANT VT_LPWSTR using Microsoft's IPropertySetStorage API.

    The MicroStation COM GetCustomProperty implementation however currently returns a maximum of 512 wide characters.  If that is a limitation you need to work-around you could either call the MDL function dgnFileObj_getDocumentProperty, or Microsoft's IPropertySetStorage; both which do not have that limitation.  Although the Bentley API is preferred for performing these types of modifications when the file could be the active file, Microsoft does provide Visual C based source code examples (Samples and KB186898) showing how to work with Microsoft Compound Document file metadata.

    What type of information are you trying to store and at what times do you wish/need to access it?  There may be better or different ways to accomplish the task if you could provide some more of the input/output requirements.

    Bob



  • Information to be stored relates to workspace name, user name, date/time of DNG access. Data/string gets accessed at opening and closing the DGN. At this office we deal with at least 5 different workspaces. At the moment we have a macro in place that keeps track of workspace used for a specific DGN, also a macro that attemps to make sure our users have read the standards for specific workspaces and are aware of budget and deadlines.  The former macro uses custom properties while the latter relies on a file stored in the same folder as the DGN. We would like to have everything stored in the DGN. Most times our DGN files are opened by several users from different departments and branches in our company, therefore we need to know the max we can read/write to custom properties.

    If you think education is expensive, try ignorance

  • A single "Workspaces" property should suffice if you were to store a unique/distinct list of workspaces < 512 characters in length during design file open events so you can conveniently use GetCustomProperty.

    Depending on the programming language, you could read/write the string in a comma seperated values (CSV) format and use a dictionary object to ensure that the list is unique.

    I would recommend not trying to perform any "heavy lifting" tasks/updates on design file during close or exit events since some functionality you may require may have already been unloaded, or your app may experience other unexpected side-effects potentially due to: network (delays, permissions, or timing), or if a poorly written application that may have already destabilized the environment and be closing due to the app's exception/crash.

    HTH,

    Bob



    Answer Verified By: ricrenteria 

Reply
  • A single "Workspaces" property should suffice if you were to store a unique/distinct list of workspaces < 512 characters in length during design file open events so you can conveniently use GetCustomProperty.

    Depending on the programming language, you could read/write the string in a comma seperated values (CSV) format and use a dictionary object to ensure that the list is unique.

    I would recommend not trying to perform any "heavy lifting" tasks/updates on design file during close or exit events since some functionality you may require may have already been unloaded, or your app may experience other unexpected side-effects potentially due to: network (delays, permissions, or timing), or if a poorly written application that may have already destabilized the environment and be closing due to the app's exception/crash.

    HTH,

    Bob



    Answer Verified By: ricrenteria 

Children