none
How to quickly copy timephased data from pjAssignmentTimescaledBaseline1Work to pjAssignmentTimescaledWork RRS feed

  • Question

  • Hi,

    I have written the following macro to copy timephased data from pjAssignmentTimescaledBaseline1Work to pjAssignmentTimescaledWork However, it results being very slow so I am looking whether a faster way exists.

    I know that I could you use coarser unit than minutes but then I would loose accuracy in the copy.


    Private Sub copyTimePhasedDataSameAssignment(ByRef a As Assignment)
    Dim tsvs_from As TimeScaleValues
    Dim tsvs_to As TimeScaleValues


    Set tsvs_from = a.TimeScaleData(a.baseline1Start, a.baseline1Finish, pjAssignmentTimescaledBaseline1Work , pjTimescaleMinutes)
    Set tsvs_to = a.TimeScaleData(a.baseline1Start, a.baseline1Finish, pjAssignmentTimescaledWork , pjTimescaleMinutes)


    On Error Resume Next
    For i = 1 To tsvs_from.Count
        tsvs_to(i).Value = tsvs_from(i).Value
    Next i
    End Sub




    Thursday, January 5, 2017 3:05 AM

All replies

  • Roberto,

    What is the time period? Just how long does it take?

    For reference, you won't lose any accuracy by using hours instead of minutes. Internally Project stores all time related data in minutes anyway.

    John

    Thursday, January 5, 2017 2:17 PM
  • Hi John,

    The time period is 3 days and it takes around 5 seconds.

    Here is an example of how you can loose accuracy if you use hours instead of minutes.
    If between 8:00am and 9:00am I have worked only between 8:00am and 8:15am and I use hours instead of minutes then the destination timephased data will have the 15minutes spread across the entire hour rather than between 8:00 and 8:15 only.

    Roberto

    Thursday, January 5, 2017 10:29 PM
  • Roberto,

    If you really need to track down to the minute, then yes, it's going to take longer. Except for a few isolated cases tracking work in hours is the standard.

    However, using your 3 day example, I don't get anywhere near 5 seconds of run time. I set up a simple file with a 3 day task and one resource. I set baseline 2 and then ran the following code. Note I use a different structure to work around non-working time values (it runs faster). The screen shot below shows the run time (3 successive runs)

    John

    Sub testtimescale()
    Dim tsv As TimeScaleValue
    Dim tsvs_from As TimeScaleValues
    Dim tsvs_to As TimeScaleValues
    Dim a As Assignment
    Dim t As Single
    Set a = ActiveProject.Tasks(1).Assignments(1)
    Set tsvs_to = a.TimeScaleData(a.Start, a.Finish, pjAssignmentTimescaledWork, pjTimescaleMinutes)
    Set tsvs_from = a.TimeScaleData(a.Baseline2Start, a.Baseline2Finish, pjAssignmentTimescaledBaseline2Work, pjTimescaleMinutes)
    t = Timer
    For i = 1 To tsvs_from.Count
        If Not tsvs_from(i).Value = "" Then
            tsvs_to(i).Value = tsvs_from(i).Value
        End If
    Next i
    Debug.Print "Runtime: " & Timer - t & " secs;" & " Total i count: " & i
    End Sub

    Saturday, January 7, 2017 2:06 AM