Having a problem with Geopak GetJobNumbersWithinAcdtiveDir

I have one VBA that will not find the gpk file. Using the same code that works on the other VBA. Below is the code from the example which is used to check. The result returns the path/jobjob104.gpk

 Dim jobNums()   As String
    Dim count       As Integer
    Dim myCogo      As Cogo

    'Array of Job Numbers
    jobNums() = GetJobNumbersWithinActiveDir()

    For count = LBound(jobNums) To UBound(jobNums)
        'Get the first Job Number in the array
        If 0 = count Then
            'Set the active Job Number
            Set myCogo = OpenCogoByJobNumber(104)
            'Set myCogo = OpenCogoByJobNumber(jobNums(count))

            If (myCogo Is Nothing) Then
                MsgBox "error reading job: " & jobNums(count)
            Else
                MsgBox myCogo.FullFileName
            End If

        End If

    Next count

Parents Reply
  • Hi Larry,

    could you please execute this code below and send us the output of the debug statements - thank you in advance.

    Artur



    Option Explicit Sub COGO_SetActiveJobNumber() Dim jobNums() As String Dim count As Integer Dim myCogo As Cogo 'Array of Job Numbers jobNums() = GetJobNumbersWithinActiveDir() For count = LBound(jobNums) To UBound(jobNums) 'Get the first Job Number in the array If 0 = count Then 'Set the active Job Number Set myCogo = OpenCogoByJobNumber(104) ' Set myCogo = OpenCogoByJobNumber(jobNums(count)) ' Geopak GPK active dir location logic: Dim arrCfgVars() As Variant Dim cfg As Variant arrCfgVars = Array("GPK_JOBDIR", "GPK_CWD", "_DGNFILE") For Each cfg In arrCfgVars If (ActiveWorkspace.IsConfigurationVariableDefined(cfg)) Then Debug.Print cfg & ": " & ActiveWorkspace.ConfigurationVariableValue(cfg, True) Else Debug.Print cfg & ": " & "NOT DEFINED" End If Next Debug.Print "Cogo.FullFileName: " & myCogo.FullFileName If (myCogo Is Nothing) Then MsgBox "error reading job: " & jobNums(count) Else MsgBox myCogo.FullFileName End If End If Next count End Sub

Children
  • Artur,
    here is the results

    GPK_JOBDIR: Q:\City of Trotwood\0106104A.00 - MOT-Wolf Creek Pike Improv\88223\geopak\
    GPK_CWD: Q:\City of Trotwood\0106104A.00 - MOT-Wolf Creek Pike Improv\88223\geopak
    _DGNFILE: Q:\City of Trotwood\0106104A.00 - MOT-Wolf Creek Pike Improv\88223\row\sheets\88223RB016.dgn
    Cogo.FullFileName: Q:\City of Trotwood\0106104A.00 - MOT-Wolf Creek Pike Improv\88223\geopak\\jobjob104.gpk

    Larry Wilson
    LWilson@LJBinc.com
     

  • Hi Larry,
    as a result of this test we can assume that the .gpk file is found.
    In the following the value ...\\jobjob104.gpk for Cogo.FullFileName is not necessary a problem.

    In your next code block after finding and selecting the active job, which problems occur?
    Do you receive any error message or what indicator for a problem do you receive?

    The drive Q: let us assume the project is placed on a network drive.
    Do you also experience this problem with local files?

    Could you also provide us a complete testcase?

    Best regards,
    Artur

  • Arthur,
    This is the next part of the code. I'm just looking for the parcels in the code. Just for your information, when I hard code the gpk evertything works fine.

    'next part of sub
    If cboJobs.ListCount > 0 Then
    ' Set the Job combo to the first in the list
    cboJobs.ListIndex = 0
    End If
    Dim par As Variant



    For Each par In ActiveCogo.GetElementNamesByType(gpkCogoTypeParcel)
    Dim oneChar As String
    oneChar = Mid(par, 1, 1)

    If IsNumeric(oneChar) Then
    cbParcel.AddItem par
    GetSubName (par)


    Else

    End If

    Next par

    'Hard coded sub and works


    For count = LBound(jobNums) To UBound(jobNums)
    'Get the first Job Number in the array
    If 0 = count Then
    'Set the active Job Number

    'hardcode for trotwood
    Set myCogo = OpenCogoByJobNumber(104)

    If (myCogo Is Nothing) Then
    MsgBox "error reading job: " & jobNums(count)
    Else
    MsgBox myCogo.FullFileName
    End If

    End If

    Next count

    Larry Wilson
    LWilson@LJBinc.com
     

  • Hi Larry,

    did you check, how many and which jobs are listed in the .gpk file? Maybe in Pos 0 is not the jonb in question.
    Please run this subroutine below and let us know the results of the debug.print statements - thanks

    Artur

    Sub whichJobsareIn()
        Dim jobNums()   As String
        Dim i As Integer
        
        jobNums() = GetJobNumbersWithinActiveDir()
        For i = LBound(jobNums) To UBound(jobNums)
            Debug.Print "Jobnumber: " & i & ", " & jobNums(i)
        Next i
    End Sub
    

  • Artur,
    Here is your results, Jobnumber: 0, 104. There is only one gpk file in the directory.

    Larry Wilson
    LWilson@LJBinc.com