Skip to content

Commit c744f24

Browse files
authored
[bugfix] Add overloaded Mdb.Model method to copy existing model (#5708)
1 parent 34bb16c commit c744f24

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

src/abaqus/Mdb/Mdb.py

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

3-
from typing_extensions import Literal
3+
import copy
4+
5+
from typing_extensions import Literal, overload
46

57
from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
68

@@ -22,6 +24,7 @@ class Mdb(AcisMdb, JobMdb):
2224
mdb
2325
"""
2426

27+
@overload
2528
@abaqus_method_doc
2629
def Model(
2730
self,
@@ -78,16 +81,45 @@ def Model(
7881
model: Model
7982
A Model object
8083
"""
81-
self.models[name] = model = Model(
82-
name,
83-
description,
84-
stefanBoltzmann,
85-
absoluteZero,
86-
waveFormulation,
87-
modelType,
88-
universalGas,
89-
copyConstraints,
90-
copyConnectors,
91-
copyInteractions,
92-
)
84+
85+
@overload
86+
@abaqus_method_doc
87+
def Model(self, name: str, objectToCopy: Model) -> Model:
88+
"""This method creates a Model object.
89+
90+
.. note::
91+
This function can be accessed by::
92+
93+
mdb.Model
94+
95+
Parameters
96+
----------
97+
name
98+
A String specifying the repository key.
99+
objectToCopy
100+
A Model object to copy.
101+
"""
102+
103+
@abaqus_method_doc
104+
def Model(self, name: str, *args, **kwargs) -> Model:
105+
"""This method creates a Model object.
106+
107+
.. note::
108+
This function can be accessed by::
109+
110+
mdb.Model
111+
112+
Parameters
113+
----------
114+
name
115+
A String specifying the repository key.
116+
args, kwargs
117+
Positional and keyword arguments to be passed to the Model object.
118+
"""
119+
if len(args) == 1 and isinstance(args[0], Model):
120+
self.models[name] = model = copy.deepcopy(args[0])
121+
elif "objectToCopy" in kwargs and isinstance(kwargs["objectToCopy"], Model):
122+
self.models[name] = model = copy.deepcopy(kwargs["objectToCopy"])
123+
else:
124+
self.models[name] = model = Model(name, *args, **kwargs)
93125
return model

0 commit comments

Comments
 (0)