08-21-2023 12:54 PM
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:
What I want to do:
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()
08-22-2023 01:15 AM
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()
08-25-2023 11:44 AM
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 🙂