# Copyright (c) 2026 JSOL CORPORATION # # This script is released under the MIT License. # See the full license text at: # https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/ app = designer.GetApplication() def createCut(model, param): """Create a cut plane""" cutList = model.GetCutList() cutType = param[u"cutType"] # Plane cut if cutType == u"plane": cutDefinition = cutList.CreateCutPlane(param[u"title"]) # Cylindrical cut elif cutType == u"cylinder": cutDefinition = cutList.CreateCutCylinder(param[u"title"]) cutDefinition.SetRadius(param[u"radius"]) nX, nY, nZ = param[u"normalXYZ"] cutDefinition.SetNormalXYZ( nX, nY, nZ) oX, oY, oZ = param[u"originXYZ"] cutDefinition.SetOriginXYZ( oX, oY, oZ) cutDefinition.SetDisplayType(param[u"displayType"]) return cutDefinition def createContourWithCut(study, param): """Create a contour plot using the created cut plane.""" contour = study.CreateContour(param[u"title"]) contour.SetResultType(param[u"resultType"]) # The 1st argument of SetResultCoordinate # Name or index # The name of the preset coordinate system is fixed according to the language setting. # The index is specified in a 0-based from the coordinate system definition list order under Project - Model - Coordinate Systems contour.SetResultCoordinate(param[u"resultCoordinate"]) # contour.SetResultCoordinate(u"Global Rectangular") contour.SetDisplayAllParts(param[u"displayAllParts"]) cutDefNames = param[u"cutDefNames"] for cutDefName in cutDefNames: contour.AddCutPlane(cutDefName) model = app.GetCurrentModel() cutPlaneParam = { u"cutType" : u"plane", u"title" : u"DiagonalCut", u"normalXYZ" : [5, -5, 0], u"originXYZ" : [28, 28, 0], u"displayType" : u"ShowBehind" } cutPlaneDef = createCut(model, cutPlaneParam) cutCylinderParam = { u"cutType" : u"cylinder", u"title" : u"CylinderCut", u"normalXYZ" : [0, 0, 1], u"originXYZ" : [0, 0, 0], u"radius" : 13, u"displayType" : u"ShowOutside" } cutCylinderDef = createCut(model, cutCylinderParam) study = app.GetCurrentStudy() contourParam = { u"title" : u"MagFluxDensContour", u"resultType" : u"MagneticFluxDensity", u"resultCoordinate" : 0, u"displayAllParts" : True, u"cutDefNames" : [ cutPlaneDef.GetName(), cutCylinderDef.GetName() ] } createContourWithCut(study, contourParam) # Turn on the contour display for the results. app.View().SetContourView(True)