top of page

Rise Up, Be Free

Public·18 members

Jason Hinterweger
Jason Hinterweger

Bentley Microstation Dgn 89 Object Library



Option ExplicitSub GetArrayData()'requires microsoft excel 16.0 object library reference Dim MyArray() As Variant Dim Data As Variant Dim myPath, myFile, DGNFile, NewestFile, PointText, Trackr, Tailend As String Dim c As Long, N, erCatch As Integer Dim LatestDate As Date Dim LMD As Date DGNFile = "*" & ActiveDesignFile.Path & "*" myPath = Environ$("TEMP") 'file path of xml report 'debug.print myPath If Right(myPath, 1) "\" Then myPath = myPath & "\" myFile = Dir(myPath & "*.xml", vbNormal) If Len(myFile) = 0 Then MsgBox "No files were found...", vbExclamation Exit Sub End If Do While Len(myFile) > 0 LMD = FileDateTime(myPath & myFile) 'check file for tag Open myPath & myFile For Input As #1 'Len = Len(myRecord) For N = 1 To 3 Line Input #1, Data Select Case True 'is file a station offset report? Case Data Like "*Station Offset Report*" 'check lines 1-3 for command name 'go to next line of file then Line Input #1, Data 'debug.print Data 'does file tag match dgnfile path If Data Like DGNFile Then If LMD > LatestDate Then NewestFile = myFile LatestDate = LMD End If End If End Select Next Close #1 myFile = Dir Loop If Len(NewestFile) = 0 Then MsgBox "No files were found Please Run Station Offset Report", vbExclamation Exit Sub End If Open myPath & NewestFile For Input As #1 erCatch = 0 c = 1 Do Until EOF(1) Line Input #1, Data Select Case True 'use trackr to find values to pass to array Case Data Like "*




Bentley Microstation Dgn 89 Object Library



I wonder, before you came to this solution or since then, have you looked at using the Microsoft XML object library? I feel like that might be a lot smoother and more scalable. I'll be checking it out myself when I have the time.


I'd be interested to know what variables were renamed its sometimes hard to see a different perspective when coding but i like to be flexible. On the microsoft xml object library i did consider it but i was attempting to avoid using object libraries that aren't the default because i dont like hard coding a library to load as it may be outdated eventually. but if you do manage to get the XML code working i'd love to see it.


Sub GetArrayData() 'processes information from report XML'requires microsoft excel 16.0 object library referenceDim SetOfRecords() As Variant 'might be better as a collectionDim Record As Variant Dim LineOfXmlFile As Variant Dim PathToXmlFolder, NamesOfXmlFiles, PathToDgnFile, NameOfLatestXmlWithCommand, XmlCodeOfInterest, RemainderOfXmlLine As String Dim ProcessPointBecauseInOLP As Boolean Dim iRecord As Long, iLineOfXml, identifierFailureMode As Integer Dim DateOfLatestXmlFile As Date Dim DateOfThisXmlFile As Date 'TODO: Chunk out these processes, for pete's sake!'PathToLatestXmlFile = GetLatestXmlFile(Environ$("TEMP"), "*Station Offset Report*") 'both arguments should be optional'Set Records = MineXmlFileForOffsetLinePoint(PathToLatestXmlFile) 'maybe there could be a way to generalize this for which attributes (and whose) to collect'Tabulate RecordsPathToDgnFile = "*" & ActiveDesignFile.Path & "*" PathToXmlFolder = Environ$("TEMP") 'file path of xml report If Right(PathToXmlFolder, 1) "\" Then PathToXmlFolder = PathToXmlFolder & "\" Debug.Print PathToXmlFolder NamesOfXmlFiles = Dir(PathToXmlFolder & "*.xml", vbNormal) Debug.Print NamesOfXmlFiles If Len(NamesOfXmlFiles) = 0 Then MsgBox "No XML was found.", vbExclamation Exit Sub End If Do While Len(NamesOfXmlFiles) > 0 DateOfThisXmlFile = FileDateTime(PathToXmlFolder & NamesOfXmlFiles) Debug.Print DateOfThisXmlFile 'check file for tag Open PathToXmlFolder & NamesOfXmlFiles For Input As #1 For iLineOfXml = 1 To 3 'Debug.Print iLineOfXml Line Input #1, LineOfXmlFile Debug.Print iLineOfXml & vbTab & LineOfXmlFile If LineOfXmlFile Like "*Station Offset Report*" Then 'go to next line of file then 'Line Input #1, LineOfXmlFile 'debug.print LineOfXmlFile 'does file tag match PathToDgnFile path If DateOfThisXmlFile > DateOfLatestXmlFile Then NameOfLatestXmlWithCommand = NamesOfXmlFiles DateOfLatestXmlFile = DateOfThisXmlFile End If End If Next Close #1 NamesOfXmlFiles = Dir Loop If Len(NameOfLatestXmlWithCommand) = 0 Then Debug.Print "No files were found Please Run Station Offset Report", vbExclamation Exit Sub End If Open PathToXmlFolder & NameOfLatestXmlWithCommand For Input As #1 identifierFailureMode = 0 iRecord = 1 Do Until EOF(1) Line Input #1, LineOfXmlFile Select Case True 'use ProcessPointBecauseInOLP to find values to pass to array Case LineOfXmlFile Like "*


About

Welcome to the group! You can connect with other members, ge...

Members

bottom of page