Пример #1
0
def ConstrainedRigidBodies(Include='None', PutInInclude=0):
    dogy = list()
    if (Include == 'None'):
        RigidBodies = base.CollectEntities(constants.LSDYNA, None,
                                           "CONSTRAINED_RIGID_BODIES", False)
    else:
        RigidBodies = base.CollectEntities(constants.LSDYNA, Include,
                                           "CONSTRAINED_RIGID_BODIES", False)
    print("    Starting ConstrainedRigidBodies To RBE2 %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(RigidBodies)))
    for RigidBody in RigidBodies:
        PIDM = base.GetEntityCardValues(constants.LSDYNA, RigidBody,
                                        ('PIDM', ))['PIDM']
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PIDM)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartMNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                   entity=PartNodes[0],
                                                   fields=('NID', ))['NID']
        PIDS = base.GetEntityCardValues(constants.LSDYNA, RigidBody,
                                        ('PIDS', ))['PIDS']
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PIDS)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartSNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                   entity=PartNodes[0],
                                                   fields=('NID', ))['NID']
        RBE2 = base.CreateEntity(
            constants.NASTRAN, "RBE2", {
                'GN': PartMNode1,
                'GM1': PartSNode1,
                'No.of.Nodes': '2',
                'CM': '123456'
            })
        dogy.append(RBE2)
    print("    Finished ConstrainedRigidBodies To RBE2 %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
def exe(entities, params):
    t = base.CheckReport('Element check' + params['type_check'])
    t.has_fix = True
    if entities:
        if not (type(entities) == list):
            entities = [entities]
        if type(entities) == list:
            for entity in entities:
                entity_full = entity_cls(entity._id, params['type_check'])
                entity_full.check(params)
                ent = [
                    base.GetEntity(constants.ABAQUS, params['type_check'],
                                   entity._id)
                ]
                status, status_lenght = entity_full.check(params)
                descriptions = ''
                if status != '':
                    descriptions = status
                    t.add_issue(entities=ent,
                                status="Warning",
                                description=descriptions)
                if status_lenght != '':
                    descriptions = status_lenght
                    t.add_issue(entities=ent,
                                status="Warning",
                                description=descriptions)

    return [t]
Пример #3
0
	def CreateStepOutPut(self):
		if base.GetEntity(constants.ABAQUS, "STEP", 1) ==None:
			WorkStep=base.CreateEntity(constants.ABAQUS, "STEP",{'STEP ID':'1','Name':'Work Step 1',})
		else:
			vals={'Name':'WorkStep'}
			WorkStep=base.GetEntity(constants.ABAQUS, "STEP", 1)
			base.SetEntityCardValues(constants.ABAQUS,WorkStep,vals)
#		if base.AbqStepCollectOutputRequests(WorkStep)==None:
			base.AbqStepInsertOutputRequest(WorkStep, "*OUTPUT",)
			base.AbqStepInsertOutputRequest(WorkStep, "*ELEMENT OUTPUT", "Identifying Keys","S,E","SECTION POINTS", "all")
			base.AbqStepInsertOutputRequest(WorkStep, "*NODE OUTPUT", "Identifying Keys","U","SECTION POINTS", "all")
			base.AbqStepInsertOutputRequest(WorkStep, "*CONTACT OUTPUT", "Identifying Keys","CFORCE",)
			base.AbqStepInsertOutputRequest(WorkStep, "*OUTPUT","PARAMETER","HISTORY",)
			NSETID=[]
			for i in range(len(self.RefNodesSets)):
				NSETID.append(base.GetEntityCardValues(constants.ABAQUS,self.RefNodesSets[i],{'SID'})['SID'])	
			base.AbqStepInsertOutputRequest(WorkStep, "*NODE OUTPUT","NSET",NSETID,"Identifying Keys","RF",)
		print("Your step and output has been created! Please create output after the ref node sets are created if the outputs for them are wanted be automatically generated!")
Пример #4
0
	def BatchMesh(self):
		if os.path.isfile('work.ansa_mpar'):
			mpar='./work.ansa_mpar'
			if base.GetEntity(constants.ABAQUS, "BATCH_MESH_SESSION", 1)==None:
				NewScenario=batchmesh.GetNewMeshingScenario('Work','PIDS',)
			else:
				print("Already a Meshing Scenario!")
				NewScenario=base.GetEntity(constants.ABAQUS, "BATCH_MESH_SESSION_GROUP", 1)
			GetSession=base.GetEntity(constants.ABAQUS, "BATCH_MESH_SESSION", 1)
			SessionName = base.GetEntityCardValues(constants.ABAQUS,GetSession, ('Name',))
			print(SessionName)
			base.SetEntityCardValues(constants.ABAQUS,GetSession, {'Name':'WorkSession',})
			batchmesh.AddPartToMeshingScenario (base.CollectEntities(constants.ABAQUS, None, "__PROPERTIES__",True),NewScenario)
			batchmesh.ReadSessionMeshParams(GetSession,mpar)
			batchmesh.RunAllMeshingScenarios()
		else:
			print("please copy your work.ansa_mpar to the working directory first!")
		return
Пример #5
0
def ConstrainedExtraNodesSet(Include='None', PutInInclude='0'):
    dogy = list()
    if (Include == 'None'):
        ExtraNodes = base.CollectEntities(constants.LSDYNA, None,
                                          "CONSTRAINED_EXTRA_NODES_SET", False)
    else:
        ExtraNodes = base.CollectEntities(constants.LSDYNA, Include,
                                          "CONSTRAINED_EXTRA_NODES_SET", False)
    print("    Starting ConstrainedExtraNodesSet To RBE2 %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(ExtraNodes)))
    for ExtraNode in ExtraNodes:
        PID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                       ('PID', ))['PID']
        NSID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                        ('NSID', ))['NSID']
        SetEntity = base.GetEntity(constants.LSDYNA, 'SET', NSID)
        PartEntity = base.GetEntity(constants.LSDYNA, '__PROPERTIES__', PID)
        PartNodes = base.CollectEntities(constants.LSDYNA,
                                         PartEntity,
                                         "NODE",
                                         recursive=True)
        if (len(PartNodes) == 0):
            print("            ***Warning: Part %s has no nodes" %
                  (PartEntity._id))
            continue
        PartNode1 = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                  entity=PartNodes[0],
                                                  fields=('NID', ))['NID']
        NodeEntity = base.GetEntity(constants.LSDYNA, 'NODE', PartNode1)
        base.AddToSet(SetEntity, NodeEntity)
        RBE2 = base.CreateEntity(constants.NASTRAN, "RBE2", {
            'GN': PartNode1,
            'GM NSET': NSID,
            'CM': '123456'
        })
        dogy.append(RBE2)
    print("    Finished ConstrainedExtraNodesSet To RBE2 %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
Пример #6
0
    def findProjection(self):
        self.attributes = self.getEntityAttributes(self.gapEntity, 'GAP')
        self.property = base.GetEntity(constants.ABAQUS, 'GAP_PROP',
                                       self.attributes['PID'])
        self.propAttributes = self.getEntityAttributes(self.property,
                                                       'GAP_PROP')

        if self.propAttributes['C1'] is None or self.propAttributes[
                'C2'] is None or self.propAttributes['C3'] is None:
            #			self.checkReportTable.add_issue(entities=[self.gapEntity], status="warning" , description='Contact direction missing!')
            raise CheckedGapException('Contact direction missing!')

        pos_A = self.getNodePosition(self.attributes['GA'])
        pos_B = self.getNodePosition(self.attributes['GB'])

        vectorNodes = np.array(pos_B) - np.array(pos_A)
        vectorDirection = np.array([
            self.propAttributes['C1'], self.propAttributes['C2'],
            self.propAttributes['C3']
        ])
        vectorDirectionNorm = vectorDirection / np.linalg.norm(vectorDirection)

        self.projection = ansa.calc.DotProduct(vectorNodes,
                                               vectorDirectionNorm)
Пример #7
0
def exe(entities, params):
    t0 = base.CheckReport('Tied check - 1. wave - master and slave roles')
    t1 = base.CheckReport(
        'Tied check - 2. wave - check of GROUPs names - identification of master or slave role - Tms or Tsl'
    )
    t2 = base.CheckReport(
        'Tied check - 3. wave - check of GROUPs names - check component numbers from PARTs'
    )
    t3 = base.CheckReport(
        'Tied check - 3. wave - check of GROUPs names - check component numbers from PARTs - not possible auto fix'
    )
    t4 = base.CheckReport(
        'Tied check - 4. wave - check of consistency of GROUP names and TIEDs  names'
    )
    t5 = base.CheckReport(
        'Tied check - 5. wave - check of consistency of TIED names and PART TIED  names'
    )
    t100 = base.CheckReport('Tied check - TIEDs are OK')
    t0.has_fix = True
    t1.has_fix = True
    t2.has_fix = True
    t3.has_fix = False
    t4.has_fix = True
    t5.has_fix = True

    if entities:
        if not (type(entities) == list):
            entities = [entities]

        if type(entities) == list:
            for tied_ent in entities:

                tied = tied_cls(tied_ent._id)
                tie = [
                    base.GetEntity(constants.PAMCRASH, "CNTAC", tied_ent._id)
                ]
                tied.get_component_ids()
                # TODO OSError: [Errno5] Input/output error - can't fix
                print(
                    '----------------------------------------------------------'
                )
                print('tied name:', tied._name)
                print('tied_part_name:', tied.tied_part_name)
                print('master_name_id_part:',
                      tied.master_name_id_part['text_list'])
                print('slave_name_id_part:',
                      tied.slave_name_id_part['text_list'])
                print("part slave_name:", tied.part_slave_name)
                print("part master_name: ", tied.part_master_name)
                print("group master_name: ", tied.group_master_name)
                print("group slave_name: ", tied.group_slave_name)
                print("part_slave_composite: ", tied.part_slave_composite)
                print("part_master_composite: ", tied.part_master_composite)
                print("part_master_h: ", tied.part_master_h)
                print("part_slave_h: ", tied.part_slave_h)

                ############# zero level

                if tied.part_slave_name == " " and tied.part_master_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - both master and slave group are empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                elif tied.part_master_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - master group is empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                elif tied.part_slave_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - slave group is empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                else:
                    if (not (tied.part_slave_composite)
                            and tied.part_master_composite):
                        status = False
                    if (not (tied.part_master_composite)
                            and (tied.part_slave_composite)):
                        status = True
                    if (not (tied.part_slave_composite)
                            and not (tied.part_master_composite)):
                        if (tied.part_slave_h <= tied.part_master_h):
                            status = True
                        else:
                            status = False
                    if ((tied.part_slave_composite)
                            and (tied.part_master_composite)):
                        if (tied.part_slave_h <= tied.part_master_h):
                            status = True
                        else:
                            status = False
                    if status == False:
                        name_info = 'Tied ID: \"' + str(
                            tied._id
                        ) + "\" Name: \"" + tied._name + '\" - you should switch the master and slave group'
                        t0.add_issue(entities=tie,
                                     status="error",
                                     description=name_info)
                        status_groups = "Error"
                    name_info = ""
                    if status == True:
                        status_groups = "OK"
                        name_info = 'Tied ID: \"' + str(
                            tied._id) + "\" Name: \"" + tied._name + '\"  '

                        ############# first level

                        flag_1_level_error = True
                        flag_2_level_error = True
                        flag_3_level_error = True
                        flag_4_level_error = True
                        flag_5_level_error = True

                        if not ("Tms" in tied.group_master_name):
                            name_info = name_info + ' in master \"GROUP  NAME \" missing Tms |'
                            status_groups = "Warning"
                            flag_1_level_error = False
                            print('----------------------------')

                        if not ("Tsl" in tied.group_slave_name):
                            name_info = name_info + ' in slave \"GROUP  NAME \" missing Tsl |'
                            status_groups = "Warning"
                            flag_1_level_error = False
                            print('----------------------------')

                        ############# second level

                        if flag_1_level_error:
                            if ((str(tied.master_name_id_part["text_list"]) !=
                                 str(tied.master_name_id_group["text_list"]))):
                                name_info = name_info + 'Component id doesn\'t match with master \"GROUP NAME\" ' +str(tied.master_name_id_group["text_list"])+ \
                                 ' and master part name '+ str (tied.master_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.slave_name_id_part["text_list"]) !=
                                 str(tied.slave_name_id_group["text_list"]))):
                                name_info = name_info + 'Component id doesn\'t match with slave \"GROUP NAME\" '+str(tied.slave_name_id_group["text_list"])+ \
                                 ' and slave part name ' + str (tied.slave_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.master_name_id_part["text_list"]) !=
                                 str(tied.
                                     slave_name_id_group_master["text_list"])
                                 )):
                                name_info = name_info + 'Second component id doesn\'t match with slave \"GROUP NAME\" ' +str(tied.slave_name_id_group_master["text_list"])+ \
                                 ' and master part name '+ str (tied.master_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.slave_name_id_part["text_list"]) !=
                                 str(tied.
                                     master_name_id_group_slave["text_list"])
                                 )):
                                name_info = name_info + 'Component id doesn\'t match with master \"GROUP NAME\" '+str(tied.master_name_id_group_slave["text_list"])+ \
                                 ' and slave part name ' + str (tied.slave_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False
                        ############# third level
                        if flag_2_level_error and flag_1_level_error:
                            if (not (str(tied.master_name_id_part["text_list"])
                                     in tied.
                                     master_name_id_part__slave["text_list"])):
                                status_groups = "Warning"
                                name_info = name_info + 'Component id from master \"GROUP NAME\" '+ str(tied.master_name_id_part["text_list"])+\
                                   ' doesn\'t match component id from slave part name behind the \"glue_to\"'+ str(tied.master_name_id_part__slave["text_list"]) + ' | '
                                flag_3_level_error = False

                            if (not (str(tied.slave_name_id_part["text_list"])
                                     in tied.
                                     slave_name_id_part__master["text_list"])):
                                status_groups = "Warning"
                                name_info = name_info + ' Component id from slave \"GROUP NAME\" '+ str(tied.slave_name_id_part["text_list"])+\
                                   ' doesn\'t match component id from master part name behind the \"glue_to\" '+ str(tied.slave_name_id_part__master["text_list"])
                                flag_3_level_error = False

                        ############# fourth level ####### check the TIED name
                        if flag_2_level_error and flag_1_level_error:
                            if (str(tied.tied_name_component_id_1["text_list"])
                                    != str(
                                        tied.master_name_id_group["text_list"])
                                ):
                                status_groups = "Warning"
                                name_info = name_info + 'The first component id from \"TIED NAME\" '+tied.tied_name_component_id_1["text_list"]+\
                                   ' doesn match with master name group '+ str (tied.master_name_id_group["text_list"])+'. '
                                flag_4_level_error = False

                            if (str(tied.tied_name_component_id_2["text_list"])
                                    != str(
                                        tied.slave_name_id_group["text_list"])
                                ):
                                status_groups = "Warning"
                                name_info = name_info + 'The second  component id from \"TIED NAME\" '+str(tied.tied_name_component_id_2["text_list"])+\
                                   ' doesn match with slave name group '+str (tied.slave_name_id_group["text_list"])+'. '
                                flag_4_level_error = False

                        ############# fifth level ###### check the PART TIED name
                        if flag_2_level_error and flag_1_level_error and flag_4_level_error:
                            if (tied.tied_part_name_component_id_1["text_list"]
                                    != str(
                                        tied.master_name_id_group["text_list"])
                                ):

                                status_groups = "Warning"
                                name_info = name_info + 'The first component id from \"PART TIED NAME\" name: '+tied.tied_part_name_component_id_1["text_list"]+\
                                   ' doesn match with  component of master GROUP NAME: '+str(tied.master_name_id_group["text_list"])
                                flag_5_level_error = False

                            if (tied.tied_part_name_component_id_2["text_list"]
                                    != str(
                                        tied.slave_name_id_group["text_list"])
                                ):

                                status_groups = "Warning"
                                name_info = name_info + 'The second component id from \"PART TIED NAME\" name: '+tied.tied_part_name_component_id_2["text_list"]+\
                                   ' doesn match with  component of slave GROUP NAME: '+str(tied.slave_name_id_group["text_list"])
                                flag_5_level_error = False

                        if status_groups == "OK":
                            name_info = 'Tied is OK - ID: \"' + str(
                                tied._id) + "\" Name: \"" + tied._name + '\"  '
                            status_groups = "Warning"
                            t100.add_issue(entities=tie,
                                           status=status_groups,
                                           description=name_info)
                        if status_groups == "Error":
                            t0.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_1_level_error):
                            t1.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_2_level_error):
                            t2.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_4_level_error):
                            t4.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_5_level_error):
                            t5.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        if not (flag_3_level_error):
                            t3.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)

    return [t0, t1, t2, t3, t4, t5, t100]
