Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Formatting graph window in NX10

Hi Team,

Can you please tell me how can I format the graph window in NX10 according to my need with the help of c#. I need to format the axis limits, title,line style etc....

 

 

Thanks

 

7 REPLIES

Re: Formatting graph window in NX10

[ Edited ]

One way to do this is using Graph-Template files:

 

The Template file can originally be generated by using the save as command on the Default Graph Template in the XY function Navigator.

 

So at first visualize a Graph the way you like "by Hand" and afterwards generate your Template file.

 

You then get an xml file that can also easily be edited with a text editor.

 

To use this Template file in your automation, the following lines do the work for you:

 Dim baseTemplateManager1 As CAE.Xyplot.BaseTemplateManager
        baseTemplateManager1 = theSession.XYPlotManager.GetTemplateManager2d()
        'unload allTemplates:
        baseTemplateManager1.UnloadAllTemplates()
        'load your Template file
        baseTemplateManager1.LoadTemplate("MyTemplatefile.xml")
        'activate your Template file
        baseTemplateManager1.ActiveTemplate = "MyTemplatefile.xml"

 

The code is in VB but it should give a hint what's to do in c#.

 

Best regards,

MGeyer

 

Re: Formatting graph window in NX10

Thanks fo your support, but with the help of graph template I am not able to save the title of the graph. Can you please help me to solve this issue as well.

 

Thanks

Re: Formatting graph window in NX10

within an Automation there are several methods to create a Graph.

 

when you are using

theSession.Post.CreateHistoryGraph(....

'Or

theSession.Post.CreateSpatialGraph(....

you can set the Name of your Graph through one of the Parameters you need to pass into these functions.

 

Are you using these functions or something else?

Re: Formatting graph window in NX10

I am ploting graphs with the help of afu files. I am using XY plot manager to plot the graphs.

 

 

Solution
Solution
Accepted by topic author saddam
‎12-09-2015 06:02 AM

Re: Formatting graph window in NX10

[ Edited ]

Okay, so then maybe this can help you:

(I haven't tried this out but it looked promising)

 

 

Dim XValues() As Double = Nothing
Dim YValues() As Double = AfuData.GetRealData(XValues)            

Dim arrayRecord2D1 As CAE.FTK.ArrayRecord2D
arrayRecord2D1 = theSession.DataManager.CreateArrayRecord2d("Your Graph Title here", "Your Graph Legend here", XValues.Length)
            
'Putting your afu Data into an array Record because on this one you can set the Title, etc... arrayRecord2D1.SetXCoordinatePoints(XValues) arrayRecord2D1.SetYCoordinatePoints(YValues) 'Unit for the X-Axis (Time for example): Dim baseUnit1 As CAE.FTK.BaseUnit = theSession.DataManager.CreateArrayUnit(CAE.XyFunctionMeasure.Time, CAE.XyFunctionUnit.TimeSec) baseUnit1.SetMeasureName("Your X-Axis Title here") 'Unit for the Y-Axis (Pressure for example): Dim baseUnit2 As CAE.FTK.BaseUnit = theSession.DataManager.CreateArrayUnit(CAE.XyFunctionMeasure.Pressure, CAE.XyFunctionUnit.PressurePa) baseUnit2.SetMeasureName("Your Y-Axis Title here")

'Passing the Created Units to the arrayRecord: arrayRecord2D1.SetXCoordinateUnit(baseUnit1) arrayRecord2D1.SetYCoordinateUnit(baseUnit2) 'Pushing Your array Record into an arrayRecord-Array ( :-) ) Dim records(0) As CAE.FTK.BaseRecord records(0) = DirectCast(arrayRecord2D1, CAE.FTK.BaseRecord) 'Create some PlotParameters: Dim Parameters As CAE.Xyplot.PlotParameters = theSession.XYPlotManager.NewPlotParameters() 'Passing the arrayRecord-Array to the Plot Parameters Parameters.SetRecords(records) 'Create a new Plot with the Parameters object: Dim plot1 As CAE.Xyplot.Plot = theSession.XYPlotManager.PlotRecords(Parameters)

 

As I said, I haven't tried it out, it's some copy and pasting from my code snippets but I hope this helps.

 

Re: Formatting graph window in NX10

Thanks once again..... Yes its work fine with c# also...

I have one more query regarding the same, can I plot 2 graphs in one window means I need to plot  two graphs in same window for example one between time and distance and other between acceleration and velocity. I am able to plot in separate windows but not in the same window.

 

 

Thanks

Solution
Solution
Accepted by topic author saddam
‎12-14-2015 04:43 AM

Re: Formatting graph window in NX10

If I understood correctly,

the "ViewPortIndex" of the PlotParameters object should be what you are looking for.

So if you have i.e. "Side by SIde" view enabled, it should be possible to plot one Graph to ViewPortIndex 0 and one Graph to ViewPortIndex  1.

'Create some PlotParameters:
Dim Parameters As CAE.Xyplot.PlotParameters = theSession.XYPlotManager.NewPlotParameters()

'Passing the first arrayRecord-Array to the Plot Parameters
Parameters.SetRecords(records1)

'Setting the ViewPortIndex
Parameters.ViewPortIndex =0

'Create a new Plot with the Parameters object:
Dim plot1 As CAE.Xyplot.Plot = theSession.XYPlotManager.PlotRecords(Parameters)

'Now the Second Graph:
Parameters.ViewPortIndex = 1
Parameters.SetRecords(records2)
Dim plot2 As CAE.Xyplot.Plot = theSession.XYPlotManager.PlotRecords(Parameters)

Again I haven't tried it out... Smiley Wink