Skip to content

Commit

Permalink
added delete function and session status
Browse files Browse the repository at this point in the history
corrected: '= [],' to ': list = None,'
  • Loading branch information
MichalO committed Apr 7, 2022
1 parent b153ea9 commit 7a7e02f
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 45 deletions.
2 changes: 0 additions & 2 deletions Examples/TrussGenerator_2D/TrussGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
print('dirname: ', dirName)
sys.path.append(dirName + r'/../..')
from RFEM.enums import *
from RFEM.window import *
from RFEM.dataTypes import *
from RFEM.initModel import *
from RFEM.BasicObjects.material import *
from RFEM.BasicObjects.section import *
Expand Down
6 changes: 3 additions & 3 deletions RFEM/BasicObjects/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def Beam(
rotation_parameters = [0],
start_section_no: int = 1,
end_section_no: int = 1,
distribution_parameters = [],
distribution_parameters: list = None,
comment: str = '',
params: dict = {'member_hinge_start':0, 'member_hinge_end': 0,
'member_eccentricity_start': 0, 'member_eccentricity_end': 0,
Expand Down Expand Up @@ -1268,8 +1268,8 @@ def ResultBeam(
rotation_parameters = [0],
start_section_no: int = 1,
end_section_no: int = 1,
distribution_parameters = [],
integration_parameters = [],
distribution_parameters: list = None,
integration_parameters: list = None,
comment: str = '',
params: dict = { 'end_modifications_member_start_extension': 0,
'end_modifications_member_start_slope_y': 0,
Expand Down
2 changes: 1 addition & 1 deletion RFEM/BasicObjects/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self,
@staticmethod
def Standard(
no: int = 1,
coordinate_system = [],
coordinate_system: list = None,
coordinate_system_type = NodeCoordinateSystemType.COORDINATE_SYSTEM_CARTESIAN,
comment: str = '',
params: dict = None,
Expand Down
2 changes: 1 addition & 1 deletion RFEM/LoadCasesAndCombinations/modalAnalysisSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self,
mass_conversion_type = ModalMassConversionType.MASS_CONVERSION_TYPE_Z_COMPONENTS_OF_LOADS,
mass_matrix_type = ModalMassMatrixType.MASS_MATRIX_TYPE_CONSISTENT,
number_of_modes : int = 4,
acting_masses = [],
acting_masses: list = None,
neglect_masses = ModalNeglectMasses.E_NEGLECT_MASSES_NO_NEGLECTION,
comment: str = '',
params: dict = None,
Expand Down
12 changes: 6 additions & 6 deletions RFEM/Loads/freeLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def LineLoad(
load_distribution = FreeLineLoadLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_projection = FreeLoadLoadProjection.LOAD_PROJECTION_XY_OR_UV,
load_direction = FreeLineLoadLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -173,9 +173,9 @@ def RectangularLoad(
load_distribution = FreeRectangularLoadLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_projection = FreeLoadLoadProjection.LOAD_PROJECTION_XY_OR_UV,
load_direction = FreeRectangularLoadLoadDirection.LOAD_DIRECTION_GLOBAL_Z_TRUE,
load_magnitude_parameter = [],
load_magnitude_parameter: list = None,
load_location = FreeRectangularLoadLoadLocationRectangle.LOAD_LOCATION_RECTANGLE_CORNER_POINTS,
load_location_parameter = [],
load_location_parameter: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -447,7 +447,7 @@ def CircularLoad(
load_distribution = FreeCircularLoadLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_projection = FreeLoadLoadProjection.LOAD_PROJECTION_XY_OR_UV,
load_direction = FreeCircularLoadLoadDirection.LOAD_DIRECTION_GLOBAL_Z_TRUE,
load_parameter = [],
load_parameter: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -530,8 +530,8 @@ def PolygonLoad(
load_distribution = FreePolygonLoadLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_projection = FreeLoadLoadProjection.LOAD_PROJECTION_XY_OR_UV,
load_direction = FreePolygonLoadLoadDirection.LOAD_DIRECTION_GLOBAL_Z_TRUE,
load_location = [],
load_parameter = [],
load_location: list = None,
load_parameter: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down
18 changes: 9 additions & 9 deletions RFEM/Loads/memberLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def Force(
members_no: str = '1',
load_distribution= MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction= MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
force_eccentricity: bool= False,
list_reference: bool= False,
comment: str = '',
Expand Down Expand Up @@ -373,7 +373,7 @@ def Moment(
members_no: str = '1',
load_distribution= MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction= MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -601,7 +601,7 @@ def Mass(
load_case_no: int = 1,
members_no: str = '1',
individual_mass_components: bool=False,
mass_components = [],
mass_components: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -669,7 +669,7 @@ def Temperature(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down Expand Up @@ -829,7 +829,7 @@ def TemperatureChange(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down Expand Up @@ -989,7 +989,7 @@ def AxialStrain(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_X,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down Expand Up @@ -1199,7 +1199,7 @@ def Precamber(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down Expand Up @@ -1409,7 +1409,7 @@ def Displacement(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down Expand Up @@ -1647,7 +1647,7 @@ def Rotation(
members_no: str = '1',
load_distribution = MemberLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
list_reference: bool= False,
load_over_total_length: bool= False,
comment: str = '',
Expand Down
22 changes: 11 additions & 11 deletions RFEM/Loads/membersetload.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def Force(
member_sets: str = '1',
load_distribution= MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction= MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
force_eccentricity: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -404,7 +404,7 @@ def Moment(
member_sets: str = '1',
load_distribution= MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction= MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -662,7 +662,7 @@ def Mass(
load_case_no: int = 1,
member_sets: str = '1',
individual_mass_components: bool=False,
mass_components = [],
mass_components: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down Expand Up @@ -728,7 +728,7 @@ def Temperature(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -905,7 +905,7 @@ def TemperatureChange(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def AxialStrain(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_X,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -1295,7 +1295,7 @@ def Precamber(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -1515,7 +1515,7 @@ def Displacement(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -1782,7 +1782,7 @@ def Rotation(
member_sets: str = '1',
load_distribution = MemberSetLoadDistribution.LOAD_DISTRIBUTION_UNIFORM,
load_direction = MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter = [],
load_parameter: list = None,
load_over_total_length: bool= False,
comment: str = '',
params: dict = None,
Expand Down Expand Up @@ -2238,8 +2238,8 @@ def RotaryMotion(
axis_definition_type = MemberSetLoadAxisDefinitionType.AXIS_DEFINITION_TWO_POINTS,
axis_orientation = MemberSetLoadAxisDefinitionAxisOrientation.AXIS_POSITIVE,
axis_definition = MemberSetLoadAxisDefinition.AXIS_X,
axis_definition_p1 = [],
axis_definition_p2 = [],
axis_definition_p1: list = None,
axis_definition_p2: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down
4 changes: 2 additions & 2 deletions RFEM/Loads/nodalLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def Components(
no: int= 1,
load_case_no: int= 1,
nodes_no: str= '1',
components = [],
components: list = None,
specific_direction: bool= False,
force_eccentricity: bool= False,
shifted_display: bool= False,
Expand Down Expand Up @@ -469,7 +469,7 @@ def Mass(
load_case_no: int = 1,
nodes_no: str = '1',
individual_mass_components : bool = False,
mass = [],
mass: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down
4 changes: 2 additions & 2 deletions RFEM/TypesforConcreteDesign/ConcreteDurability.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def __init__(self,
member_sets_no: str = "1",
surfaces_no: str = "1",
exposure_classes_reinforcement = [True, False, False, False],
exposure_classes_reinforcement_types = [],
exposure_classes_reinforcement_types: list = None,
exposure_classes_concrete = [False, False, False],
exposure_classes_concrete_types = [],
exposure_classes_concrete_types: list = None,
structural_class = [DurabilityStructuralClassType.STANDARD, False, False, False, False],
stainless_steel_reduction = [False],
additional_protection_reduction = [False],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self,
name: str = "RD 1",
surfaces = "1",
reinforcement_direction_type = ReinforcementDirectionType.REINFORCEMENT_DIRECTION_TYPE_FIRST_REINFORCEMENT_IN_X,
rotation_parameters = [],
rotation_parameters: list = None,
comment: str = '',
params: dict = None,
model = Model):
Expand Down
27 changes: 21 additions & 6 deletions RFEM/initModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@

class Model():
clientModel = None
clientModelLst = []
activeSession = False

def __init__(self,
new_model: bool=True,
Expand Down Expand Up @@ -161,25 +163,27 @@ def __init__(self,
modelIndex = i
new = client.service.get_model(modelIndex) + 'wsdl'
# Set transport parameter if it is the first model
if modelLs:
if Model.activeSession:
cModel = Client(new)
else:
cModel = Client(new, transport=trans)
cModel.service.delete_all_results()
cModel.service.delete_all()
else:
new = client.service.new_model(model_name) + 'wsdl'
if modelLs:
if Model.activeSession:
cModel = Client(new)
else:
cModel = Client(new, transport=trans)
if not modelLs:
Model.activeSession = True
else:
modelIndex = 0
for i,j in enumerate(modelLs.name):
if modelLs.name[i] == model_name:
modelIndex = i
new = client.service.get_model(modelIndex) + 'wsdl'
if modelLs:
if Model.activeSession:
cModel = Client(new)
else:
cModel = Client(new, transport=trans)
Expand All @@ -192,9 +196,19 @@ def __init__(self,

# when using multiple intances/model
self.clientModel = cModel
if not modelLs or not model_name in modelLs.name:
Model.clientModelLst.append(cModel)
# when using only one instace/model
if not modelLs:
Model.clientModel = cModel
Model.clientModel = cModel


def __delete__(self, index):
if len(self.clientModelLst) == 1:
self.clientModelLst.clear()
self.clientModel = None
else:
self.clientModelLst.pop(index)
self.clientModel = self.clientModelLst[-1]

def clearAtributes(obj):
'''
Expand All @@ -214,10 +228,11 @@ def clearAtributes(obj):
def closeModel(index_or_name, save_changes = False):
"""
Close any model with index or name. Be sure to close the first created
model last. It carries whole session.
model last (2,1, and then 0). It carries whole session.
"""
if isinstance(index_or_name, int):
client.service.close_model(index_or_name, save_changes)
Model.__delete__(Model, index_or_name)
elif isinstance(index_or_name, str):
modelLs = client.service.get_model_list()
for i,j in enumerate(modelLs.name):
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/test_Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if Model.clientModel is None:
Model()

pytestmark = pytest.mark.skipif(CheckIfMethodOrTypeExists(Model.clientModel,'export_to_ifc', True), reason="export_to_ifc not in RFEM GM yet")
pytest.mark.xfail(reason="Calculate_all() performs incosistently.", strict=False)
def test_export():

Model.clientModel.service.delete_all()
Expand Down

0 comments on commit 7a7e02f

Please sign in to comment.