# 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 createFluxLineFromPlane(study, fluxLineParam, planeParam): """Create a flux line.""" fluxLineDef = study.CreateFluxLine(fluxLineParam[u"title"]) fluxLineDef.SetResultType(fluxLineParam[u"resultType"]) # Display type # 0 : Shading # 1 : No hidden lines # 2 : Wireframe fluxLineDef.SetDisplayType(fluxLineParam[u"displayType"]) fluxLineDef.SetThickness(u"1.1") fluxLineDef.SetColor(u"red") fluxLineDef.SetLines(planeParam[u"lines"]) # drawing type # point : Point specification # plane : Surface specification fluxLineDef.SetFluxLineType(u"plane") normalX, normalY, normalZ = planeParam[u"normal"] fluxLineDef.SetNormal( normalX, normalY, normalZ ) originX, originY, originZ = planeParam[u"origin"] fluxLineDef.SetOrigin( originX, originY, originZ ) plane = planeParam[u"plane"] useFinitePlane = plane[u"useFinite"] fluxLineDef.SetUseFinitePlane(useFinitePlane) if useFinitePlane: fluxLineDef.SetPlaneWidth(plane[u"width"]) fluxLineDef.SetPlaneHeight(plane[u"height"]) seed = planeParam[u"seed"] useAllParts = seed[u"allParts"] fluxLineDef.SetSeedLineAllParts(useAllParts) if not useAllParts: # Specify the part ID. partIdList = seed[u"partIdList"] for partId in partIdList: fluxLineDef.AddPart(partId) model = app.GetCurrentModel() study = app.GetCurrentStudy() partSet = model.GetSetList().GetSet(u"Rotor") fluxLineParam = { u"title" : u"MagFluxDens", u"resultType" : u"MagneticFluxDensity", u"displayType" : 2 } planeParam = { u"lines" : u"22", u"normal" : (1, 0, 0), u"origin" : (8, 7, 8), u"plane" : { u"useFinite" : True, u"width" : 15, u"height" : 15, }, u"seed" : { u"allParts" : False, u"partIdList" : partSet.GetIDs(), }, } createFluxLineFromPlane(study, fluxLineParam, planeParam) # Turn on the display of flux lines. app.View().SetFluxLineView(True)