# 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 createUserComponent(param): """Create a user component.""" usrCompoList = app.GetUserComponentList() usrCompo = usrCompoList.CreateUserComponent(param[u"title"]) # Analysis type # 0 : Magnetic field analysis # 1 : Thermal analysis # 2 : Structural analysis # 3 : Electric field analysis # 4 : Iron loss analysis usrCompo.SetAnalysisType(param[u"anType"]) usrCompo.SetDescription(param[u"desc"]) usrCompo.SetExpression(param[u"expr"]) def createProbeByUserComponent(study, userCompoTitle): """Create a probe using the created user component as the result type.""" probeDef = study.CreateProbe(u"probeUserCompo") probeDef.SetResultType(u"User") probeDef.SetUserComponentType(userCompoTitle) # The 1st argumet 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 probeDef.SetResultCoordinate(0) probeDef.SetLocationCoordinate(0) probeDef.SetProbeType(u"Coordinate") probeDef.SetLocation(0, u"0", u"0", u"1") probeDef.RenamePoint(0, u"PointAlpha") probeDef.SetUseElementValue(False) probeDef.SetMoveWithPart(True) userCompoTitle = u"UCMagFn0xAbs" param = { u"title" : userCompoTitle, u"anType" : 0, u"desc" : u"Absolute value of the zero-order nodal force x component", u"expr" : u"abs(Fn0x)", } createUserComponent(param) study = app.GetCurrentStudy() createProbeByUserComponent(study, userCompoTitle)