Skip to content

Commit 705cfb4

Browse files
Merge pull request #35 from mitchell-tesch/frame_updates_temp
Updates for frame force extraction, sections and group assignments, model saving
2 parents 6953581 + 422c91a commit 705cfb4

File tree

4 files changed

+206
-3
lines changed

4 files changed

+206
-3
lines changed

src/pytabs/analysis_results.py

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ class BucklingFactor(TypedDict):
6464
step_number: list[float]
6565
factor: list[float]
6666

67+
class FrameForce(TypedDict):
68+
"""TypedDict class for frame_force return"""
69+
number_results: int
70+
object_name: list[str]
71+
object_station: list[float]
72+
element_name: list[str]
73+
element_station: list[float]
74+
load_case: list[str]
75+
step_type: list[str]
76+
step_number: list[int]
77+
axial_force: list[float]
78+
shear_2: list[float]
79+
shear_3: list[float]
80+
torsion: list[float]
81+
moment_2: list[float]
82+
moment_3: list[float]
83+
84+
6785

6886
class JointDisplacement(TypedDict):
6987
"""TypedDict class for joint_displacement return"""
@@ -379,7 +397,62 @@ def buckling_factor(self) -> BucklingFactor:
379397
'step_number': list(step_number),
380398
'factor': list(factor)}
381399

382-
# TODO: FrameForce
400+
401+
def frame_force(self, name, item_type_element: etabs.eItemTypeElm) -> FrameForce:
402+
"""Reports the frame forces for specified line elements
403+
404+
:param name: The name of an existing point object, point element, or group of objects depending on the value of the ItemTypeElm item
405+
:type name: str
406+
:param item_type_element: one of the following items in the `eItemTypeElm` enumeration.
407+
`ObjectElm` - the point element corresponding to the point object specified by the `name`
408+
`Element` - the point element specified by `name`
409+
`GroupElm` - all point elements directly or indirectly specified in the group specified by `name`
410+
`SelectionElm` - all point elements directly or indirectly selected and `name` is ignored
411+
:type item_type_element: etabs.eItemTypeElm
412+
:return: Frame force analysis results
413+
:rtype: FrameForce
414+
"""
415+
416+
number_results = int()
417+
object_name = [str()]
418+
object_station = [float()]
419+
element_name = [str()]
420+
element_station = [float()]
421+
load_case = [str()]
422+
step_type = [str()]
423+
step_number = [int()]
424+
axial_force = [float()]
425+
shear_2 = [float()]
426+
shear_3 = [float()]
427+
torsion = [float()]
428+
moment_2 = [float()]
429+
moment_3 = [float()]
430+
431+
[ret, number_results, object_name, object_station,
432+
element_name, element_station, load_case, step_type,
433+
step_number, axial_force, shear_2, shear_3, torsion,
434+
moment_2, moment_3] = self.analysis_results.FrameForce(name, item_type_element, number_results, object_name, object_station,
435+
element_name, element_station, load_case, step_type,
436+
step_number, axial_force, shear_2, shear_3, torsion,
437+
moment_2, moment_3)
438+
439+
handle(ret)
440+
return {'number_results': number_results,
441+
'object_name': list(object_name),
442+
'object_station': list(object_station),
443+
'element_name': list(element_name),
444+
'element_station': list(element_station),
445+
'load_case': list(load_case),
446+
'step_type': list(step_type),
447+
'step_number': list(step_number),
448+
'axial_force': list(axial_force),
449+
'shear_2': list(shear_2),
450+
'shear_3': list(shear_3),
451+
'torsion': list(torsion),
452+
'moment_2': list(moment_2),
453+
'moment_3': list(moment_3)}
454+
455+
383456
# TODO: FrameJointForce
384457
# TODO: GeneraliszeDispl
385458
# TODO: JointAcc

