forked from dlubal-software/RSTAB_Python_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_objectInformation.py
More file actions
72 lines (58 loc) · 2.42 KB
/
Copy pathtest_objectInformation.py
File metadata and controls
72 lines (58 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import sys
import os
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)
# Import the relevant Libraries
from RSTAB.enums import SelectedObjectInformation
from RSTAB.initModel import CheckIfMethodOrTypeExists, Model
from RSTAB.BasicObjects.material import Material
from RSTAB.BasicObjects.section import Section
from RSTAB.BasicObjects.node import Node
from RSTAB.BasicObjects.member import Member
from RSTAB.Tools.centreOfGravityAndObjectInfo import ObjectInformation
from math import sqrt
import pytest
if Model.clientModel is None:
Model()
# pytestmark sets same parameters (in this case skipif) to all functions in the module or class
# TODO: US-8142
pytestmark = pytest.mark.skipif(CheckIfMethodOrTypeExists(Model.clientModel,'ns0:array_of_get_center_of_gravity_and_objects_info_elements_type', True),
reason="ns0:array_of_get_center_of_gravity_and_objects_info_elements_type not in RSTAB GM yet")
def test_centre_of_gravity():
Model.clientModel.service.delete_all()
Model.clientModel.service.begin_modification()
x1, y1, z1, = 0, 0, 0
x2, y2, z2 = 4, 10, -6
Node(1, x1, y1, z1)
Node(2, x2, y2, z2)
Material(1, 'S235')
Section()
Member(1, start_node_no= 1, end_node_no= 2)
Model.clientModel.service.finish_modification()
CoG_X = (x2 - x1) / 2
CoG_Y = (y2 - y1) / 2
CoG_Z = (z2 - z1) / 2
assert CoG_X == ObjectInformation.CentreOfGravity(coord= 'X')
assert CoG_Y == ObjectInformation.CentreOfGravity(coord= 'Y')
assert CoG_Z == ObjectInformation.CentreOfGravity(coord= 'Z')
def test_member_information():
Model.clientModel.service.delete_all()
Model.clientModel.service.begin_modification()
x1, y1, z1, = 0, 0, 0
x2, y2, z2 = 4, 10, -6
Node(1, x1, y1, z1)
Node(2, x2, y2, z2)
Material(1, 'S235')
Section()
Member(1, start_node_no= 1, end_node_no= 2)
Model.clientModel.service.finish_modification()
L = sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
A = 53.80 / (100 * 100)
V = L * A
M = (V * 7850) / 1000
assert round(L,3) == ObjectInformation.MemberInformation(information=SelectedObjectInformation.LENGTH)
assert round(V,3) == ObjectInformation.MemberInformation(information=SelectedObjectInformation.VOLUME)
assert round(M,3) == ObjectInformation.MemberInformation(information=SelectedObjectInformation.MASS)