Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinate System #277

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 336 additions & 0 deletions RFEM/BasicObjects/coordinateSystem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
from RFEM.initModel import Model, clearAttributes, deleteEmptyAttributes
from RFEM.enums import CoordinateSystemType, CoordinateSystemRotationAnglesSequence

class CoordinateSystem():
def __init__(self,
no: int = 1,
type = CoordinateSystemType.TYPE_OFFSET_XYZ,
origin_coordinate_x: float = 0.0,
origin_coordinate_y: float = 0.0,
origin_coordinate_z: float = 0.0,
name: str = 'Coord1',
comment: str = '',
params: dict = None,
model = Model):

'''
Args:
no (int): Coordinate System Tag
type (enum): Coordinate System Type
origin_coordinate_x (float): X-Coordinate
origin_coordinate_y (float): Y-Coordinate
origin_coordinate_z (float): Z-Coordinate
name (str): Name
comment (str, optional): Comments
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
model (RFEM Class, optional): Model to be edited
'''
# Client model | Coordinate System
clientObject = model.clientModel.factory.create('ns0:coordinate_system')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Coordinate System No.
clientObject.no = no

# Coordinate System Type
clientObject.type = type.name

# Coordinates
clientObject.origin_coordinate_x = origin_coordinate_x
clientObject.origin_coordinate_y = origin_coordinate_y
clientObject.origin_coordinate_z = origin_coordinate_z

# Name
if name:
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Coordinate System to client model
model.clientModel.service.set_coordinate_system(clientObject)

@staticmethod
def OffsetXYZ(no: int = 1,
origin_coordinate_x: float = 0.0,
origin_coordinate_y: float = 0.0,
origin_coordinate_z: float = 0.0,
name: str = '',
comment: str = '',
params: dict = None,
model = Model):

'''
Args:
no (int): Coordinate System Tag
origin_coordinate_x (float): X-Coordinate
origin_coordinate_y (float): Y-Coordinate
origin_coordinate_z (float): Z-Coordinate
name (str): Name
comment (str, optional): Comments
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
model (RFEM Class, optional): Model to be edited
'''
# Client model | Coordinate System
clientObject = model.clientModel.factory.create('ns0:coordinate_system')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Coordinate System No.
clientObject.no = no

# Coordinate System Type
clientObject.type = CoordinateSystemType.TYPE_OFFSET_XYZ.name

# Coordinates
clientObject.origin_coordinate_x = origin_coordinate_x
clientObject.origin_coordinate_y = origin_coordinate_y
clientObject.origin_coordinate_z = origin_coordinate_z

# Name
if name:
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Coordinate System to client model
model.clientModel.service.set_coordinate_system(clientObject)

@staticmethod
def ThreePoints(no: int = 1,
origin_coordinate_x: float = 1.0,
origin_coordinate_y: float = 0.0,
origin_coordinate_z: float = 0.0,
u_axis_point_coordinate_x: float = 0.0,
u_axis_point_coordinate_y: float = 1.0,
u_axis_point_coordinate_z: float = 0.0,
uw_plane_point_coordinate_x: float = 0.0,
uw_plane_point_coordinate_y: float = 0.0,
uw_plane_point_coordinate_z: float = 1.0,
name: str = '',
comment: str = '',
params: dict = None,
model = Model):

'''
Args:
no (int): Coordinate System Tag
origin_coordinate_x (float): Origin Point X-Coordinate
origin_coordinate_y (float): Origin Point Y-Coordinate
origin_coordinate_z (float): Origin Point Z-Coordinate
u_axis_point_coordinate_x (float): Point on +U-Axis - 1st point X-Coordinate
u_axis_point_coordinate_y (float): Point on +U-Axis - 1st point Y-Coordinate
u_axis_point_coordinate_z (float): Point on +U-Axis - 1st point Z-Coordinate
uw_plane_point_coordinate_x (float): Point in +UW-Plane - 2nd Point X-Coordinate
uw_plane_point_coordinate_y (float): Point in +UW-Plane - 2nd Point Y-Coordinate
uw_plane_point_coordinate_z (float): Point in +UW-Plane - 2nd Point Z-Coordinate
name (str): Name
comment (str, optional): Comments
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
model (RFEM Class, optional): Model to be edited
'''
# Client model | Coordinate System
clientObject = model.clientModel.factory.create('ns0:coordinate_system')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Coordinate System No.
clientObject.no = no

