#***************************************************************#SimLab Version 2022 #Created at Mon Apr 22 19:05:48 2024#***************************************************************#For debugging this python script,Please comment(#) out the line "from hwx import simlab" and uncomment the line "import simlab"#import simlabfrom hwx import simlabUnitSystem=''' <UnitSystem UUID="3aca8564-4d38-4b0b-887c-6a542d4001c6"><SetCurrentDisplaySystem Name="MPA (mm t N s)"/></UnitSystem>''';
simlab.execute(UnitSystem);NodeByXYZ=''' <NodeByXYZ UUID="F200B5A2-D615-4d01-8DE2-25596B3B1EB8"><tag Value="-1"/><Name Value=""/><LocalCoordinateSystem Value="0"/><Position Value="0 mm,0 mm,0 mm"/><Node Value="1"/><UniqueNodeId Value="0"/><ModelName Value=""/></NodeByXYZ>''';
simlab.execute(NodeByXYZ);
1.2、轴瓦节点计算并建立
#***************************************************************#SimLab Version 2022 #Created at Sun Apr 21 20:29:55 2024#***************************************************************#For debugging this python script,Please comment(#) out the line "from hwx import simlab" and uncomment the line "import simlab"#import simlabfrom hwx import simlab
import numpy as np
import csvUnitSystem=''' <UnitSystem UUID="3aca8564-4d38-4b0b-887c-6a542d4001c6"><SetCurrentDisplaySystem Name="MPA (mm t N s)"/></UnitSystem>''';
simlab.execute(UnitSystem);Ni=7#轴瓦数
Nj=7#单轴瓦轴向x节点数
Nk=60#周向节点数
R=[30.,32.]#轴瓦内外半径
L=163#轴瓦间距
x=[0.,2.,6.,12.]#第一个半轴瓦节点轴向坐标
xx=[-x[3],-x[2],-x[1],x[0],x[1],x[2],x[3]]#第一个轴瓦节点轴向坐标
ang=np.linspace(0.,np.pi,Nk,False)
y=np.cos(ang)
z=np.sin(ang)withopen('C:/Users/Admin/Documents/SimLab/nodes.csv','w', newline='')asfile:writer = csv.writer(file)for i inrange(Ni):for j inrange(Nj):for k inrange(Nk):writer.writerow((i*L+xx[j],y[k],z[k],str(i+1)+str(j+1)+str(k+1).zfill(3))xij=[[[x[0],R[0],0.],[x[1],R[0],0.],[x[2],R[0],0.],[x[3],R[0],0.]],[[x[0],R[1],0.],[x[1],R[1],0.],[x[2],R[1],0.],[x[3],R[1],0.]]]for i inrange(2):for j inrange(4): NodeByXYZ=''' <NodeByXYZ UUID="F200B5A2-D615-4d01-8DE2-25596B3B1EB8"><tag Value="-1"/><Name Value=""/><LocalCoordinateSystem Value="0"/><Position Value="'''+str(xij[i][j][0])+''' mm,'''+str(xij[i][j][1])+''' mm,'''+str(xij[i][j][2])+''' mm"/><Node Value="'''+str(i+1)+str(j+1)+'''"/><UniqueNodeId Value="0"/><ModelName Value="Model_1.gda"/></NodeByXYZ>''';simlab.execute(NodeByXYZ);
2、由节点建面
2.1、由4个节点建面得到3个面单元Body
for i inrange(3):CreateFaceFromFourNodes=''' <FaceUsingFourNodes gda="" UUID="6C69767C-8731-433c-8474-BE95AE45FCDE"><SupportEntities PythonDoc="The four nodes defining the vertices of the face"><Entities><Model>Model_1.gda</Model><Node>1'''+str(i+1)+''',1'''+str(i+2)+''',2'''+str(i+1)+''',2'''+str(i+2)+'''</Node></Entities></SupportEntities><x_no.ofElements Value="1"/><y_no.ofElements Value="1"/><Element_type Value="Quad"/><tag Value="-1"/></FaceUsingFourNodes>''';simlab.execute(CreateFaceFromFourNodes);
Python环境找不到 打开设置:Ctrl Alt S 添加Local Interpreter... 打开System Interpreter,找到本地安装的Python.exe路径,然后一路点OK Trust Project 如果打开工程时,出现如下对话框,请勾选 Trust projects in ...&…