Does the MicroStation API offer a method to retrieve the last modified date and the username for each element?how I can retrieve this data?
Hi Ivan,
Ivan Petrov said:Does the MicroStation API offer a method to retrieve the last modified date and the username for each element?
at first it should be checked, whether MicroStation itself, provides such information. When it is not available in GUI, it's likely not available in API too.
Ivan Petrov said:the last modified date
"Last modified" is information available in element properties. I think there is no special API available to obtain this information, but it is possible to get it from EC element properties data representation (GetElementProperties method in DgnECManager class).
Ivan Petrov said:and the username for each element?
Can you share where such information is available in MicroStation? DGN V8 format does not allow to store information about who modified specific element.
The only information I know about is who saved the file as the last user, which is DGN file properties. I am not sure whether the is method to get this information, or (again), EC representation should be used.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan Šlegr thanks for your answers.1.
Jan Šlegr said:"Last modified" is information available in element properties
My example file provides this in an extended section of element properties. It seems that the approach you suggested might work. thanks2.
Jan Šlegr said:Can you share where such information is available in MicroStation?
my guess was that it exists, but it looks like it doesn't. I hoped because it would be very useful when the team works.
Ivan Petrov said:but it looks like it doesn't.
Well, MicroStation (and DGN format) is neither database nor DMS/CMS ;-)
Ivan Petrov said:I hoped because it would be very useful when the team works.
A granularity of access to elements has been discussed many times. But my experience is that pros and cons (plus necessary complexity of such system) is against to track everything.
The most detail level can be DGN design history feature, when an author of commits is recorded. It does not mean such author did all changes, but at least he approved (take ownership) of them.
In the end, I'm using another function.
var historicalElementProperties = DgnECManager.Manager.GetHistoricalElementProperties(instance.Element); foreach (var elementInstance in historicalElementProperties) { var modifiedTimeString = elementInstance.FirstOrDefault(_ => _.AccessString == "ModifiedTime")?.StringValue; }
And what is the reason you specifically this method and not "standard" GetElementProperties?
The "historical properties" are used in relation to Design History I mentioned in my previous answer.
Regards,
Not using the latest API classes but this works (last modified time is in the element header):
mdlElmdscr_read(&edP, *lP, modelRef, FALSE, NULL); double modified = edP->el.ehdr.lastModified; long long modtime = (long long)(modified/1000); struct tm *thistime; thistime = localtime(&modtime); swprintf(szBufferW, L"%4d-%02d-%02d %02d:%02d", thistime->tm_year+1900, thistime->tm_mon+1, thistime->tm_mday, thistime->tm_hour, thistime->tm_min); Msg(szBufferW); // 2023-01-30 15:47