# Coordinate System Type
clientObject.type = CoordinateSystemType.TYPE_3_POINTS.name

# Coordinates
clientObject.origin_coordinate_x = origin_coordinate_x
clientObject.origin_coordinate_y = origin_coordinate_y
clientObject.origin_coordinate_z = origin_coordinate_z

clientObject.u_axis_point_coordinate_x = u_axis_point_coordinate_x
clientObject.u_axis_point_coordinate_y = u_axis_point_coordinate_y
clientObject.u_axis_point_coordinate_z = u_axis_point_coordinate_z

clientObject.uw_plane_point_coordinate_x = uw_plane_point_coordinate_x
clientObject.uw_plane_point_coordinate_y = uw_plane_point_coordinate_y
clientObject.uw_plane_point_coordinate_z = uw_plane_point_coordinate_z

# Name
if name:
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Coordinate System to client model
model.clientModel.service.set_coordinate_system(clientObject)

@staticmethod
def TwoPointsAndAngle(no: int = 1,
origin_coordinate_x: float = 1.0,
origin_coordinate_y: float = 0.0,
origin_coordinate_z: float = 0.0,
u_axis_point_coordinate_x: float = 0.0,
u_axis_point_coordinate_y: float = 0.0,
u_axis_point_coordinate_z: float = 0.0,
uw_plane_angle: float = 0.0,
name: str = '',
comment: str = '',
params: dict = None,
model = Model):

'''
Args:
no (int): Coordinate System Tag
origin_coordinate_x (float): Origin Point X-Coordinate
origin_coordinate_y (float): Origin Point Y-Coordinate
origin_coordinate_z (float): Origin Point Z-Coordinate
u_axis_point_coordinate_x (float): Point on +U-Axis - 1st point X-Coordinate
u_axis_point_coordinate_y (float): Point on +U-Axis - 1st point Y-Coordinate
u_axis_point_coordinate_z (float): Point on +U-Axis - 1st point Z-Coordinate
uw_plane_angle (float): Rotation About U-Axis
name (str): Name
comment (str, optional): Comments
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
model (RFEM Class, optional): Model to be edited
'''
# Client model | Coordinate System
clientObject = model.clientModel.factory.create('ns0:coordinate_system')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Coordinate System No.
clientObject.no = no

# Coordinate System Type
clientObject.type = CoordinateSystemType.TYPE_2_POINTS_AND_ANGLE.name

# Coordinates
clientObject.origin_coordinate_x = origin_coordinate_x
clientObject.origin_coordinate_y = origin_coordinate_y
clientObject.origin_coordinate_z = origin_coordinate_z

clientObject.u_axis_point_coordinate_x = u_axis_point_coordinate_x
clientObject.u_axis_point_coordinate_y = u_axis_point_coordinate_y
clientObject.u_axis_point_coordinate_z = u_axis_point_coordinate_z

clientObject.uw_plane_angle = uw_plane_angle

# Name
if name:
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Coordinate System to client model
model.clientModel.service.set_coordinate_system(clientObject)

@staticmethod
def PointAndThreeAngles(no: int = 1,
origin_coordinate_x: float = 1.0,
origin_coordinate_y: float = 2.0,
origin_coordinate_z: float = 3.0,
rotation_angles_sequence: float = CoordinateSystemRotationAnglesSequence.SEQUENCE_XYZ,
rotation_angle_1: float = 0.0,
rotation_angle_2: float = 0.0,
rotation_angle_3: float = 0.0,
name: str = '',
comment: str = '',
params: dict = None,
model = Model):

