Skip to content

Commit

Permalink
[bugfix] Add overloaded Mdb.Model method to copy existing model (ba…
Browse files Browse the repository at this point in the history
…ckport #5708) (#5709)

[bugfix] Add overloaded `Mdb.Model` method to copy existing model (#5708)

(cherry picked from commit c744f24)

Co-authored-by: Hailin Wang <[email protected]>
  • Loading branch information
mergify[bot] and haiiliin authored Aug 19, 2024
1 parent 7f43797 commit 6899f68
Showing 1 changed file with 45 additions and 13 deletions.
58 changes: 45 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,45 @@ 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 = Model(name, *args, **kwargs)
return model

0 comments on commit 6899f68

Please sign in to comment.