02-12-2010 02:19 AM
Im having issues applying just a line thinckness to all curves in my REPORT. So heres the story,
I call the Export to PDF tool from labview for each measurement I do. Every measurement has a slightly different report layout that I load from independent files, I use a script once the data has loaded into the report to adjust a few parameters like the axis and curve width. Please see code:
Call
GraphObjOpen("2D-Axis1")
Call GraphObjOpen("2DXAxis8_1")
D2AxisXDivMode
= "linear"
D2AxisXScaleType = "manual"
D2AxisXBegin = 20
D2AxisXEnd
= 20000
D2AxisXOrigin = 20
D2AxisXTick = 1
D2AxisXMiniTick = 4
Call
GraphObjClose("2DXAxis8_1")
Call GraphObjOpen("2DYAxis8_1")
D2AxisYDivMode
= "linear"
D2AxisYScaleType = "manual"
D2AxisYBegin = -60
D2AxisYEnd
= 10
D2AxisYOrigin = -60
D2AxisYTick = 1
D2AxisYMiniTick = 1
Call
GraphObjClose("2DYAxis8_1")
Call GraphObjOpen("2DObj2_Curve1")
D2CURVELINEWIDTH
= 1
Call GraphObjOpen("2DObj2_Curve1")
Call
GraphObjOpen("2DObj2_Curve2")
D2CURVELINEWIDTH = 1
Call
GraphObjOpen("2DObj2_Curve2")
Call GraphObjClose("2D-Axis1")
Towards the end of the script I programatically enter in CurveLineWidth adjustments to rectify my lines, but there is a problem. each report seems to use different object names so I often get the error message: Object "2DObj2_Curve1" unknown or not open. Obviously..
How are these objects names chosen by the diadem PDF Report Generation VI? some appear linear like.. curve2, curve3 but then i get names like curve4, curve13!?!? Is it possible to see the script that this VI generates?
Is there any way to do a "foreach" method without using the specific object names???
Or does any other method come to mind???
Help is highly appreciated...
AL.
Solved! Go to Solution.
02-12-2010 09:42 AM
Hi Al,
This is the FOR Each approach you requested. You can also rename those REPORT object by directly editing the TDR file in NotePad or WordPad. There's also a way to find the names of all the REPORT objects if you don't know the graph is called "2D-Axis1".
Call GraphObjOpen("2D-Axis1")
Call GraphObjOpen(D2AxisXObj(1))
D2AxisXDivMode = "linear"
: : :
Call GraphObjClose(D2AxisXObj(1))
FOR y = 1 TO AxisNoMax
IF D2AxisYObj(y) = "" THEN Exit For ' y
Call GraphObjOpen(D2AxisYObj(y))
D2AxisYDivMode = "linear"
: : :
Call GraphObjClose(D2AxisYObj(y))
FOR c = 1 TO CurveNoMax
If D2CurveObj(c) = "" Then Exit For ' c
Call GraphObjOpen(D2CurveObj(c))
D2CurveLineWidth = 1
: :
Call GraphObjClose(D2CurveObj(c))
NEXT ' c
Call GraphObjClose(D2AxisYObj(y))
NEXT ' y
Call GraphObjClose("2D-Axis1")
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-12-2010 11:53 AM - edited 02-12-2010 11:55 AM
Hi Brad,
Thanks for your snappy reply!
It works! I just used a portion where the curves are applied as I only have one Y-axis...
so here is my generated code:
Call GraphObjOpen("2D-Axis1")
Call GraphObjOpen("2DXAxis8_1")
D2AxisXDivMode = "linear"
D2AxisXScaleType = "manual"
D2AxisXBegin = 0
D2AxisXEnd = 15
D2AxisXOrigin = 0
D2AxisXTick = 1
D2AxisXMiniTick = 4
Call GraphObjClose("2DXAxis8_1")
Call GraphObjOpen("2DYAxis8_1")
D2AxisYDivMode = "linear"
D2AxisYScaleType = "complete automatic"
D2AxisYBegin = -60
D2AxisYEnd = 10
D2AxisYOrigin = -60
D2AxisYTick = 1
D2AxisYMiniTick = 1
Call GraphObjClose("2DYAxis8_1")
FOR c = 1 TO CurveNoMax
If D2CurveObj(c) = "" Then Exit For ' c
Call GraphObjOpen(D2CurveObj(c))
D2CurveLineWidth = 10
Call GraphObjClose(D2CurveObj(c))
NEXT ' c
Call GraphObjClose("2D-Axis1")
Call PicUpdate
When I ran your script out the box it gave me the following error...
Error in <test3.vbs> (Line: 19, Column: 3):
Cannot close object "2DYAxis8_1". Incorrect Name?
but i then saw the error... there was one " Call GraphObjClose(D2AxisYObj(y))" too many between the NEXT statements 😉
did you mean the code to be like this..
Call GraphObjOpen("2D-Axis1")
Call
GraphObjOpen(D2AxisXObj(1))
D2AxisXDivMode = "linear"
: : :
Call GraphObjClose(D2AxisXObj(1))
FOR y =
1 TO AxisNoMax
IF D2AxisYObj(y) = "" THEN Exit For ' y
Call
GraphObjOpen(D2AxisYObj(y))
D2AxisYDivMode = "linear"
: : :
Call GraphObjClose(D2AxisYObj(y))
NEXT ' y
FOR c
= 1 TO CurveNoMax
If D2CurveObj(c) = "" Then Exit For ' c
Call GraphObjOpen(D2CurveObj(c))
D2CurveLineWidth = 1
: :
Call GraphObjClose(D2CurveObj(c))
NEXT ' c
Call
GraphObjClose("2D-Axis1")
before it looked like the curves were nested in the Y-axis'? thou that does also make sense... but anyhow the code works great!
Thanks again for your assistance Brad... your presence in this forum is much appreciated i think, you have tackled a few of my issues now relating to diadem 😉
Have a great weekend
AL