'''
Args:
no (int): Coordinate System Tag
origin_coordinate_x (float): Origin Point X-Coordinate
origin_coordinate_y (float): Origin Point Y-Coordinate
origin_coordinate_z (float): Origin Point Z-Coordinate
rotation_angles_sequence (float): Rotation Angles Sequesce
rotation_angle_1 (float): Rotation about X Axes
rotation_angle_2 (float): Rotation about Y Axes
rotation_angle_3 (float): Rotation about Z Axes
name (str): Name
comment (str, optional): Comments
params (dict, optional): Any WS Parameter relevant to the object and its value in form of a dictionary
model (RFEM Class, optional): Model to be edited
'''
# Client model | Coordinate System
clientObject = model.clientModel.factory.create('ns0:coordinate_system')

# Clears object atributes | Sets all atributes to None
clearAttributes(clientObject)

# Coordinate System No.
clientObject.no = no


# Coordinate System Type
clientObject.type = CoordinateSystemType.TYPE_POINT_AND_3_ANGLES.name

# Coordinates
clientObject.origin_coordinate_x = origin_coordinate_x
clientObject.origin_coordinate_y = origin_coordinate_y
clientObject.origin_coordinate_z = origin_coordinate_z

# Rotation Angles
clientObject.rotation_angles_sequence = rotation_angles_sequence.name

clientObject.rotation_angle_1 = rotation_angle_1
clientObject.rotation_angle_2 = rotation_angle_2
clientObject.rotation_angle_3 = rotation_angle_3

# Name
if name:
clientObject.name = name

# Comment
clientObject.comment = comment

# Adding optional parameters via dictionary
if params:
for key in params:
clientObject[key] = params[key]

print(clientObject)
# Delete None attributes for improved performance
deleteEmptyAttributes(clientObject)

# Add Coordinate System to client model
model.clientModel.service.set_coordinate_system(clientObject)
13 changes: 13 additions & 0 deletions RFEM/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2532,3 +2532,16 @@ class TimberServiceConditionsTreatmentType(Enum):
Timber Service Conditions Treatment
'''
TREATMENT_TYPE_FIRE_RETARDANT, TREATMENT_TYPE_NONE, TREATMENT_TYPE_PRESERVATIVE = range(3)

class CoordinateSystemType(Enum):
'''
Coordinate System Type
'''
TYPE_2_POINTS_AND_ANGLE, TYPE_3_POINTS, TYPE_GLOBAL_XYZ, TYPE_OFFSET_XYZ, TYPE_POINT_AND_3_ANGLES = range(5)

class CoordinateSystemRotationAnglesSequence(Enum):
'''
Coordinate System Rotation Angles Sequence
'''
SEQUENCE_XYZ, SEQUENCE_XZY, SEQUENCE_YXZ, SEQUENCE_YZX, SEQUENCE_ZXY, SEQUENCE_ZYX = range(6)

5 changes: 3 additions & 2 deletions RFEM/initModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def clearAttributes(obj):
return obj

def deleteEmptyAttributes(obj):
from enum import Enum
'''
Delete all attributes that are None for better performance.

Expand All @@ -237,13 +238,13 @@ def deleteEmptyAttributes(obj):
ValueError('WARNING: Object feeded to deleteEmptyAttributes function is not iterable. It is type: '+str(type(obj)+'.'))

for i in it:
if isinstance(i, str) or isinstance(i, int) or isinstance(i, float) or isinstance(i, bool):
if isinstance(i, str) or isinstance(i, int) or isinstance(i, float) or isinstance(i, bool) or isinstance(i, Enum):
continue
if len(i) > 2:
i = deleteEmptyAttributes(i)
elif i[1] is None or i[1] == "":
delattr(obj, i[0])
elif isinstance(i[1], str) or isinstance(i[1], int) or isinstance(i[1], float) or isinstance(i[1], bool):
elif isinstance(i[1], str) or isinstance(i[1], int) or isinstance(i[1], float) or isinstance(i[1], bool) or isinstance(i[1], Enum):
pass
else:
if isinstance(i, tuple):
Expand Down
Loading