For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

An unhandled exception occured!!

hadi's picture
Forums: 

I am using PythonOCC 0.5 release with Python 2.6.6.
When I run a part of my code, the error "An unhandled exception occured" is being displayed asking for Abort, Ignore or cancel.

this is my code:
for i in range(0, len(TheShape_Faces)):

if BaseFace.IsSame(TopoDS_Shape(TheShape_Faces[i])):

AllSLRMs.append('BaseFace')

elif MachFace.IsSame(TopoDS_Shape(TheShape_Faces[i])):

AllSLRMs.append('MachFace')

else:

#all the surfaces was unable to represent maximum edge length more than 0.75*maximumkollsutuh
#would be out!

Each_Face_Max_Length=Max_Edges_Lens[i]

if Each_Face_Max_Length

AllSLRMs.append('Out')

else:

Each_Face_No_Of_Parts=AllSursNodesParts[i]

CandFaceNodes=AllSursNodes[i]

CandFaceNorms=AllSursNorms[i]

Len=len(CandFaceNorms)

if Each_Face_No_Of_Parts==1:

AdrIP="F:\HP\SLRM_IP"+str(i)+".txt"
AdrDist="F:\HP\SLRM_Dist"+str(i)+".txt"

File_IP=open(AdrIP,"w")
File_Dist=open(AdrDist,"w")

for j in range(0,Len):

MainNorm=CandFaceNorms[j]

MainNode=CandFaceNodes[j]

MainPt=gp_Pnt(MainNode[0],MainNode[1],MainNode[2])

for k in range(0,Len):

SecNode=CandFaceNodes[k]

SecPt=gp_Pnt(SecNode[0],SecNode[1],SecNode[2])

Dist=int(MainPt.Distance(SecPt))

Temp_Norm=CandFaceNorms[k]

IP_2='%.2f' % abs(MainNorm.Dot(Temp_Norm))

if k!=j and float(IP_2>0.766) and Dist>0.75*Each_Face_Max_Length:

ATemArray=[]

ATemArray.append(IP_2)

ATemArray.append(Dist)

File_IP.write(str(IP_2)+" ")

File_Dist.write(str(Dist)+" ")

#SLRM1[j][k]=ATemArray

else:

File_IP.write(str(0)+" ")

File_Dist.write(str(0)+" ")

#SLRM[j][k]=0

File_IP.write("\n")

File_Dist.write("\n")

File_IP.close()

File_Dist.close()

elif Each_Face_No_Of_Parts>1: # this part of code has trigger the mentioned error

Each_Sur_No_Of_Div_Row=AllSursNoOfDivRows[i]

for m in range(0,Each_Sur_No_Of_Div_Row):

if m==Each_Sur_No_Of_Div_Row-1:

Fin=Len

else:

Fin=(m+1)*Each_Sur_No_Of_Div_Row

Adr1="F:\HP\SLRM_IP"+str(i)+"_"+str(m)+".txt"
Adr2="F:\HP\SLRM_Dist"+str(i)+"_"+str(m)+".txt"

File_IP=open(Adr1,"w")
File_Dist=open(Adr2,"w")

for j in range(m*Each_Sur_No_Of_Div_Row,Fin):

MainNorm=CandFaceNorms[j]

MainNode=CandFaceNodes[j]

MainPt=gp_Pnt(MainNode[0],MainNode[1],MainNode[2])

for k in range(0,Len):

SecNode=CandFaceNodes[k]

SecPt=gp_Pnt(SecNode[0],SecNode[1],SecNode[2])

Dist=int(MainPt.Distance(SecPt))

Temp_Norm=CandFaceNorms[k]

IP_2='%.2f' % abs(MainNorm.Dot(Temp_Norm))

if k!=j and float(IP_2>0.766) and Dist>0.75*Each_Face_Max_Length:

ATemArray=[]

ATemArray.append(IP_2)

ATemArray.append(Dist)

File_IP.write(str(IP_2)+" ")

File_Dist.write(str(Dist)+" ")

#SLRM1[j][k]=ATemArray

else:

File_IP.write(str(0)+" ")

File_Dist.write(str(0)+" ")

#SLRM[j][k]=0

File_IP.write("\n")

File_Dist.write("\n")

File_IP.close()

File_Dist.close()

As description, I meshed a surface with 4352 nodes. Then, I read the nodes coordinates into CandFaceNodes and the surface Normals into CandFaceNorms. Now I need a 4352*4352 matrix (named SLRM) so that I can save the dot product of any two points inside it. Also, I save the distance between any two points inside the matrix.

First, I saved all the data in a matrix and I got the same error. Then, I tried saving data inside .txt files but the same error appeared. Then, I thought that it can be because of memory error and I tried to divide the large 4352*4352 matrix into smaller matrices and save them into files, separately. No success! the same error.

It is really interesting that the code trigger the error in variable places each time! Also, it is woorthy to express that the code works with matrix of 1936*1936!!

I really appreciate any help. I am really confused and mixed up!!

Tnx
Hadi Parvaz