From 7f48923153246f2e2a3165256c9d14d6f0caaba2 Mon Sep 17 00:00:00 2001 From: Jesusbill Date: Mon, 17 Aug 2020 17:05:31 +0200 Subject: [PATCH] add rigid connections - add spring stiffness for point connections --- src/ifc2ca/ca2ifc.py | 51 +++++++++++++++---- src/ifc2ca/ifc2ca.py | 20 ++++---- src/ifc2ca/scriptCodeAster.py | 95 ++++++++++++++++++++--------------- src/ifc2ca/scriptSalome.py | 68 ++++++++++++++++--------- 4 files changed, 151 insertions(+), 83 deletions(-) diff --git a/src/ifc2ca/ca2ifc.py b/src/ifc2ca/ca2ifc.py index 7b0568ba1e..785f9cb613 100644 --- a/src/ifc2ca/ca2ifc.py +++ b/src/ifc2ca/ca2ifc.py @@ -30,7 +30,8 @@ class CA2IFC: localPlacement = self.f.createIfcLocalPlacement(None, globalAxes) # TODO: create units - unitAssignment = self.f.createIfcUnitAssignment() + lengthUnit = self.f.createIfcSIUnit(None, 'LENGTHUNIT', None, 'METRE') + unitAssignment = self.f.createIfcUnitAssignment((lengthUnit,)) # 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]) profileIndex = [prof['ifcName'] for prof in self.data['db']['profiles']].index(mpSet.split('-')[1]) 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) ifcMaterialProfileSets[i] = self.f.createIfcMaterialProfileSet(None, None, (matProf,)) @@ -89,8 +90,8 @@ class CA2IFC: localAxes = self.create_orientation(conn['orientation']) # boundary conditions if conn['appliedCondition']: - bc = 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'])) + bc = self.create_node_applied_conditions(conn['appliedCondition']) + appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz']) else: appliedCondition = None @@ -122,15 +123,18 @@ class CA2IFC: for conn in el['connections']: localAxes = self.create_orientation(conn['orientation']) if conn['appliedCondition']: - bc = 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'])) + bc = self.create_node_applied_conditions(conn['appliedCondition']) + appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz']) else: appliedCondition = None j = [c['ifcName'] for c in self.data['connections']].index(conn['relatedConnection']) if not conn['eccentricity']: self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes) 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 self.f.createIfcRelAssignsToGroup(self.guid(), ownerHistory, None, None, tuple(ifcElements + ifcConnections), None, model) @@ -283,9 +287,38 @@ class CA2IFC: 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__': - inputFilename = '' # json file to read - outputFilename = '' # ifc file to write + inputFilename = 'grid_of_beams.json' + outputFilename = 'grid_of_beams.ifc' ca2ifc = CA2IFC(inputFilename, outputFilename) 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() diff --git a/src/ifc2ca/ifc2ca.py b/src/ifc2ca/ifc2ca.py index 97f170bcd6..f484ab76ea 100644 --- a/src/ifc2ca/ifc2ca.py +++ b/src/ifc2ca/ifc2ca.py @@ -10,6 +10,7 @@ class IFC2CA: self.file = None self.result = {} self.warnings = [] + self.tol = 1E-06 def convert(self): self.file = ifcopenshell.open(self.filename) @@ -73,10 +74,11 @@ class IFC2CA: representation = self.get_representation(item, 'Edge') material_profile = self.get_material_profile(item) if not representation: - # add to warnings + self.warnings.append('No representation defined for %s. Member excluded' % (item.is_a() + '|' + str(item.id()))) return 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 profileId = None else: @@ -95,8 +97,8 @@ class IFC2CA: length = np.linalg.norm(np.array(geometry[1]) - np.array(geometry[0])) for c in connections: if c['eccentricity']: - if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length: - # print('Eccentricity in %s corrected' % item.is_a() + '|' + str(item.id())) + if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length + self.tol: + print((np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])), '>', length)) self.warnings.append('Eccentricity in %s corrected' % (item.is_a() + '|' + str(item.id()))) c['eccentricity']['pointOnElement'][0] = length # End <-- @@ -125,10 +127,10 @@ class IFC2CA: representation = self.get_representation(item, 'Face') material = self.get_material_profile(item) if not representation: - # add to warnings + self.warnings.append('No representation defined for %s. Member excluded' % (item.is_a() + '|' + str(item.id()))) return if not material: - #add to warnings + self.warnings.append('No material defined for in %s' % (item.is_a() + '|' + str(item.id()))) materialId = None else: materialId = material.is_a() + '|' + str(material.id()) @@ -161,7 +163,7 @@ class IFC2CA: elif item.is_a('IfcStructuralPointConnection'): representation = self.get_representation(item, 'Vertex') if not representation: - # add to warnings + self.warnings.append('No representation defined for %s. Connection excluded' % (item.is_a() + '|' + str(item.id()))) return geometry = self.get_geometry(representation) @@ -233,7 +235,7 @@ class IFC2CA: return rep 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: return representation if representation.RepresentationType == 'MappedRepresentation': @@ -453,7 +455,7 @@ class IFC2CA: } if __name__ == '__main__': - fileNames = ['cantilever_01', 'portal_01'] + fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams'] files = fileNames for fileName in files: diff --git a/src/ifc2ca/scriptCodeAster.py b/src/ifc2ca/scriptCodeAster.py index 8c8a8ca233..dd73013072 100644 --- a/src/ifc2ca/scriptCodeAster.py +++ b/src/ifc2ca/scriptCodeAster.py @@ -34,7 +34,13 @@ class COMMANDFILE: for rel in el['connections']: conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0] 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']) self.calculateConstraints(rel) conn['relatedElements'].append(rel) @@ -50,18 +56,20 @@ class COMMANDFILE: unifiedConnection = False rigidLinkGroupNames = [] - # for conn in connections: - # conn['relatedGroupNames'] = tuple([self.getGroupName(rel['relatingElement']) + '_0DC_' + self.getGroupName(conn['ifcName']) for rel in conn['relatedElements']]) - # if not conn['appliedCondition'] and len(conn['relatedGroupNames']) == 1: - # conn['appliedCondition'] = { - # 'dx': True, - # 'dy': True, - # 'dz': True - # } - # if len(conn['relatedGroupNames']) > 1: - # unifiedConnection = True - # rigidLinkGroupNames.extend([self.getGroupName(rel['relatingElement']) + '_1DC_' + self.getGroupName(conn['ifcName']) for rel in conn['relatedElements'] if rel['eccentricity']]) - # rigidLinkGroupNames = tuple(rigidLinkGroupNames) + for conn in connections: + conn['unifiedGroupNames'] = [rel['unifiedGroupName'] for rel in conn['relatedElements'] if rel['eccentricity']] + # if not conn['appliedCondition'] and len(conn['unifiedGroupNames']) == 1: + # conn['appliedCondition'] = { + # 'dx': True, + # 'dy': True, + # 'dz': True + # } + if len(conn['unifiedGroupNames']) >= 1: + conn['unifiedGroupNames'].insert(0, self.getGroupName(conn['ifcName'])) + conn['unifiedGroupNames'] = tuple(conn['unifiedGroupNames']) + 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 f = open(self.asterFilename, 'w') @@ -514,7 +522,7 @@ liaisons = AFFE_CHAR_MECA( 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 = \ ''' _F( @@ -523,7 +531,7 @@ liaisons = AFFE_CHAR_MECA( ),''' context = { - 'groupNames': conn['relatedGroupNames'] + 'groupNames': conn['unifiedGroupNames'] } f.write(template.format(**context)) @@ -600,19 +608,19 @@ res_Bld = MECA_STATIQUE( ''' ) - # f.write( + # f.write( # ''' # # STEP: POST-PROCESSING # res_Bld = CALC_CHAMP( # reuse = res_Bld, # RESULTAT = res_Bld, - # CONTRAINTE = ('SIEF_ELNO', 'SIGM_ELNO', 'EFGE_ELNO',), - # FORCE = ('REAC_NODA', 'FORC_NODA',), + # # CONTRAINTE = ('SIEF_ELNO', 'SIGM_ELNO', 'EFGE_ELNO',), + # FORCE = ('REAC_NODA', 'FORC_NODA',) # ) # ''' - # ) + # ) # - # template = \ + # template = \ # ''' # # STEP: MASS EXTRACTION FOR EACH ASSEMBLE # FaceMass = POST_ELEM( @@ -625,13 +633,13 @@ res_Bld = MECA_STATIQUE( # ), # )\n''' # - # context = { - # 'massList': massList, - # } + # context = { + # 'massList': massList, + # } # - # f.write(template.format(**context)) + # f.write(template.format(**context)) # - # f.write( + # f.write( # ''' # IMPR_TABLE( # UNITE = 10, @@ -641,37 +649,42 @@ res_Bld = MECA_STATIQUE( # # FORMAT_R = '1PE15.6', # ) # ''' - # ) + # ) # - # f.write( + # template = \ # ''' # # STEP: REACTION EXTRACTION AT THE BASE # Reacs = POST_RELEVE_T( # ACTION = _F( # INTITULE = 'sumReac', - # GROUP_NO = 'grdSupps', + # GROUP_NO = {groupNames}, # RESULTAT = res_Bld, # NOM_CHAM = 'REAC_NODA', # RESULTANTE = ('DX','DY','DZ',), - # # MOMENT = ('DRX','DRY','DRZ',), - # # POINT = (0,0,0,), - # OPERATION = 'EXTRACTION', - # ), + # MOMENT = ('DRX','DRY','DRZ',), + # POINT = (0,0,0,), + # OPERATION = 'EXTRACTION' + # ) # ) # ''' - # ) # - # f.write( + # context = { + # 'groupNames': point0DGroupNames, + # } + # + # f.write(template.format(**context)) + # + # f.write( # ''' # IMPR_TABLE( # UNITE = 10, # TABLE = Reacs, # SEPARATEUR = ',', - # NOM_PARA = ('INTITULE', 'RESU', 'NOM_CHAM', 'INST', 'DX','DY','DZ'), - # # FORMAT_R = '1PE12.3', + # # NOM_PARA = ('INTITULE', 'RESU', 'NOM_CHAM', 'INST', 'DX','DY','DZ'), + # FORMAT_R = '1PE12.3', # ) # ''' - # ) + # ) # f.write( ''' @@ -699,8 +712,8 @@ FIN() def calculateConstraints(self, rel): - gr1 = self.getGroupName(rel['relatedConnection']) - gr2 = rel['groupName'] + gr1 = rel['groupName1'] + gr2 = rel['groupName2'] o = np.array(rel['orientation']).transpose().tolist() liaisons = { 'groupNames': (gr1, gr1, gr1, gr2, gr2, gr2), @@ -771,7 +784,7 @@ FIN() conn['liaisons'] = liaisons conn['stiffnesses'] = tuple(stiffnesses) return - + if isinstance(conn['appliedCondition']['dx'], bool) and conn['appliedCondition']['dx']: liaisons['coeffs'].append((o[0][0], o[1][0], o[2][0])) liaisons['dofs'].append(('DX', 'DY', 'DZ')) @@ -812,7 +825,7 @@ FIN() conn['stiffnesses'] = tuple(stiffnesses) if __name__ == '__main__': - fileNames = ['cantilever_01', 'portal_01'] + fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams'] files = fileNames for fileName in files: diff --git a/src/ifc2ca/scriptSalome.py b/src/ifc2ca/scriptSalome.py index 3679e609e8..5662eb5100 100644 --- a/src/ifc2ca/scriptSalome.py +++ b/src/ifc2ca/scriptSalome.py @@ -7,6 +7,9 @@ import salome import salome_notebook import salome_version import numpy as np +import itertools + +flatten = itertools.chain.from_iterable class MODEL: def __init__(self, dataFilename, medFilename, meshSize): @@ -73,10 +76,10 @@ class MODEL: shapeType = 'FACE' return self.geompy.MakePartition(objects, [], [], [], self.geompy.ShapeType[shapeType], 0, [], 1) - # def getLinkGeometry(self, ecc, orientation, finalPoint): - # vector = np.array(orientation).transpose().dot(ecc['vector']) - # initialPoint = (np.array(finalPoint) - vector).tolist() - # return [initialPoint, finalPoint] + def getLinkGeometry(self, ecc, orientation, finalPoint): + vector = np.array(orientation).transpose().dot(ecc['vector']) + initialPoint = (np.array(finalPoint) - vector).tolist() + return [initialPoint, finalPoint] def length(self, geometry): return (( @@ -150,16 +153,23 @@ class MODEL: el['elemObj'] = self.makeObject(el['geometry'], el['geometryType']) 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']): 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) if conn['geometryType'] == 'point': if not rel['eccentricity']: el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType']) else: - pass - # geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry']) - # el['linkObjs'][j] = self.makeObject(geometry, 'line') + geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry']) + el['connObjs'][j] = self.makeObject(geometry[0], conn['geometryType']) + + 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': pass elif conn['geometryType'] == 'surface': @@ -170,18 +180,15 @@ class MODEL: el['elemObj'] = geompy.GetInPlace(el['partObj'], el['elemObj']) for j,rel in enumerate(el['connections']): 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: - # if conn['appliedCondition']: conn['connObj'] = self.makeObject(conn['geometry'], conn['geometryType']) # Make assemble of Building Object bldObjs = [] 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 if conn['appliedCondition']]) bldComp = geompy.MakeCompound(bldObjs) # 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'])) for j,rel in enumerate(el['connections']): geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) - # if rel['eccentricity']: - # geompy.addToStudyInFather(el['partObj'], el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) + if rel['eccentricity']: + 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: - # if conn['appliedCondition']: # geompy.addToStudy(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']): geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) - # if rel['eccentricity']: - # el['linkObjs'][j].SetColor(SALOMEDS.Color(0, 0, 0)) - # geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) + if rel['eccentricity']: + geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + 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: - # if conn['appliedCondition']: # conn['connObj'] = geompy.RestoreGivenSubShapes(bldComp, [conn['connObj']], GEOM.FSM_GetInPlace, False, False)[0] 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) smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])) rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0] - # if rel['eccentricity']: - # tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE) - # smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection'])) + if rel['eccentricity']: + tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE) + 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: # if conn['appliedCondition']: @@ -330,8 +347,11 @@ class MODEL: for j,rel in enumerate(el['connections']): 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'])) - conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0] - grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])]) + if not rel['eccentricity']: + 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.meshNodes = bldMesh.GetNodesId() @@ -365,7 +385,7 @@ class MODEL: print('ALL Operations Completed in %g sec' % (elapsed_time)) if __name__ == '__main__': - fileNames = ['cantilever_01', 'portal_01'] + fileNames = ['cantilever_01'] files = fileNames meshSize = 0.1