Пример #8
0
    def identifyEntity(self):

        self.setEntity = base.GetEntity(constants.ABAQUS, 'SET', self.id)
Пример #9
0
 def get(search_type, element_id, deck=base.CurrentDeck(), **kwargs):
     return QDEntity.convert(
         base.GetEntity(*(deck, search_type, element_id), **kwargs))
def main():
    created_forces = list()
    solver = constants.NASTRAN
    print("Please select the FORCE CSV file...")
    filename = utils.SelectOpenFile(0, "csv file (*.csv)")
    if not filename[0]:
        return
    fileopen = open(filename[0], "r")
    for line in fileopen:
        if "Channel" not in line[:7]:
            columns = line.replace("\n", "").split(",")
            sid = columns[0]

            name = columns[1]

            grid = columns[2]

            axis = columns[3]

            if columns[3] == "FX":
                n1 = 1
                n2 = 0
                n3 = 0
                typ = "FORCE"
            if columns[3] == "FY":
                n1 = 0
                n2 = 1
                n3 = 0
                typ = "FORCE"
            if columns[3] == "FZ":
                n1 = 0
                n2 = 0
                n3 = 1
                typ = "FORCE"
            if columns[3] == "MX":
                n1 = 1
                n2 = 0
                n3 = 0
                typ = "MOMENT"
            if columns[3] == "MY":
                n1 = 0
                n2 = 1
                n3 = 0
                typ = "MOMENT"
            if columns[3] == "MZ":
                n1 = 0
                n2 = 0
                n3 = 1
                typ = "MOMENT"

            cid = columns[4]
            magn = columns[5]

            created_forces.append(
                base.CreateEntity(
                    solver, "FORCE", {
                        "TYPE": typ,
                        "Name": name,
                        "SID": sid,
                        "by": "node",
                        "G": grid,
                        "CID": cid,
                        "F": magn,
                        "N1": n1,
                        "N2": n2,
                        "N3": n3
                    }))

            bc = base.GetEntity(solver, "LOAD_SET", int(sid))
            base.SetEntityCardValues(solver, bc, {
                "Name": name,
            })

    total_forces = len(created_forces)
    print(total_forces, "forces and moments created successfully!")

    #Creating Nastran Header with Subcases...#

    header = base.CreateEntity(solver, "Nastran Header")

    text = "SOL 101\n" + "TIME = 3.15E7\n" + "CEND\n" + "$\n" + "$\n"
    text += "DISPLACEMENT(PLOT) = ALL\n" + "STRESS(PLOT) = ALL\n" + "$\n" + "$\n"

    #Creating Subcases for the different loads#
    for f in created_forces:

        name = base.GetEntityCardValues(solver, f, ("Name", ))["Name"]
        force_id = base.GetEntityCardValues(solver, f, ("SID", ))["SID"]

        text += "Subcase " + str(force_id) + "\n"
        text += "Load = " + str(
            force_id) + "\n" + "Label = " + name + "\n" + "$\n"

    #Setting the rest of the header
    text += "BEGIN BULK\n"
    text += "PARAM, AUTOSPC, YES\n" + "PARAM, GRDPNT,0\n" + "PARAM, INREL,-2\n" + "PARAM, K6ROT, 100.\n" + "PARAM, MAXRATIO,1.E8\n" + "PARAM, POST, -2\n"
    text += "$\n" + "$\n"

    base.SetNastranHeaderText(header, text)

    fileopen.close()
    print("Done!!!")
