Skip to content

Commit

Permalink
Add overloaded Mdb.Model method to copy existing model
Browse files Browse the repository at this point in the history
Closes #5707.
  • Loading branch information
haiiliin committed Aug 19, 2024
1 parent 34bb16c commit f0a25df
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions src/abaqus/Mdb/Mdb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

from typing_extensions import Literal
import copy

from typing_extensions import Literal, overload

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

Expand All @@ -22,6 +24,7 @@ class Mdb(AcisMdb, JobMdb):
mdb
"""

@overload
@abaqus_method_doc
def Model(
self,
Expand Down Expand Up @@ -78,16 +81,49 @@ def Model(
model: Model
A Model object
"""
self.models[name] = model = Model(
name,
description,
stefanBoltzmann,
absoluteZero,
waveFormulation,
modelType,
universalGas,
copyConstraints,
copyConnectors,
copyInteractions,
)

@overload
@abaqus_method_doc
def Model(
self,
name: str,
objectToCopy: Model,
) -> Model:
"""This method creates a Model object.
.. note::
This function can be accessed by::
mdb.Model
Parameters
----------
name
A String specifying the repository key.
objectToCopy
A Model object to copy.
"""

@abaqus_method_doc
def Model(self, name: str, *args, **kwargs) -> Model:
"""This method creates a Model object.
.. note::
This function can be accessed by::
mdb.Model
Parameters
----------
name
A String specifying the repository key.
args, kwargs
Positional and keyword arguments to be passed to the Model object.
"""
if len(args) == 1 and isinstance(args[0], Model):
self.models[name] = model = copy.deepcopy(args[0])
elif "objectToCopy" in kwargs and isinstance(kwargs["objectToCopy"], Model):
self.models[name] = model = copy.deepcopy(kwargs["objectToCopy"])
else:
self.models[name] = model = self.Model(name, *args, **kwargs)
return model

0 comments on commit f0a25df

Please # to comment.