05-13-2022 09:51 AM
I have a question that I think should be pretty basic but I can't figure it out. Using the sample data I want to use VBscript to put a waveform channel into a report layout that I already have set up. Currently I have everything scripted to show up in VIEW, but I want the flexibility to add titles and place labels where I want them so I need to switch to REPORT.
I need to add a bunch of channels so I want to eventually use this example script, but even without the loop I can't get it to work.
https://forums.ni.com/t5/DIAdem/Adding-Multiple-Channel-references-in-Diadem-Report/m-p/4156825
Dim Channels, Sheet, Graph
Set Channels = Data.Root.ChannelGroups(2).Channels
Set Sheet = Report.ActiveSheet
Set Graph = Sheet.Objects("2DAxis1")
Call Graph.Curves2D.RemoveAll()
Graph.Curves2D.Add(e2DShapeLine, "Curve1").Shape.YChannel.Reference = Channels(1).GetReference(eReferenceIndexName)
The above script adds the Y-channel I want, but my X-channel is a question mark (?). Why does it do that? I have to manually delete the question mark and then the graph will plot.
Thanks,
Tyler
Solved! Go to Solution.
05-15-2022 12:01 PM
When dealing with waveform channels, you need to set the X channel reference to "". See the example below.
Dim oChnWf, oRptSht, oRptObj, oCurve2D
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Example_data.tdm", "TDM", "[2]/*", "Load|ChnXYRelation")
Set oChnWf = Data.GetChannel("Noise data/Noise_1")
Set oRptSht = Report.ActiveSheet 'or Set oRptSheet = Report.Sheets.Item("Sheet 1")
Set oRptObj = oRptSht.Objects.Item("2DAxis1")
Call oRptObj.Curves2D.RemoveAll()
Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeLine, "Curve1")
oCurve2D.Shape.XChannel.Reference = ""
oCurve2D.Shape.YChannel.Reference = oChnWf.GetReference(eReferenceIndexName)
Call Report.Refresh()
05-16-2022 10:37 AM
Thanks Mark! I knew I was missing some minor detail. I'm kind of kicking myself for not trying "" for the X-channel, but that is how scripting goes for me.