Exemplo n.º 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)
Exemplo n.º 2
0
def ConstrainedJointRevolute(Include='None', PutInInclude='0'):
    dogy = list()
    if (Include == 'None'):
        Joints = base.CollectEntities(constants.LSDYNA, None,
                                      "CONSTRAINED_JOINT_REVOLUTE", False)
    else:
        Joints = base.CollectEntities(constants.LSDYNA, Include,
                                      "CONSTRAINED_JOINT_REVOLUTE", False)

    PBUSH = base.CreateEntity(constants.NASTRAN, 'PBUSH', {
        'K1': '1E6',
        'K2': '1E6',
        'K3': '1E6',
        'K4': '0',
        'K5': '0',
        'K6': '0'
    })
    print("    Starting ConstrainedJointRevolute To CBUSH %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(Joints)))
    for Joint in Joints:
        N1 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N1', ))['N1']
        N2 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N2', ))['N2']
        N3 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N3', ))['N3']
        N4 = base.GetEntityCardValues(constants.LSDYNA, Joint, ('N4', ))['N4']
        CBUSH = base.CreateEntity(
            constants.NASTRAN, 'CBUSH', {
                'PID': PBUSH._id,
                'GA': N1,
                'GB': N2,
                'Orient': 'With Cord',
                'CID': '0'
            })
        CBUSH = base.CreateEntity(
            constants.NASTRAN, 'CBUSH', {
                'PID': PBUSH._id,
                'GA': N3,
                'GB': N4,
                'Orient': 'With Cord',
                'CID': '0'
            })
        dogy.append(CBUSH)
    print("    Finished ConstrainedJointSpherical To CBUSH %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
Exemplo n.º 3
0
	def CreateCouplingAndMPCs(self):
		self.CouplingSets=[i for i in self.CouplingSets if str(i).find('id:0>')==-1 and i!=None]
		self.MPCSets=[i for i in self.MPCSets if str(i).find('id:0>')==-1 and i!=None]
		for LoadSets in [self.CouplingSets,self.MPCSets]:
			for i in LoadSets:
				BoundaryArea = base.CollectEntities(constants.ABAQUS,i,{'SHELL','FACE','CONS','NODE','SOLIDFACET','SOLID',})
				BoundaryHotPoints = base.CollectEntities(constants.ABAQUS,BoundaryArea,{'NODE','HOT POINT'})
				BoundaryNodes=base.CollectEntities(constants.ABAQUS,i,{'NODE',})
#				print(BoundaryNodes+BoundaryHotPoints)
				if BoundaryNodes+BoundaryHotPoints==[]:
#					print("The contents in the sets are not supported to create coupling and MPC automatically!")
					continue
				else:
#					print(BoundaryHotPoints)
					CardVals=('X','Y','Z')
					PointTempX=[]
					PointTempY=[]
					PointTempZ=[]
			
					for BHP in BoundaryNodes+BoundaryHotPoints:
						CardValues=base.GetEntityCardValues(constants.ABAQUS, BHP,CardVals)
						PointTempX.append(CardValues['X'])
						PointTempY.append(CardValues['Y'])
						PointTempZ.append(CardValues['Z'])
					BoundaryNodeCoord=[sum(PointTempX)/len(PointTempX),sum(PointTempY)/len(PointTempY),sum(PointTempZ)/len(PointTempZ)]
					RefNode=base.CreateEntity(constants.ABAQUS, "NODE",{'X':BoundaryNodeCoord[0],'Y':BoundaryNodeCoord[1],'Z':BoundaryNodeCoord[2]})
#					print("RefNode=",RefNode)
					if LoadSets==self.CouplingSets:		
						CRCP={'COUPLING':'*DISTRIBUTING','REF NODE':base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'],'SURF.TYPE':'NODE-BASED','DOF':123,'NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'Name': 'FromSet'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
						base.CreateEntity(constants.ABAQUS,"COUPLING",CRCP)
						CRRNS1={'Name':'RefNode'+str(base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'])+'For'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						RNS1Set=base.CreateEntity(constants.ABAQUS,"SET",CRRNS1)
#						print('CRRNS1=',CRRNS1)
						base.AddToSet(RNS1Set,RefNode)
						self.RefNodesSets.append(RNS1Set)
					elif LoadSets==self.MPCSets:
						base.AddToSet(i,RefNode)
						CRMPC={'TYPE': 'BEAM', 'NSET': base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'], 'NODE0': base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'],'Name': 'FromSet'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						base.CreateEntity(constants.ABAQUS,"MPC",CRMPC)
						CRRNS2={'Name':'RefNode'+str(base.GetEntityCardValues(constants.ABAQUS,RefNode,{'ID'})['ID'])+'For'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),}
						RNS2Set=base.CreateEntity(constants.ABAQUS,"SET",CRRNS2)
						base.AddToSet(RNS2Set,RefNode)
						self.RefNodesSets.append(RNS2Set)
		return 0
Exemplo n.º 4
0
def ConstrainedExtraNodesNode(Include='None', PutInInclude='0'):
    print("Inlude File Name:%s ,ID:%s" % (Include._name, Include._id))

    dogy = list()
    if (Include == 'None'):
        ExtraNodes = base.CollectEntities(constants.LSDYNA, None,
                                          "CONSTRAINED_EXTRA_NODES_NODE",
                                          False)
    else:
        ExtraNodes = base.CollectEntities(constants.LSDYNA, Include,
                                          "CONSTRAINED_EXTRA_NODES_NODE",
                                          False)
    print("    Starting ConstrainedExtraNodesNode To RBE2 %s" %
          (datetime.datetime.now()))
    print("        Proccesing %s entities" % (len(ExtraNodes)))
    for ExtraNode in ExtraNodes:
        PID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                       ('PID', ))['PID']
        NID = base.GetEntityCardValues(constants.LSDYNA, ExtraNode,
                                       ('NID', ))['NID']
        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']
        RBE2 = base.CreateEntity(constants.NASTRAN, "RBE2", {
            'GN': PartNode1,
            'GM1': NID,
            'No.of.Nodes': '2',
            'CM': '123456'
        })
        dogy.append(RBE2)
    print("    Finished ConstrainedExtraNodesNode To RBE2 %s" %
          (datetime.datetime.now()))
    if (PutInInclude == 1 and Include != 'None'):
        base.AddToInclude(Include, dogy)
Exemplo n.º 5
0
    def __getitem__(self, key):

        # just a string key
        if isinstance(key, str):
            ret = base.GetEntityCardValues(self.myDeck, self, [key])
            if ret:
                return ret[key]
            else:
                raise KeyError('Key not found: %s' % str(key))

        # list of string key
        elif isinstance(key, (list, tuple, np.ndarray)):

            ret = base.GetEntityCardValues(self.myDeck, self, key)

            # check if all cards could be found
            if len(ret) == len(key):
                return [ret[key[ii]] for ii in range(len(key))]

            # some cards could not be found
            else:

                unknown_keys = [subkey for subkey in key if subkey not in ret]
                #unknown_keys = [ subkey for subkey in key if 0==len(base.GetEntityCardValues(self.myDeck, self, [subkey])) ]
                if unknown_keys:
                    raise KeyError("Could not find the following cards: %s" %
                                   str(unknown_keys))
                else:
                    raise KeyError("Some key (unknown) was not found in %s" %
                                   str(key))

        # unknown key type
        else:
            raise TypeError(
                "key must be of type string or list(str)/tuple(str)/np.ndarray(str), not %s."
                % str(type(key)))
Exemplo n.º 6
0
    def _checkCurrentPosition(self):

        vals = ("A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3")
        card = base.GetEntityCardValues(constants.ABAQUS, self.coorSysEntity,
                                        vals)

        self.vectorZ = np.array(
            [float(card['B1']),
             float(card['B2']),
             float(card['B3'])]) - np.array(self.originCoords)
        self.vectorX = np.array(
            [float(card['C1']),
             float(card['C2']),
             float(card['C3'])]) - np.array(self.originCoords)
        self.vectorY = np.cross(self.vectorX, self.vectorZ)
Exemplo n.º 7
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!")
Exemplo n.º 8
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
Exemplo n.º 9
0
	def CreateFixForFixSets(self):
		self.FixSets=[i for i in self.FixSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.FixSets:
			print(str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])[3:])
			BoundaryVals={ 'by': 'set','NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'DOF': str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])[3:],'Magn(N)': '0','Name':'BoundaryOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name']),'TYPE':'DISPLACEMENT',}
			base.CreateEntity(constants.ABAQUS,"BOUNDARY",BoundaryVals)
Exemplo n.º 10
0
	def CreateDloadForPressureSets(self):
		self.PressureSets=[i for i in self.PressureSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.PressureSets:
			if base.CollectEntities(constants.ABAQUS, i, "__ALL_ENTITIES__",True)!=[]:
				PressureVals={ 'by': 'set','STEP':1,'ELSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'LOAD TYPE':'P','magn(EID)':0,'Name':'DloadOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
				base.CreateEntity(constants.ABAQUS,"DLOAD",PressureVals)
Exemplo n.º 11
0
	def CreateCloadForRefNodes(self):
		self.RefNodesSets=[i for i in self.RefNodesSets if str(i).find('id:0>')==-1 and i!=None]
		for i in self.RefNodesSets:
			CloadVals={ 'by': 'set','STEP':1,'NSET':base.GetEntityCardValues(constants.ABAQUS,i,{'SID'})['SID'],'DOF': '1: Fx','magn(N)': '0','Name':'CloadOf'+str(base.GetEntityCardValues(constants.ABAQUS,i,{'Name'})['Name'])}
			base.CreateEntity(constants.ABAQUS,"CLOAD",CloadVals)
		self.PressureSets=[i for i in self.PressureSets if str(i).find('id:0>')==-1 and i!=None]
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!!!")
Exemplo n.º 13
0
 def getEntityAttributes(self, entity, type):
     fields = base.GetKeywordFieldLabels(constants.ABAQUS, type)
     return base.GetEntityCardValues(constants.ABAQUS, entity, fields)
Exemplo n.º 14
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']
Exemplo n.º 15
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)