[S8341] Script to get the maximum flux density of a contour plot for any part

 

The following is an example script to obtain the maximum flux density of a contour plot on an arbitrary part.

app = designer.GetApplication()

# Get ID of part name "Rotor core"

PartID = app.GetModel(0).GetPart(u"Rotor core").ID()

# Create a contour plot

app.GetModel(0).GetStudy(0).CreateContour(u"MagneticFluxDensity")

# Set the type of results

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").SetResultType(u"MagneticFluxDensity", u"")

# Set coordinate system

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").SetResultCoordinate(u"Global Rectangular")

# Flag to indicate whether all parts are to be rendered

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").SetDisplayAllParts(False)

# Remove all parts from the list of drawing targets

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").RemoveAllParts()

# Add a part to the list of drawing targets

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").AddPart(PartID)

# Flag to show or hide shell and beam elements

app.GetModel(0).GetStudy(0).GetContour(u"MagneticFluxDensity").SetDisplayShellBeam(False)

# Flag to display contour plots

app.View().SetContourView(True)

# Get the maximum value of the contour on the display

maxcontour = app.View().ContourMaxValue()

# Display retrieved values

print(u"Max:" +  str(maxcontour))

How to use script file

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