[S0039] Create a full model from a partial model using the assembly pattern feature

In simulations, to reduce computational costs, it is recommended to perform analysis using partial model when there is periodicity or symmetry.
However, even when dealing with the same model, full model analysis may be necessary depending on the analysis objective.
This script reads a CAD file prepared as a partial model and creates a full model using assembly pattern features.

Preconditions

  • Prepare a CAD file created as a partial model.
    This script loads a CAD file in SAT format.
  • The periodicity and symmetry of the prepared partial model are known.
    This script runs for the partial model that has a circumferential periodicity of 90 degree with the Z-axis as a rotation axis and has a mirror symmetry with the XY plane.

Script Function

  • Load the CAD file of the partial model into the Geometry Editor.
  • Retrieve all parts and create their reference objects.
  • Create an assembly circular pattern for all parts with the Z axis as the rotation axis.
    This script uses 90 degree as the periodic angle.
  • Create an assembly mirror copy for all parts and the created assembly circular pattern to the XY plane as the mirror face.
# 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/


SAT_FILEPATH = u"D:/Temp/ipm_motor.SAT"  # Full path to the CAD file
PERIODIC_ANGLE = 90.0  # Periodic angle of the circumferential periodicity of the model

app = designer.GetApplication()
geomApp = app.CreateGeometryEditor()
geomDoc = geomApp.GetDocument()


def getAllParts(assembly):
    """Get all parts on the assembly"""
    numAssmItems = assembly.NumItems()
    allParts = []
    for i in range(numAssmItems):
        item = assembly.GetItem(i)
        if item.GetScriptTypeName() == u"Part":
            allParts.append(item)
    return allParts


def getAllPartsReferece(assembly):
    """Create reference objects for all parts on the assembly"""
    allParts = getAllParts(assembly)
    allPartsRef = []
    for part in allParts:
        allPartsRef.append(geomDoc.CreateReferenceFromItem(part))
    return allPartsRef


def createAssemblyCircularPatternOnZAxis(assembly, allPartsRef, allFeatureRef, periodicAngle, numInstances):
    """Create a circular pattern of all parts and features on the assembly, centered on the Z-axis"""
    assmCircularPattern = assembly.CreateAssemblyCircularPattern()
    assmCircularPattern.SetProperty(u"AxisType", u"DefaultZ")  # The rotation axis of the circular pattern is the Z-axis
    assmCircularPattern.SetAngle(periodicAngle)
    assmCircularPattern.SetInstance(numInstances)
    for partRef in allPartsRef:
        assmCircularPattern.AddPropertyByReference(u"Target", partRef)
    for featureRef in allFeatureRef:
        assmCircularPattern.AddPropertyByReference(u"Feature", featureRef)
    return assmCircularPattern


def createMirrorOnXYPlane(assembly, allPartsRef, allFeatureRef):
    """Create a mirror copy of all parts and features on the assembly using the XY plane as the mirrr face"""
    assmMirrorCopy = assembly.CreateAssemblyMirrorCopy()
    assmMirrorCopy.SetProperty(u"SymmetryType", u"DefaultXY")  # The mirror face of the copy is XY plane
    for partRef in allPartsRef:
        assmMirrorCopy.AddPropertyByReference(u"Target", partRef)
    for featureRef in allFeatureRef:
        assmMirrorCopy.AddPropertyByReference(u"Feature", featureRef)
    return assmMirrorCopy


def createFullModel(assembly):
    """Create a full model from a partial model using assembly circular pattern and mirror copy"""
    allFeatureRef = []
    allPartsRef = getAllPartsReferece(assembly)
    
    featureCreated = createAssemblyCircularPatternOnZAxis(assembly, allPartsRef, allFeatureRef, PERIODIC_ANGLE, 360 / PERIODIC_ANGLE)
    allFeatureRef.append(geomDoc.CreateReferenceFromItem(featureCreated))
    
    createMirrorOnXYPlane(assembly, allPartsRef, allFeatureRef)


geomApp.Load3DCad(SAT_FILEPATH)
assm = geomDoc.GetAssembly()
createFullModel(assm)

Download Python source code

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.

Search Filter
  • All Categories

An engineer's diary
JMAG-Express Online