yassou
Mechanical
- Mar 13, 2015
- 69
Hi everybody
I Create a Model, Then Save it in this directory C:\Users\MyPCName\Desktop\Sample.
After open the Sample folder and run the .CAE file my .odb and .rpy and ... files will be saved in that directory.
In Abaqus Environment->Abaqus PDE, I run a script.
This is Part of Script:
After i run the Script in "Kernel mode", It Stick and Highlight the row 163 (raise AbaqusException, 'abaqus replay file not found'), But my .rpy files is in the C:\Users\MyPCName\Desktop\Sample directory.
Is there anybody know what should i do ?
With Best regards.
yassou.
I Create a Model, Then Save it in this directory C:\Users\MyPCName\Desktop\Sample.
After open the Sample folder and run the .CAE file my .odb and .rpy and ... files will be saved in that directory.
In Abaqus Environment->Abaqus PDE, I run a script.
This is Part of Script:
Code:
[ol 1]
[li]from abaqusConstants import *[/li]
[li]from caeModules import *[/li]
[li]import abaqus[/li]
[li]import material[/li]
[li]import sketch[/li]
[li]import part[/li]
[li]import assembly[/li]
[li]import section[/li]
[li]import mesh[/li]
[li]import regionToolset[/li]
[li]import gc[/li]
[li]import os[/li]
[li]import sys[/li]
[li]import shutil, osutils[/li]
[li]import zipfile[/li]
[li][/li]
[li][/li]
[li]def getPyScriptPath():[/li]
[li] abqVersion = abaqus.version[/li]
[li] abqMainVersion = abqVersion.split('.')[0][/li]
[li] abqSubVersion = abqVersion.split('.')[1].split('-')[0][/li]
[li] if(abqMainVersion>6 or (abqMainVersion==6 and abqSubVersion>=8)):[/li]
[li] pyName = abaqus.getCurrentScriptPath()[/li]
[li] print pyName[/li]
[li] return os.path.dirname(pyName)[/li]
[li] else:[/li]
[li] if(not os.path.isfile('abaqus.rpy')):[/li]
[li] getWarningReply('The abaqus replay file could not be found. This happens if you change the Abaqus working directory after Abaqus/CAE has started. Try to revert to the original Abaqus working directory and rerun the script.',(CANCEL,))[/li]
[li] return ''[/li]
[li] shutil.copy('abaqus.rpy', 'abaqus2.rpy')[/li]
[li] flag = False[/li]
[li] line2 = ''[/li]
[li] for line in open("abaqus2.rpy"):[/li]
[li] if line.startswith('execfile('):[/li]
[li] flag = True[/li]
[li] line2 = ''[/li]
[li] if flag:[/li]
[li] line2 = line2 + line.replace('\n','')[/li]
[li] if line.find(')') > -1:[/li]
[li] flag=False[/li]
[li] osutils.remove('abaqus2.rpy')[/li]
[li] pyName = line2.split("'")[1][/li]
[li] return pyName[:pyName.rfind("/")][/li]
[li][/li]
[li][/li]
[li]def getPyScriptName():[/li]
[li] v = abaqus.version[/li]
[li] vbis = v.split('.')[/li]
[li] major = int(vbis[0])[/li]
[li] vbis = vbis[1].split('-')[/li]
[li] minor = int(vbis[0])[/li]
[li] revision = int(vbis[1])[/li]
[li] if(major>6 or (major==6 and minor>=8)):[/li]
[li] pyName = abaqus.getCurrentScriptPath()[/li]
[li] pyName = pyName.replace('/','\\')[/li]
[li] toReturn = pyName[pyName.rfind('\\')+1:pyName.rfind('.py')][/li]
[li] return toReturn[/li]
[li] else:[/li]
[li] if(not os.path.isfile('abaqus.rpy')):[/li]
[li] getWarningReply('The abaqus replay file could not be found. This happens if you change the Abaqus working directory after Abaqus/CAE has started. Try to revert to the original Abaqus working directory and rerun the script.',(CANCEL,))[/li]
[li] return ''[/li]
[li] shutil.copy('abaqus.rpy', 'abaqus2.rpy')[/li]
[li] flag = False[/li]
[li] line2 = ''[/li]
[li] for line in open("abaqus2.rpy"):[/li]
[li] if line.startswith('execfile('):[/li]
[li] flag = True[/li]
[li] line2 = ''[/li]
[li] if flag:[/li]
[li] line2 = line2 + line.replace('\n','')[/li]
[li] if line.find(')') > -1:[/li]
[li] flag=False[/li]
[li] osutils.remove('abaqus2.rpy')[/li]
[li] pyName = line2.split("'")[1][/li]
[li] pyName = pyName.replace('/','\\')[/li]
[li] pyName = pyName[pyName.rfind('\\')+1:pyName.rfind('.py')][/li]
[li] return pyName[/li]
[li][/li]
[li][/li]
[li]def merge(seq):[/li]
[li] merged = [][/li]
[li] for s in seq:[/li]
[li] for x in s:[/li]
[li] merged.append(x)[/li]
[li] return merged[/li]
[li]def equals(a,b):[/li]
[li] tol = 5e-5*(abs(a)+abs(b))/2[/li]
[li] if(abs(a-b)<=tol):[/li]
[li] return 1[/li]
[li] else:[/li]
[li] return 0[/li]
[li]def distance(x1,y1,z1,x2,y2,z2):[/li]
[li] dist = sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)[/li]
[li] return dist[/li]
[li][/li]
[li]def findVertex(vert,x,y,z):[/li]
[li] toReturn = vert[0][/li]
[li] minDist = distance(toReturn.pointOn[0][0],toReturn.pointOn[0][1],toReturn.pointOn[0][2],x,y,z)[/li]
[li] for v in vert:[/li]
[li] newDist = distance(v.pointOn[0][0],v.pointOn[0][1],v.pointOn[0][2],x,y,z)[/li]
[li] if(newDist<minDist and (equals(v.pointOn[0][0],x) or equals(v.pointOn[0][1],y) or equals(v.pointOn[0][2],z))):[/li]
[li] minDist = newDist[/li]
[li] toReturn = v[/li]
[li] return toReturn[/li]
[li]def findVertex3(myAssembly,x,y,z):[/li]
[li] for inst in myAssembly.instances.values():[/li]
[li] vert = inst.vertices[/li]
[li] if(len(vert)>0):[/li]
[li] v = vert.findAt((x,y,z),)[/li]
[li] if(v!=None):[/li]
[li] return v[/li]
[li] return None[/li]
[li]def getValue(f,x):[/li]
[li] if(len(f[0])==0):[/li]
[li] return 0[/li]
[li] if(f[0][0]==x):[/li]
[li] return f[1][0][/li]
[li] for i in range(len(f[0])):[/li]
[li] if(f[0][i]>=x):[/li]
[li] val = f[1][i-1] + ((x-f[0][i-1])/(f[0][i]-f[0][i-1])) * (f[1][i]-f[1][i-1])[/li]
[li] return val[/li]
[li]def functionAdd(f1,f2):[/li]
[li] toReturn=[[],[]][/li]
[li] if(len(f1[0])==0):[/li]
[li] toReturn[0]=f2[0][/li]
[li] elif(len(f2[0])==0):[/li]
[li] toReturn[0]=f1[0][/li]
[li] else:[/li]
[li] j = 0[/li]
[li] i = 0[/li]
[li] tmp = 0.[/li]
[li] while (i < len(f1[0])):[/li]
[li] if(j>=len(f2[0]) or (f1[0][i]<=f2[0][j])):[/li]
[li] tmp=f1[0][i][/li]
[li] i = i+1[/li]
[li] else:[/li]
[li] tmp=f2[0][j][/li]
[li] j = j+1[/li]
[li] if(len(toReturn[0])==0):[/li]
[li] toReturn[0].append(tmp)[/li]
[li] else:[/li]
[li] if(toReturn[0][len(toReturn[0])-1]!=tmp):[/li]
[li] toReturn[0].append(tmp)[/li]
[li] for i in range(len(toReturn[0])):[/li]
[li] toReturn[1].append(getValue(f1,toReturn[0][i])+getValue(f2,toReturn[0][i]))[/li]
[li] return toReturn[/li]
[li]def functionMult(a,f1):[/li]
[li] toReturn=[[],[]][/li]
[li] toReturn[0]=f1[0][/li]
[li] for i in f1[1]:[/li]
[li] toReturn[1].append(a*i)[/li]
[li] return toReturn[/li]
[li]def getFuncData(f):[/li]
[li] toReturn=[][/li]
[li] for i in range(len(f[0])):[/li]
[li] toReturn.append([f[0][i],f[1][i]])[/li]
[li] return toReturn[/li]
[li]def main():[/li]
[li] pyPath = getPyScriptPath()[/li]
[li][/li]
[li][/li]
[li] if(pyPath==''):[/li]
[li] [highlight #8AE234]raise AbaqusException, 'abaqus replay file not found'[/highlight][/li]
[li] os.chdir(pyPath[/li]
[/ol]
Is there anybody know what should i do ?
With Best regards.
yassou.