Simlab python二次开发1-将所有缸套内表面半径加大1mm
- 1、打开模型文件
- 2、getBodiesWithSubString()从名字得到Bodies
- 3、建Body类Group
- 3.1、定义放入Group中的Bodies
- 3.2、建Group
- 4、将缸套内表面建组,并扩半径1mm
- 4.1、simlab.getBodiesFromGroup()
- 4.2、选择圆柱特征,建面组
- 4.3、根据圆柱面(面组名)得到端点坐标和半径
- 4.4、将圆柱面(面组名)根据端点坐标扩半径1mm
1、打开模型文件
#***************************************************************
#SimLab Version 2020 Beta
#Created at Tue Oct 15 11:22:28 2019
#***************************************************************
#For debugging this python script,Please comment(#) out the line "from hwx import simlab" and uncomment the line "import simlab"
from hwx import simlab
#import simlabImportGda=''' <ImportGda UUID="D896F6DF-56FA-4134-9AD1-1010BF292223" gda="" CheckBox="ON"><tag Value="1"/><Name Value="./SampleBolck.gda"/><FileName Value="D:/study/CAEpython/getBodiesFromGroup_sample./SampleBolck.gda"/><Units Value="MilliMeter"/><Output/></ImportGda>''';
simlab.execute(ImportGda)
和matlab类似,加;不打印结果
2、getBodiesWithSubString()从名字得到Bodies
outputBodies=simlab.getBodiesWithSubString("SampleBolck.gda", ["Liners_*"])
结果为元胞类型:
3、建Body类Group
3.1、定义放入Group中的Bodies
CreateGroup=''' <CreateGroup UUID="899db3a6-bd69-4a2d-b30f-756c2b2b1954" CheckBox="OFF" isObject="4"><tag Value="-1"/><Name Value="Liner_Bodies" OldValue=""/><SupportEntities><Entities><Model>SampleBolck.gda</Model><Body>'''+str(outputBodies).replace("'",'"').strip('()')+'''</Body></Entities></SupportEntities><Type Value="Body"/><Color Value="255,206,0,"/><Dup Value="1"/></CreateGroup>''';
3.2、建Group
simlab.execute(CreateGroup)
4、将缸套内表面建组,并扩半径1mm
4.1、simlab.getBodiesFromGroup()
从Body类Group中取得Bodies的名称(元胞)
Liner_Bodies=simlab.getBodiesFromGroup('Liner_Bodies');
4.2、选择圆柱特征,建面组
i=1;#下面的for 循环将所有的缸套内表面选择后建组,并扩半径1 mm(45-46):
#本示例只将Liners_2进行处理:
#for LinerBody in Liner_Bodies:LinerBody=Liner_Bodies[0] #######GroupName="Bore_"+str(i)SelectFeatures=''' <SelectFeatures UUID="CF82E8FB-9B3E-4c02-BA93-9466C1342C6E" CheckBox="ON"><SupportEntities><Entities><Model>SampleBolck.gda</Model><Body>"'''+LinerBody+'''",</Body></Entities></SupportEntities><Arcs MinValue="0.0" MaxValue="0.0" Value="0"/><ArcsAll Value="1"/><Circles MinValue="0.0" MaxValue="5" Value="0"/><CirclesAll Value="0"/><Cones MinValue="0.0" MaxValue="0.0" Value="0"/><ConeAll Value="0"/><FullCone Value="0"/><ClosedPartialCone Value="0"/><OpenPartialCone Value="0"/><Dics MinValue="0.0" MaxValue="0.0" Value="0"/><DicsAll Value="0"/><HollowDics MinValue="0.0" MaxValue="0.0" Value="0"/><HollowDicsAll Value="0"/><Cylinders MinValue="44" MaxValue="45" Value="1"/><CylindersAll Value="0"/><FullCylinder Value="1"/><ClosedPartialCylinder Value="0"/><OpenPartialCylinder Value="0"/><Fillets MinValue="0.0" MaxValue="0.0" Value="0"/><FilletsOption Value="1"/><PlanarFaces Value="0"/><FourEdgedFaces Value="0"/><ConnectedCoaxialFaces Value="0"/><ThroughBoltHole MinValue="0.0" MaxValue="0.0" Value="0"/><BlindBoltHole MinValue="0.0" MaxValue="0.0" Value="0"/><BlindBoltHoleDepth MinValue="0.0" MaxValue="0.0" Value="0"/><CreateGrp Name="'''+GroupName+'''" Value="1"/><ArcLengthBased Value=""/></SelectFeatures>''';simlab.execute(SelectFeatures);
4.3、根据圆柱面(面组名)得到端点坐标和半径
AxPt1,AxPt2,Rad=simlab.getCylindricalFaceAttributes(GroupName)
可测知面的半径为45mm
4.4、将圆柱面(面组名)根据端点坐标扩半径1mm
AlignCylinder=''' <AlignCylinder UUID="5D271AC4-A0CE-411f-9E60-E7B17CB8B1B7" CheckBox="ON"><tag Value="-1"/><Name Value=""/><Entities><Group>"'''+GroupName+'''",</Group></Entities><Axis Point1="'''+str(AxPt1).strip('()') + '''" Point2="'''+str(AxPt2).strip('()') + '''" Value="Select"/><Radius Value="46"/><ProjectMidNodes Value="0"/><EntityType Value="1"/></AlignCylinder>''';simlab.execute(AlignCylinder);i=i+1