DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Automated curve shape settings modification with script

Hello all,

 

I am new to Diadem scripting. I am trying to achieve the following but it does not work so any help is appreciated.

 

Boundary conditions:

  1. Existing report with 100+ pages.
  2. Each report page has multiple graphs with several curves

 

What I want to do:

  1. Run through all report pages (script seems to work)
  2. Run through all graphs on each report page (script seems to work)
  3. Run through all curves in each graph for further modification of the curve shape settings. Here the script is not working. I did a lot of try & error but did not find any solution. 

 

My code:

Dim k,m
Dim oMyReportObj, oMyReportObjects, oMy2DLine

'Run through all report pages (seems to work)
For k=1 to Report.Sheets.Count
    Report.Sheets(k).Activate
    Set oMyReportObjects = Report.ActiveSheet.Objects

    'Run through all 2D axis systems on the currently activated report page (seems to work)
    For Each oMyReportObj in oMyReportObjects
      If oMyReportObj.ObjectType = eReportObject2DAxisSystem Then

        'Run through all curves in one 2D axis system to change the curve shape settings if necessary (not working)
        For m = 1 to oMyReportObj.Curves2D.Count
          Set oMy2DLine = oMy2DAxisSystem.Curves2D(m) 'not working
    
        'I also did some try and error with this one but also not working
        For Each oMy2DLine in oMyReportObj
          If oMy2DLine.ObjectType = e2DShapeLine Then       

          'Curve shape settings modification example (seems to work)
          If oMy2DLine.Shape.Settings.Line.Color.ColorIndex = eColorIndexDarkRed  Then
            oMy2DLine.Shape.Settings.Line.Color.ColorIndex = eColorIndexBlack
          End If

        Next
      End If
    Next
Next

Call Report.Refresh()

 

0 Kudos
Message 1 of 3
(1,283 Views)

Hello Max,

 

if you loops over the curves collection you have to use the collections name: oMyReportObj.Curves2D. I have adjusted the script so that it now runs. Now it changes the dark red curve color into black in all axis systems. I have added a comment to the lines of code that resulted in an error.

 

Dim k,m
Dim oMyReportObj, oMyReportObjects, oMy2DLine

'Run through all report pages (seems to work)
For k=1 to Report.Sheets.Count
  Report.Sheets(k).Activate
  Set oMyReportObjects = Report.ActiveSheet.Objects
  
  'Run through all 2D axis systems on the currently activated report page (seems to work)
  For Each oMyReportObj in oMyReportObjects
    If oMyReportObj.ObjectType = eReportObject2DAxisSystem Then
  
      'Run through all curves in one 2D axis system to change the curve shape settings if necessary (not working)
  '        For m = 1 to oMyReportObj.Curves2D.Count
  '          Set oMy2DLine = oMy2DAxisSystem.Curves2D(m) 'not working
  
      'I also did some try and error with this one but also not working
      For Each oMy2DLine in oMyReportObj.Curves2D ' Error: Missing Curves2D
        If oMyReportObj.ObjectType = e2DShapeLine Then ' Error: Use oMyReportObj instead of oMy2DLine
  
          'Curve shape settings modification example (seems to work)
          If oMy2DLine.Shape.Settings.Line.Color.ColorIndex = eColorIndexDarkRed  Then
            'oMy2DLine.Shape.Settings.Line.Color.ColorIndex = eColorIndexBlack 
            oMy2DLine.Shape.Settings.Line.Color.SetPredefinedColor(ePredefinedColorBlack) ' Hint: Use SetPredefinedColor instead of setting ColorIndex
          End If
        End If
      Next
    End If
  Next
Next

Call Report.Refresh()
Message 2 of 3
(1,246 Views)

Hello AnJalpaka,

 

Thank you for your quick reply and sorry for my late responese. After your modifications the script is working perfectly fine. This is exactly what I was looking for. It also helped me to get a better understanding for the Diadem scripting language. Thanks a lot for your help 🙂

0 Kudos
Message 3 of 3
(1,207 Views)