[S8329] Script to create a sectiongraph and export the results to a CSV file

 

The following is an example of a script to export a CSV file after setting up a new arc graph from the displayed model using “Results” > ‘Section’ > “Arbitrary Region” > “New Arc …”.

app = designer.GetApplication()
#Use the first study of the first model (index 0 is the first)
# Create arc section graph (“Test” is the name of the graph, 0 is the index)
sectiongraph1 = app.GetModel(0).GetStudy(0).CreateSectionGraph(u"Test", 0)
# Explicitly set graph name
sectiongraph1.SetName(u"Test")
# Set result type to magnetic flux density
sectiongraph1.SetResultType(u"MagneticFluxDensity", u"")
# Flag for creating a sectional graph of arbitrary area
sectiongraph1.SetAirRegionFlag(True)
# Specify the number of section divisions
sectiongraph1.SetAirRegionSectionGraph(u"45")
# Flag to output a graph with separate lines for each material
sectiongraph1.SetSeparateLines(False)
# Set X axis to angle
sectiongraph1.SetAbscissa(u"angle")
# Set center point, axis, starting point, and angle of arc graph
sectiongraph1.SetArcExpression(u"0", u"0", u"0", u"0", u"0", u"1", u"30", u"0", u"0", u"90", u"30")
# Set arc offset
sectiongraph1.SetArcOffset(u"0")
# Set reference coordinate system for section graph
sectiongraph1.SetResultCoordinate(u"Use Coordinate System of Target Point")
# Set the component of the result to be output
sectiongraph1.SetComponent(u"Radial")
# Set the coordinate system of the symmetry boundary to the section graph
sectiongraph1.SetBoundaryCoordinate(u"Global Rectangular")
#Create arc section graph
sectiongraph1.Build()
#Exporting CSV files
app.GetDataManager().GetGraphModel(u"Test").WriteTable(u"D:/MagFllux.csv")

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.