Пример #11
0
 def getNodePosition(self, nodeId):
     node = base.GetEntity(constants.ABAQUS, 'NODE', nodeId)
     vals = base.GetEntityCardValues(constants.ABAQUS, node,
                                     ['X', 'Y', 'Z'])
     return vals['X'], vals['Y'], vals['Z']
Пример #12
0
def TiedContacts(TiedConvertionType='RBE3',
                 Tol=50,
                 FileAppend=0,
                 Include='None',
                 PutInInclude='0',
                 WorkDir="./"):
    dogy = list()
    if (TiedConvertionType == 'CGAPG'):
        if (Include == 'None'):
            FileName = 'None'
        else:
            FileName = Include._name
        OutFile = open(WorkDir + FileName + '.CGAPG', 'w+')

    if (Include == 'None'):
        Contacts = base.CollectEntities(constants.LSDYNA, None, "CONTACT",
                                        False)
    else:
        Contacts = base.CollectEntities(constants.LSDYNA, Include, "CONTACT",
                                        False)
    print("    Starting Contact To %s %s" %
          (TiedConvertionType, datetime.datetime.now()))
    ents = list()
    grid_coords = list()
    new_grids_list = list()
    parts_list = list()
    connections_list = list()
    refgrid_list = list()
    for Contact in Contacts:
        Counter = 0
        #contact = ansa.base.GetEntity(constants.LSDYNA, "CONTACT", contact_id)
        contact = Contact
        contact_card = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                     entity=contact,
                                                     fields=('SSID', 'MSID',
                                                             'SSTYP', 'MSTYP'))
        # Master
        if not ('MSTYP' in contact_card and 'SSTYP' in contact_card):
            continue
        if (contact_card['MSTYP'] == '2: Part  set'):
            MasterEntities = ansa.base.GetEntity(constants.LSDYNA, "SET",
                                                 contact_card['MSID'])
            biw_containers = ansa.base.CollectEntities(constants.NASTRAN,
                                                       MasterEntities,
                                                       "__PROPERTIES__",
                                                       recursive=True)
            elems = ansa.base.CollectEntities(constants.NASTRAN,
                                              biw_containers,
                                              "__ELEMENTS__",
                                              recursive=True)
        if (contact_card['MSTYP'] == '3: Part  id'):
            biw_containers = base.GetEntity(constants.LSDYNA, "__PROPERTIES__",
                                            contact_card['MSID'])
            elems = ansa.base.CollectEntities(constants.NASTRAN,
                                              biw_containers,
                                              "__ELEMENTS__",
                                              recursive=True)
        if (contact_card['SSTYP'] == '2: Part  set') or (contact_card['SSTYP']
                                                         == '4: Node  set'):
            SlaveEntities = ansa.base.GetEntity(constants.LSDYNA, "SET",
                                                contact_card['SSID'])
            grids = ansa.base.CollectEntities(constants.NASTRAN,
                                              SlaveEntities,
                                              "GRID",
                                              recursive=True)
        if (contact_card['SSTYP'] == '3: Part  id'):
            SlaveEntities = ansa.base.GetEntity(constants.LSDYNA,
                                                "__PROPERTIES__",
                                                contact_card['SSID'])
            grids = ansa.base.CollectEntities(constants.NASTRAN,
                                              SlaveEntities,
                                              "GRID",
                                              recursive=True)
        print(
            "        Contact ID = %s, Slave nodes = %s, Master elements = %s, Tol = %s"
            % (contact._id, len(grids), len(elems), Tol))
        grid_coords_list = list()
        for grid in grids:
            grid_card = ansa.base.GetEntityCardValues(constants.LSDYNA,
                                                      entity=grid,
                                                      fields=('NID', 'X', 'Y',
                                                              'Z'))
            grid_coords = (grid_card['X'], grid_card['Y'], grid_card['Z'])
            grid_coords_list.append(grid_coords)
        NearestElements = ansa.base.NearestShell(
            search_entities=biw_containers,
            tolerance=Tol,
            coordinates=grid_coords_list)
        if (TiedConvertionType == 'CGAPG'):
            val = {'KA': '1E6', 'KB': '1E6', 'Kt': '1E6'}
            PGAP = base.CreateEntity(constants.NASTRAN, "PGAP", val)
            CONM1 = base.CreateEntity(constants.NASTRAN, "CONM1",
                                      {'GA': grids[0]._id})
            MaxID = CONM1._id
            base.DeleteEntity(CONM1, True)
            i = 0
            for i in range(len(NearestElements)):
                if (NearestElements[i]):
                    OutFile.write("\nCGAPG,%s,%s,%s,ELEM\n,%s" %
                                  (i + MaxID, PGAP._id, grids[i]._id,
                                   NearestElements[i]._id))
                    Counter = Counter + 1

        if (TiedConvertionType == 'RBE3'):
            i = 0
            refc = '123456'
            for i in range(len(NearestElements)):
                if (NearestElements[i]):
                    elem_type = base.GetEntityCardValues(
                        constants.NASTRAN,
                        entity=NearestElements[i],
                        fields=('EID', 'type'))
                    if "QUAD" in elem_type['type']:
                        elem_ret = ansa.base.GetEntityCardValues(
                            constants.NASTRAN,
                            entity=NearestElements[i],
                            fields=('G1', 'G2', 'G3', 'G4'))
                        vals = {
                            'REFGRID': grids[i]._id,
                            'REFC': refc,
                            'WT1': 1.0,
                            'C1': '123',
                            'G1': elem_ret['G1'],
                            'G2': elem_ret['G2'],
                            'G3': elem_ret['G3'],
                            'G4': elem_ret['G4'],
                            'No.of.Nodes': 5
                        }
                        RBE3 = ansa.base.CreateEntity(constants.NASTRAN,
                                                      "RBE3", vals)
                        dogy.append(RBE3)
                    if "TRIA" in elem_type['type']:
                        elem_ret = ansa.base.GetEntityCardValues(
                            constants.NASTRAN,
                            entity=NearestElements[i],
                            fields=('G1', 'G2', 'G3'))
                        vals = {
                            'REFGRID': grids[i]._id,
                            'REFC': refc,
                            'WT1': 1.0,
                            'C1': '123',
                            'G1': elem_ret['G1'],
                            'G2': elem_ret['G2'],
                            'G3': elem_ret['G3'],
                            'No.of.Nodes': 4
                        }
                        RBE3 = ansa.base.CreateEntity(constants.NASTRAN,
                                                      "RBE3", vals)
                        dogy.append(RBE3)
                    Counter = Counter + 1
        print("            %s out of %s nodes succesfuly projected" %
              (Counter, len(grids)))
    print("    Finished Contact To %s %s" %
          (TiedConvertionType, datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)