# 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/ def generateMesh(study, caseNo): """If a mesh has not yet been generated for the case of the study specified in the argument, it will be generated""" # The argument for SetCurrentCase is a zero-based index, so it should be case number - 1. caseIndex = caseNo - 1 study.SetCurrentCase(caseIndex) if not study.HasMesh(): study.CreateMesh() def checkNumNodesAndElems(study, caseNo): """Get and display the number of nodes and elements for the case of the study specified in the argument.""" caseIndex = caseNo - 1 study.SetCurrentCase(caseIndex) if study.HasMesh(): report = study.GetReport() num_nodes = report.NumVertices() num_elements = report.NumElements() print(f"Nodes of Case{caseNo}: {num_nodes}") print(f"Elements of Case{caseNo}: {num_elements}") else: print(u"No mesh generated for the current case") app = designer.GetApplication() targetCase = 2 study = app.GetCurrentStudy() if targetCase > study.GetDesignTable().NumCases(): print(u"The case", targetCase, u"doesn't exist in this study.") else: generateMesh(study, targetCase) checkNumNodesAndElems(study, targetCase)