src/pytabs/frame_obj.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,36 @@ def set_group_assign(self, name: str, group_name: str, remove: bool = False,
204204
:type group_name: str
205205
:param remove: `True` for add, False for remove, defaults to `False`
206206
:type remove: bool, optional
207-
:param item_type: one of eItemType enumeration (`Objects` : frame object specified by name is added/removed from group, `Group` : all frame objects in the group specified by name are added/removed from group, `SelectedObjects` : all selected frame objects are added/removed from group, name is ignored), defaults to `eItemType.Objects`
207+
:param item_type: one of eItemType enumeration
208+
`Objects` : frame object specified by name is added/removed from group,
209+
`Group` : all frame objects in the group specified by name are added/removed from group,
210+
`SelectedObjects` : all selected frame objects are added/removed from group, name is ignored,
211+
defaults to `eItemType.Objects`
208212
:type item_type: eItemType, optional
209213
"""
210214
handle(self.frame_obj.SetGroupAssign(name, group_name, remove, item_type))
211215

216+
def set_section_assign(self, frame_name: str, prop_name: str, item_type: etabs.eItemType = etabs.eItemType.Objects, SVarRelStartLoc = 0.0, SVarrTotalLength = 0.0) -> None:
217+
"""Assigns a frame section property to a frame object.
218+
219+
:param frame_name: name of an existing frame object or group depending on the value of item_type
220+
:type frame_name: str
221+
:param prop_name: name of a frame section property to be assigned to the specified frame object(s)
222+
:type prop_name: str
223+
:param item_type: one of eItemType enumeration
224+
`Object` : frame object specified by name is added/removed from group,
225+
`Group` : all frame objects in the group specified by name are added/removed from group,
226+
`SelectedObjects` : all selected frame objects are added/removed from group, name is ignored,
227+
defaults to `eItemType.Objects`
228+
:type item_type: etabs.eItemType
229+
:param SVarRelStartLoc: _description_, defaults to 0.0
230+
:type SVarRelStartLoc: float, optional
231+
:param SVarrTotalLength: _description_, defaults to 0.0
232+
:type SVarrTotalLength: float, optional
233+
"""
234+
235+
handle(self.frame_obj.SetSection(frame_name, prop_name, item_type))
236+
212237
def set_spring_assignment(self, frame_name: str, line_spring_prop: str,
213238
item_type: etabs.eItemType = etabs.eItemType.Objects) -> None:
214239
"""Assigns an existing line spring property to frame objects of the value item_type.

src/pytabs/model.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,32 @@ def new_model(self, new_model_path: Union[str, Path]) -> None:
268268
self.model_path = new_model_path
269269
self.model_open = True
270270

271+
def save_model(self, save_model_path: Union[str, Path]) -> None:
272+
"""Saves the present model.
273+
If no file name is specified, the file is saved using its current name.
274+
If there is no current name for the file (the file has not been saved previously)
275+
and this function is called with no file name specified, an error will be returned.
276+
277+
:param save_model_path: file path to save new blank ETABS model file
278+
:type save_model_path: Union[str, Path]
279+
"""
280+
281+
handle(self.file.Save(str(save_model_path)))
282+
self.model_path = save_model_path
283+
self.model_open = True
284+
285+
def get_model_file_name(self, IncludePath: bool = True) -> str:
286+
"""Returns a string that represents the filename of the current model, with or without the full path
287+
288+
:param IncludePath: Include full path or not, defaults to True
289+
:type IncludePath: bool, optional
290+
:return: filename of current model, with or without the full path
291+
:rtype: str
292+
"""
293+
294+
return str(self.sap_model.GetModelFilename(IncludePath))
295+
296+
271297
def get_database_units(self) -> etabs.eUnits:
272298
"""Returns a value from the eUnits enumeration indicating the database units for the model.
273299
All data is internally stored in the model in these units and converted to the present units as needed.
@@ -373,4 +399,4 @@ def set_present_units_components(self, force_units: etabs.eForce, length_units:
373399
:param temperature_units: Temperature enumeration to set
374400
:type temperature_units: eTemperature
375401
"""
376-
handle(self.sap_model.SetPresentUnits_2(force_units, length_units, temperature_units))
402+
handle(self.sap_model.SetPresentUnits_2(force_units, length_units, temperature_units))

src/pytabs/properties/prop_frame.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111

1212
# import typing
13+
from typing import TypedDict
14+
15+
class FrameProp(TypedDict):
16+
"""TypedDict class for frame_prop return"""
17+
number_results: int
18+
name: list[str]
19+
prop_type: list[etabs.eFramePropType]
20+
t3: list[float]
21+
t2: list[float]
22+
tf: list[float]
23+
tw: list[float]
24+
t2b: list[float]
25+
tfb: list[float]
26+
area: list[float]
1327

1428

1529
class PropFrame:
@@ -26,3 +40,68 @@ def __init__(self, sap_model: etabs.cSapModel) -> None:
2640
"""EtabsModel `FramePropType` enumeration"""
2741

2842
# relate custom enumerations
43+
44+
45+
def get_all_frame_prop(self) -> FrameProp:
46+
"""Retrieves select data for all frame properties in the model
47+
48+
:return: All frame properties defined in the model
49+
:rtype: FrameProp
50+
"""
51+
52+
number_results = int()
53+
name = [str()]
54+
prop_type = [] # self.eFramePropType(int)
55+
t3 = [float()]
56+
t2 = [float()]
57+
tf = [float()]
58+
tw = [float()]
59+
t2b = [float()]
60+
tfb = [float()]
61+
area = [float()]
62+
63+
[ret, number_results,
64+
name, prop_type, t3, t2,
65+
tf, tw, t2b, tfb, area] = self.prop_frame.GetAllFrameProperties_2(number_results, name,
66+
prop_type, t3, t2, tf,
67+
tw, t2b, tfb, area)
68+
69+
handle(ret)
70+
71+
return {'number_results': number_results,
72+
'prop_name': list(name),
73+
#'prop_type': self.eFramePropType(list(prop_type)), ## enum to be resolved
74+
'prop_type': prop_type,
75+
't3': list(t3),
76+
't2': list(t2),
77+
'tf': list(tf),
78+
'tw': list(tw),
79+
't2b': list(t2b),
80+
'tfb': list(tfb),
81+
'area': list(area)}
82+
83+
84+
def set_rectangle_prop(self, name: str, mat_prop: str, t3: float, t2: float, colour: float = -1, notes: str = '', guid: str = '') -> None:
85+
"""Initializes a solid rectangular frame section property. If this function is called for an existing frame section property,
86+
all items for the section are reset to their default value.
87+
88+
:param name: name of the fame section property
89+
:type name: str
90+
:param mat_prop: name of the material property to assign
91+
:type mat_prop: str
92+
:param t3: section depth, defined according to model units
93+
:type t3: float
94+
:param t2: section width, defined according to model units
95+
:type t2: float
96+
:param colour: _description_, defaults to -1
97+
:type colour: float, optional
98+
:param notes: _description_, defaults to ''
99+
:type notes: str, optional
100+
:param guid: _description_, defaults to ''
101+
:type guid: str, optional
102+
:return: _description_
103+
:rtype: _type_
104+
"""
105+
106+
return handle(self.prop_frame.SetRectangle(name, mat_prop, t3, t2, colour, notes, guid))
107+

0 commit comments

Comments
 (0)