# 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/ import math def selectPartsWithinRadius(targetModel, targetRadius): """Select all parts within the argument radius""" sel = targetModel.CreateSelection() numParts = targetModel.NumParts() for i in range(numParts): targetPart = targetModel.GetPartByIndex(i) # Get a position within a part pointInPart = targetPart.PointInPart() # Calculate the r component at the origin center of the above position rad = math.sqrt((pointInPart.GetX()**2)+(pointInPart.GetY()**2)) if rad <= targetRadius: sel.SelectPart(targetPart.ID()) return sel def createMotionConditionOfInnerRotor(targetStudy, selectedTargets): """Create a rotation motion condition to the parts passed as the 2nd argument""" RotMotionCond = targetStudy.CreateCondition(u"RotationMotion", u"rotMotion") RotMotionCond.SetValue(u"MotionGroupType", u"ConstantVelocity") RotMotionCond.SetValue(u"AngularVelocity", 600) RotMotionCond.SetValue(u"InitialRotationAngleType", u"Manual") RotMotionCond.SetValue(u"InitialRotationAngle", 15) RotMotionCond.SetXYZPoint(u"Origin", 0, 0, 0) RotMotionCond.ClearParts() RotMotionCond.AddSelected(selectedTargets) app = designer.GetApplication() model = app.GetModel(0) rad = 0.01175 sel = selectPartsWithinRadius(model, rad) study = model.GetStudy(0) createMotionConditionOfInnerRotor(study, sel)