add rigid connections - add spring stiffness for point connections

This commit is contained in:
Jesusbill
2020-08-17 17:05:31 +02:00
parent eac72dc852
commit 7f48923153
4 changed files with 151 additions and 83 deletions
+42 -9
View File
@@ -30,7 +30,8 @@ class CA2IFC:
localPlacement = self.f.createIfcLocalPlacement(None, globalAxes) localPlacement = self.f.createIfcLocalPlacement(None, globalAxes)
# TODO: create units # TODO: create units
unitAssignment = self.f.createIfcUnitAssignment() lengthUnit = self.f.createIfcSIUnit(None, 'LENGTHUNIT', None, 'METRE')
unitAssignment = self.f.createIfcUnitAssignment((lengthUnit,))
# create owner history # create owner history
ownerHistory = self.create_owner_history() ownerHistory = self.create_owner_history()
@@ -60,7 +61,7 @@ class CA2IFC:
materialIndex = [mat['ifcName'] for mat in self.data['db']['materials']].index(mpSet.split('-')[0]) materialIndex = [mat['ifcName'] for mat in self.data['db']['materials']].index(mpSet.split('-')[0])
profileIndex = [prof['ifcName'] for prof in self.data['db']['profiles']].index(mpSet.split('-')[1]) profileIndex = [prof['ifcName'] for prof in self.data['db']['profiles']].index(mpSet.split('-')[1])
material = ifcMaterials[materialIndex] material = ifcMaterials[materialIndex]
profile = ifcProfiles[materialIndex] profile = ifcProfiles[profileIndex]
matProf = self.f.createIfcMaterialProfile(self.data['db']['materials'][materialIndex]['name'] + ' | ' + self.data['db']['profiles'][profileIndex]['profileName'], None, material, profile) matProf = self.f.createIfcMaterialProfile(self.data['db']['materials'][materialIndex]['name'] + ' | ' + self.data['db']['profiles'][profileIndex]['profileName'], None, material, profile)
ifcMaterialProfileSets[i] = self.f.createIfcMaterialProfileSet(None, None, (matProf,)) ifcMaterialProfileSets[i] = self.f.createIfcMaterialProfileSet(None, None, (matProf,))
@@ -89,8 +90,8 @@ class CA2IFC:
localAxes = self.create_orientation(conn['orientation']) localAxes = self.create_orientation(conn['orientation'])
# boundary conditions # boundary conditions
if conn['appliedCondition']: if conn['appliedCondition']:
bc = conn['appliedCondition'] bc = self.create_node_applied_conditions(conn['appliedCondition'])
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, self.f.createIfcBoolean(bc['dx']), self.f.createIfcBoolean(bc['dy']), self.f.createIfcBoolean(bc['dz']), self.f.createIfcBoolean(bc['drx']), self.f.createIfcBoolean(bc['dry']), self.f.createIfcBoolean(bc['drz'])) appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
else: else:
appliedCondition = None appliedCondition = None
@@ -122,15 +123,18 @@ class CA2IFC:
for conn in el['connections']: for conn in el['connections']:
localAxes = self.create_orientation(conn['orientation']) localAxes = self.create_orientation(conn['orientation'])
if conn['appliedCondition']: if conn['appliedCondition']:
bc = conn['appliedCondition'] bc = self.create_node_applied_conditions(conn['appliedCondition'])
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, self.f.createIfcBoolean(bc['dx']), self.f.createIfcBoolean(bc['dy']), self.f.createIfcBoolean(bc['dz']), self.f.createIfcBoolean(bc['drx']), self.f.createIfcBoolean(bc['dry']), self.f.createIfcBoolean(bc['drz'])) appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
else: else:
appliedCondition = None appliedCondition = None
j = [c['ifcName'] for c in self.data['connections']].index(conn['relatedConnection']) j = [c['ifcName'] for c in self.data['connections']].index(conn['relatedConnection'])
if not conn['eccentricity']: if not conn['eccentricity']:
self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes) self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes)
else: else:
pass pointOnElement = self.f.createIfcCartesianPoint(tuple(conn['eccentricity']['pointOnElement']))
vector = conn['eccentricity']['vector']
connPointEcc = self.f.createIfcConnectionPointEccentricity(pointOnElement, None, vector[0], vector[1], vector[2])
self.f.createIfcRelConnectsWithEccentricity(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes, connPointEcc)
# assign elements and connections to group # assign elements and connections to group
self.f.createIfcRelAssignsToGroup(self.guid(), ownerHistory, None, None, tuple(ifcElements + ifcConnections), None, model) self.f.createIfcRelAssignsToGroup(self.guid(), ownerHistory, None, None, tuple(ifcElements + ifcConnections), None, model)
@@ -283,9 +287,38 @@ class CA2IFC:
return faceProdDefShape return faceProdDefShape
def create_node_applied_conditions(self, bc):
for dof in ['dx', 'dy', 'dz']:
if isinstance(bc[dof], bool):
bc[dof] = self.f.createIfcBoolean(bc[dof])
else:
bc[dof] = self.f.createIfcLinearStiffnessMeasure(bc[dof])
for dof in ['drx', 'dry', 'drz']:
if isinstance(bc[dof], bool):
bc[dof] = self.f.createIfcBoolean(bc[dof])
else:
bc[dof] = self.f.createIfcRotationalStiffnessMeasure(bc[dof])
return bc
if __name__ == '__main__': if __name__ == '__main__':
inputFilename = '' # json file to read inputFilename = 'grid_of_beams.json'
outputFilename = '' # ifc file to write outputFilename = 'grid_of_beams.ifc'
ca2ifc = CA2IFC(inputFilename, outputFilename) ca2ifc = CA2IFC(inputFilename, outputFilename)
ca2ifc.convert() ca2ifc.convert()
#
# inputFilename = 'portal_01.json'
# outputFilename = 'portal_01.ifc'
#
# ca2ifc = CA2IFC(inputFilename, outputFilename)
# ca2ifc.convert()
#
# inputFilename = 'building_01.json' # json file to read
# outputFilename = 'building_01.ifc' # ifc file to write
#
# ca2ifc = CA2IFC(inputFilename, outputFilename)
# ca2ifc.convert()
+11 -9
View File
@@ -10,6 +10,7 @@ class IFC2CA:
self.file = None self.file = None
self.result = {} self.result = {}
self.warnings = [] self.warnings = []
self.tol = 1E-06
def convert(self): def convert(self):
self.file = ifcopenshell.open(self.filename) self.file = ifcopenshell.open(self.filename)
@@ -73,10 +74,11 @@ class IFC2CA:
representation = self.get_representation(item, 'Edge') representation = self.get_representation(item, 'Edge')
material_profile = self.get_material_profile(item) material_profile = self.get_material_profile(item)
if not representation: if not representation:
# add to warnings self.warnings.append('No representation defined for %s. Member excluded' % (item.is_a() + '|' + str(item.id())))
return return
if not material_profile: if not material_profile:
#add to warnings self.warnings.append('No material defined for in %s' % (item.is_a() + '|' + str(item.id())))
self.warnings.append('No profile defined for in %s' % (item.is_a() + '|' + str(item.id())))
materialId = None materialId = None
profileId = None profileId = None
else: else:
@@ -95,8 +97,8 @@ class IFC2CA:
length = np.linalg.norm(np.array(geometry[1]) - np.array(geometry[0])) length = np.linalg.norm(np.array(geometry[1]) - np.array(geometry[0]))
for c in connections: for c in connections:
if c['eccentricity']: if c['eccentricity']:
if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length: if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length + self.tol:
# print('Eccentricity in %s corrected' % item.is_a() + '|' + str(item.id())) print((np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])), '>', length))
self.warnings.append('Eccentricity in %s corrected' % (item.is_a() + '|' + str(item.id()))) self.warnings.append('Eccentricity in %s corrected' % (item.is_a() + '|' + str(item.id())))
c['eccentricity']['pointOnElement'][0] = length c['eccentricity']['pointOnElement'][0] = length
# End <-- # End <--
@@ -125,10 +127,10 @@ class IFC2CA:
representation = self.get_representation(item, 'Face') representation = self.get_representation(item, 'Face')
material = self.get_material_profile(item) material = self.get_material_profile(item)
if not representation: if not representation:
# add to warnings self.warnings.append('No representation defined for %s. Member excluded' % (item.is_a() + '|' + str(item.id())))
return return
if not material: if not material:
#add to warnings self.warnings.append('No material defined for in %s' % (item.is_a() + '|' + str(item.id())))
materialId = None materialId = None
else: else:
materialId = material.is_a() + '|' + str(material.id()) materialId = material.is_a() + '|' + str(material.id())
@@ -161,7 +163,7 @@ class IFC2CA:
elif item.is_a('IfcStructuralPointConnection'): elif item.is_a('IfcStructuralPointConnection'):
representation = self.get_representation(item, 'Vertex') representation = self.get_representation(item, 'Vertex')
if not representation: if not representation:
# add to warnings self.warnings.append('No representation defined for %s. Connection excluded' % (item.is_a() + '|' + str(item.id())))
return return
geometry = self.get_geometry(representation) geometry = self.get_geometry(representation)
@@ -233,7 +235,7 @@ class IFC2CA:
return rep return rep
def get_specific_representation(self, representation, rep_id, rep_type): def get_specific_representation(self, representation, rep_id, rep_type):
if representation.RepresentationIdentifier == rep_id or rep_id is None \ if (representation.RepresentationIdentifier == rep_id or rep_id is None) \
and representation.RepresentationType == rep_type: and representation.RepresentationType == rep_type:
return representation return representation
if representation.RepresentationType == 'MappedRepresentation': if representation.RepresentationType == 'MappedRepresentation':
@@ -453,7 +455,7 @@ class IFC2CA:
} }
if __name__ == '__main__': if __name__ == '__main__':
fileNames = ['cantilever_01', 'portal_01'] fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams']
files = fileNames files = fileNames
for fileName in files: for fileName in files:
+54 -41
View File
@@ -34,7 +34,13 @@ class COMMANDFILE:
for rel in el['connections']: for rel in el['connections']:
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0] conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
if conn['geometryType'] == 'point': if conn['geometryType'] == 'point':
rel['groupName'] = self.getGroupName(rel['relatingElement']) + '_0DC_' + self.getGroupName(rel['relatedConnection']) rel['groupName1'] = self.getGroupName(rel['relatingElement']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])
if rel['eccentricity']:
rel['groupName2'] = self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(rel['relatingElement'])
rel['index'] = len(conn['relatedElements']) + 1
rel['unifiedGroupName'] = self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index']
else:
rel['groupName2'] = self.getGroupName(rel['relatedConnection'])
rel['springGroupName'] = self.getGroupName(rel['relatingElement']) + '_1DS_' + self.getGroupName(rel['relatedConnection']) rel['springGroupName'] = self.getGroupName(rel['relatingElement']) + '_1DS_' + self.getGroupName(rel['relatedConnection'])
self.calculateConstraints(rel) self.calculateConstraints(rel)
conn['relatedElements'].append(rel) conn['relatedElements'].append(rel)
@@ -50,18 +56,20 @@ class COMMANDFILE:
unifiedConnection = False unifiedConnection = False
rigidLinkGroupNames = [] rigidLinkGroupNames = []
# for conn in connections: for conn in connections:
# conn['relatedGroupNames'] = tuple([self.getGroupName(rel['relatingElement']) + '_0DC_' + self.getGroupName(conn['ifcName']) for rel in conn['relatedElements']]) conn['unifiedGroupNames'] = [rel['unifiedGroupName'] for rel in conn['relatedElements'] if rel['eccentricity']]
# if not conn['appliedCondition'] and len(conn['relatedGroupNames']) == 1: # if not conn['appliedCondition'] and len(conn['unifiedGroupNames']) == 1:
# conn['appliedCondition'] = { # conn['appliedCondition'] = {
# 'dx': True, # 'dx': True,
# 'dy': True, # 'dy': True,
# 'dz': True # 'dz': True
# } # }
# if len(conn['relatedGroupNames']) > 1: if len(conn['unifiedGroupNames']) >= 1:
# unifiedConnection = True conn['unifiedGroupNames'].insert(0, self.getGroupName(conn['ifcName']))
# rigidLinkGroupNames.extend([self.getGroupName(rel['relatingElement']) + '_1DC_' + self.getGroupName(conn['ifcName']) for rel in conn['relatedElements'] if rel['eccentricity']]) conn['unifiedGroupNames'] = tuple(conn['unifiedGroupNames'])
# rigidLinkGroupNames = tuple(rigidLinkGroupNames) unifiedConnection = True
rigidLinkGroupNames.extend([self.getGroupName(rel['relatingElement']) + '_1DR_' + self.getGroupName(conn['ifcName']) for rel in conn['relatedElements'] if rel['eccentricity']])
rigidLinkGroupNames = tuple(rigidLinkGroupNames)
# Define file to write command file for code_aster # Define file to write command file for code_aster
f = open(self.asterFilename, 'w') f = open(self.asterFilename, 'w')
@@ -514,7 +522,7 @@ liaisons = AFFE_CHAR_MECA(
LIAISON_UNIF = (''' LIAISON_UNIF = ('''
) )
for conn in [conn for conn in connections if len(conn['relatedGroupNames']) > 1]: for conn in [conn for conn in connections if len(conn['unifiedGroupNames']) > 1]:
template = \ template = \
''' '''
_F( _F(
@@ -523,7 +531,7 @@ liaisons = AFFE_CHAR_MECA(
),''' ),'''
context = { context = {
'groupNames': conn['relatedGroupNames'] 'groupNames': conn['unifiedGroupNames']
} }
f.write(template.format(**context)) f.write(template.format(**context))
@@ -600,19 +608,19 @@ res_Bld = MECA_STATIQUE(
''' '''
) )
# f.write( # f.write(
# ''' # '''
# # STEP: POST-PROCESSING # # STEP: POST-PROCESSING
# res_Bld = CALC_CHAMP( # res_Bld = CALC_CHAMP(
# reuse = res_Bld, # reuse = res_Bld,
# RESULTAT = res_Bld, # RESULTAT = res_Bld,
# CONTRAINTE = ('SIEF_ELNO', 'SIGM_ELNO', 'EFGE_ELNO',), # # CONTRAINTE = ('SIEF_ELNO', 'SIGM_ELNO', 'EFGE_ELNO',),
# FORCE = ('REAC_NODA', 'FORC_NODA',), # FORCE = ('REAC_NODA', 'FORC_NODA',)
# ) # )
# ''' # '''
# ) # )
# #
# template = \ # template = \
# ''' # '''
# # STEP: MASS EXTRACTION FOR EACH ASSEMBLE # # STEP: MASS EXTRACTION FOR EACH ASSEMBLE
# FaceMass = POST_ELEM( # FaceMass = POST_ELEM(
@@ -625,13 +633,13 @@ res_Bld = MECA_STATIQUE(
# ), # ),
# )\n''' # )\n'''
# #
# context = { # context = {
# 'massList': massList, # 'massList': massList,
# } # }
# #
# f.write(template.format(**context)) # f.write(template.format(**context))
# #
# f.write( # f.write(
# ''' # '''
# IMPR_TABLE( # IMPR_TABLE(
# UNITE = 10, # UNITE = 10,
@@ -641,37 +649,42 @@ res_Bld = MECA_STATIQUE(
# # FORMAT_R = '1PE15.6', # # FORMAT_R = '1PE15.6',
# ) # )
# ''' # '''
# ) # )
# #
# f.write( # template = \
# ''' # '''
# # STEP: REACTION EXTRACTION AT THE BASE # # STEP: REACTION EXTRACTION AT THE BASE
# Reacs = POST_RELEVE_T( # Reacs = POST_RELEVE_T(
# ACTION = _F( # ACTION = _F(
# INTITULE = 'sumReac', # INTITULE = 'sumReac',
# GROUP_NO = 'grdSupps', # GROUP_NO = {groupNames},
# RESULTAT = res_Bld, # RESULTAT = res_Bld,
# NOM_CHAM = 'REAC_NODA', # NOM_CHAM = 'REAC_NODA',
# RESULTANTE = ('DX','DY','DZ',), # RESULTANTE = ('DX','DY','DZ',),
# # MOMENT = ('DRX','DRY','DRZ',), # MOMENT = ('DRX','DRY','DRZ',),
# # POINT = (0,0,0,), # POINT = (0,0,0,),
# OPERATION = 'EXTRACTION', # OPERATION = 'EXTRACTION'
# ), # )
# ) # )
# ''' # '''
# )
# #
# f.write( # context = {
# 'groupNames': point0DGroupNames,
# }
#
# f.write(template.format(**context))
#
# f.write(
# ''' # '''
# IMPR_TABLE( # IMPR_TABLE(
# UNITE = 10, # UNITE = 10,
# TABLE = Reacs, # TABLE = Reacs,
# SEPARATEUR = ',', # SEPARATEUR = ',',
# NOM_PARA = ('INTITULE', 'RESU', 'NOM_CHAM', 'INST', 'DX','DY','DZ'), # # NOM_PARA = ('INTITULE', 'RESU', 'NOM_CHAM', 'INST', 'DX','DY','DZ'),
# # FORMAT_R = '1PE12.3', # FORMAT_R = '1PE12.3',
# ) # )
# ''' # '''
# ) # )
# #
f.write( f.write(
''' '''
@@ -699,8 +712,8 @@ FIN()
def calculateConstraints(self, rel): def calculateConstraints(self, rel):
gr1 = self.getGroupName(rel['relatedConnection']) gr1 = rel['groupName1']
gr2 = rel['groupName'] gr2 = rel['groupName2']
o = np.array(rel['orientation']).transpose().tolist() o = np.array(rel['orientation']).transpose().tolist()
liaisons = { liaisons = {
'groupNames': (gr1, gr1, gr1, gr2, gr2, gr2), 'groupNames': (gr1, gr1, gr1, gr2, gr2, gr2),
@@ -771,7 +784,7 @@ FIN()
conn['liaisons'] = liaisons conn['liaisons'] = liaisons
conn['stiffnesses'] = tuple(stiffnesses) conn['stiffnesses'] = tuple(stiffnesses)
return return
if isinstance(conn['appliedCondition']['dx'], bool) and conn['appliedCondition']['dx']: if isinstance(conn['appliedCondition']['dx'], bool) and conn['appliedCondition']['dx']:
liaisons['coeffs'].append((o[0][0], o[1][0], o[2][0])) liaisons['coeffs'].append((o[0][0], o[1][0], o[2][0]))
liaisons['dofs'].append(('DX', 'DY', 'DZ')) liaisons['dofs'].append(('DX', 'DY', 'DZ'))
@@ -812,7 +825,7 @@ FIN()
conn['stiffnesses'] = tuple(stiffnesses) conn['stiffnesses'] = tuple(stiffnesses)
if __name__ == '__main__': if __name__ == '__main__':
fileNames = ['cantilever_01', 'portal_01'] fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams']
files = fileNames files = fileNames
for fileName in files: for fileName in files:
+44 -24
View File
@@ -7,6 +7,9 @@ import salome
import salome_notebook import salome_notebook
import salome_version import salome_version
import numpy as np import numpy as np
import itertools
flatten = itertools.chain.from_iterable
class MODEL: class MODEL:
def __init__(self, dataFilename, medFilename, meshSize): def __init__(self, dataFilename, medFilename, meshSize):
@@ -73,10 +76,10 @@ class MODEL:
shapeType = 'FACE' shapeType = 'FACE'
return self.geompy.MakePartition(objects, [], [], [], self.geompy.ShapeType[shapeType], 0, [], 1) return self.geompy.MakePartition(objects, [], [], [], self.geompy.ShapeType[shapeType], 0, [], 1)
# def getLinkGeometry(self, ecc, orientation, finalPoint): def getLinkGeometry(self, ecc, orientation, finalPoint):
# vector = np.array(orientation).transpose().dot(ecc['vector']) vector = np.array(orientation).transpose().dot(ecc['vector'])
# initialPoint = (np.array(finalPoint) - vector).tolist() initialPoint = (np.array(finalPoint) - vector).tolist()
# return [initialPoint, finalPoint] return [initialPoint, finalPoint]
def length(self, geometry): def length(self, geometry):
return (( return ((
@@ -150,16 +153,23 @@ class MODEL:
el['elemObj'] = self.makeObject(el['geometry'], el['geometryType']) el['elemObj'] = self.makeObject(el['geometry'], el['geometryType'])
el['connObjs'] = [None for _ in el['connections']] el['connObjs'] = [None for _ in el['connections']]
el['linkObjs'] = [None for _ in el['connections']]
el['linkPointObjs'] = [[None, None] for _ in el['connections']]
for j,rel in enumerate(el['connections']): for j,rel in enumerate(el['connections']):
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0] conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
if rel['eccentricity']:
rel['index'] = len(conn['relatedElements']) + 1
conn['relatedElements'].append(rel) conn['relatedElements'].append(rel)
if conn['geometryType'] == 'point': if conn['geometryType'] == 'point':
if not rel['eccentricity']: if not rel['eccentricity']:
el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType']) el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType'])
else: else:
pass geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry'])
# geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry']) el['connObjs'][j] = self.makeObject(geometry[0], conn['geometryType'])
# el['linkObjs'][j] = self.makeObject(geometry, 'line')
el['linkPointObjs'][j][0] = self.geompy.MakeVertex(geometry[0][0], geometry[0][1], geometry[0][2])
el['linkPointObjs'][j][1] = self.geompy.MakeVertex(geometry[1][0], geometry[1][1], geometry[1][2])
el['linkObjs'][j] = self.geompy.MakeLineTwoPnt(el['linkPointObjs'][j][0], el['linkPointObjs'][j][1])
elif conn['geometryType'] == 'line': elif conn['geometryType'] == 'line':
pass pass
elif conn['geometryType'] == 'surface': elif conn['geometryType'] == 'surface':
@@ -170,18 +180,15 @@ class MODEL:
el['elemObj'] = geompy.GetInPlace(el['partObj'], el['elemObj']) el['elemObj'] = geompy.GetInPlace(el['partObj'], el['elemObj'])
for j,rel in enumerate(el['connections']): for j,rel in enumerate(el['connections']):
el['connObjs'][j] = geompy.GetInPlace(el['partObj'], el['connObjs'][j]) el['connObjs'][j] = geompy.GetInPlace(el['partObj'], el['connObjs'][j])
# if rel['eccentricity']:
# el['linkObjs'][j] = geompy.GetInPlace(el['partObj'], el['linkObjs'][j])
for conn in connections: for conn in connections:
# if conn['appliedCondition']:
conn['connObj'] = self.makeObject(conn['geometry'], conn['geometryType']) conn['connObj'] = self.makeObject(conn['geometry'], conn['geometryType'])
# Make assemble of Building Object # Make assemble of Building Object
bldObjs = [] bldObjs = []
bldObjs.extend([el['partObj'] for el in elements]) bldObjs.extend([el['partObj'] for el in elements])
bldObjs.extend(flatten([[link for link in el['linkObjs'] if link] for el in elements]))
bldObjs.extend([conn['connObj'] for conn in connections]) bldObjs.extend([conn['connObj'] for conn in connections])
# bldObjs.extend([conn['connObj'] for conn in connections if conn['appliedCondition']])
bldComp = geompy.MakeCompound(bldObjs) bldComp = geompy.MakeCompound(bldObjs)
# bldComp = geompy.MakePartition(bldObjs, [], [], [], self.geompy.ShapeType[buildingShapeType], 0, [], 1) # bldComp = geompy.MakePartition(bldObjs, [], [], [], self.geompy.ShapeType[buildingShapeType], 0, [], 1)
@@ -193,11 +200,13 @@ class MODEL:
geompy.addToStudyInFather(el['partObj'], el['elemObj'], self.getGroupName(el['ifcName'])) geompy.addToStudyInFather(el['partObj'], el['elemObj'], self.getGroupName(el['ifcName']))
for j,rel in enumerate(el['connections']): for j,rel in enumerate(el['connections']):
geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
# if rel['eccentricity']: if rel['eccentricity']:
# geompy.addToStudyInFather(el['partObj'], el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) pass
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections: for conn in connections:
# if conn['appliedCondition']:
# geompy.addToStudy(conn['connObj'], self.getGroupName(conn['ifcName'])) # geompy.addToStudy(conn['connObj'], self.getGroupName(conn['ifcName']))
geompy.addToStudyInFather(conn['connObj'], conn['connObj'], self.getGroupName(conn['ifcName'])) geompy.addToStudyInFather(conn['connObj'], conn['connObj'], self.getGroupName(conn['ifcName']))
@@ -232,12 +241,12 @@ class MODEL:
for j,rel in enumerate(el['connections']): for j,rel in enumerate(el['connections']):
geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
# if rel['eccentricity']: if rel['eccentricity']:
# el['linkObjs'][j].SetColor(SALOMEDS.Color(0, 0, 0)) geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
# geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) geompy.addToStudyInFather(bldComp, el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
geompy.addToStudyInFather(bldComp, el['linkPointObjs'][j][1], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections: for conn in connections:
# if conn['appliedCondition']:
# conn['connObj'] = geompy.RestoreGivenSubShapes(bldComp, [conn['connObj']], GEOM.FSM_GetInPlace, False, False)[0] # conn['connObj'] = geompy.RestoreGivenSubShapes(bldComp, [conn['connObj']], GEOM.FSM_GetInPlace, False, False)[0]
geompy.addToStudyInFather(bldComp, conn['connObj'], self.getGroupName(conn['ifcName'])) geompy.addToStudyInFather(bldComp, conn['connObj'], self.getGroupName(conn['ifcName']))
@@ -312,9 +321,17 @@ class MODEL:
tempgroup = bldMesh.GroupOnGeom(el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE) tempgroup = bldMesh.GroupOnGeom(el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0] rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
# if rel['eccentricity']: if rel['eccentricity']:
# tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE) tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE)
# smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
tempgroup = bldMesh.GroupOnGeom(el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
rel['eccNode'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
tempgroup = bldMesh.GroupOnGeom(el['linkPointObjs'][j][1], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections: for conn in connections:
# if conn['appliedCondition']: # if conn['appliedCondition']:
@@ -330,8 +347,11 @@ class MODEL:
for j,rel in enumerate(el['connections']): for j,rel in enumerate(el['connections']):
grpName = bldMesh.CreateEmptyGroup(SMESH.EDGE, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection'])) grpName = bldMesh.CreateEmptyGroup(SMESH.EDGE, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
smesh.SetName(grpName, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection'])) smesh.SetName(grpName, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0] if not rel['eccentricity']:
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])]) conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0]
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])])
else:
grpName.Add([bldMesh.AddEdge([rel['eccNode'], rel['node']])])
self.mesh = bldMesh self.mesh = bldMesh
self.meshNodes = bldMesh.GetNodesId() self.meshNodes = bldMesh.GetNodesId()
@@ -365,7 +385,7 @@ class MODEL:
print('ALL Operations Completed in %g sec' % (elapsed_time)) print('ALL Operations Completed in %g sec' % (elapsed_time))
if __name__ == '__main__': if __name__ == '__main__':
fileNames = ['cantilever_01', 'portal_01'] fileNames = ['cantilever_01']
files = fileNames files = fileNames
meshSize = 0.1 meshSize = 0.1