建立方向盘项目初始版本
This commit is contained in:
25
scripts/verify_switch2020_raise10.FCMacro
Normal file
25
scripts/verify_switch2020_raise10.FCMacro
Normal file
@@ -0,0 +1,25 @@
|
||||
from pathlib import Path
|
||||
import os,traceback, FreeCAD as A, Part
|
||||
R=Path(r'C:\projects\wheel');O=R/'models'/'switch_2020_raise10_concept'
|
||||
ok=False
|
||||
try:
|
||||
d=A.openDocument(str(O/'Assembly.FCStd'));d.recompute();lines=[]
|
||||
names=['SwitchCross2020','SwitchAngleA','SwitchAngleB','SwitchCrossJoint0','SwitchCrossJoint1','MotorShim0','MotorShim1','MotorBaseCorner0','MotorBaseCorner1','CompactPlate0','CompactPlate1']
|
||||
for name in names:
|
||||
o=d.getObject(name);assert o and not o.Shape.isNull() and o.Shape.isValid(),name
|
||||
lines.append('%s valid=%s bound=%s'%(name,o.Shape.isValid(),o.Shape.BoundBox))
|
||||
pairs=[('SwitchCross2020','SwitchEnvelope')]
|
||||
for i in (0,1):
|
||||
pairs += [('MotorShim%d'%i,'NewRail%d'%i),('MotorShim%d'%i,'Rail%d'%i),('MotorShim%d'%i,'MotorBaseCorner%d'%i)]
|
||||
for j in (0,1):pairs += [('CompactPlate%d'%i,'PurchasedAngle%d%d'%(i,j)),('BoardM5_%d%d'%(i,j),'PurchasedAngle%d%d'%(i,j)),('BoardM5_%d%d'%(i,j),'CompactPlate%d'%i)]
|
||||
for aa,bb in pairs:
|
||||
a=d.getObject(aa).Shape;b=d.getObject(bb).Shape
|
||||
v=a.common(b).Volume if a.BoundBox.intersect(b.BoundBox) else 0.
|
||||
dist=a.distToShape(b)[0]
|
||||
lines.append('%s / %s overlap=%.6f distance=%.6f'%(aa,bb,v,dist))
|
||||
A.closeDocument(d.Name)
|
||||
s=Part.read(str(O/'Assembly.step'));assert not s.isNull() and s.isValid()
|
||||
lines.append('STEP valid=%s solids=%d'%(s.isValid(),len(s.Solids)))
|
||||
(O/'validation.txt').write_text('\n'.join(lines)+'\n',encoding='utf8');ok=True
|
||||
except Exception:(O/'VERIFY_ERROR.txt').write_text(traceback.format_exc(),encoding='utf8')
|
||||
finally:os._exit(0 if ok else 1)
|
||||
Reference in New Issue
Block a user