88 lines
6.0 KiB
Python
88 lines
6.0 KiB
Python
from pathlib import Path
|
|
|
|
root = Path(r'C:\projects\wheel')
|
|
source = (root / 'scripts/build_new_motor_corners_2mm_concept.FCMacro').read_text(encoding='utf-8')
|
|
source = source.replace("out=root/'models'/'new_motor_corners_2mm_concept'", "out=root/'models'/'all_new_corner_18_concept'")
|
|
source = source.replace("p=38/math.sqrt(2); xinner=p+9.5; xwall=xinner+2; xrail=xwall+2; xc=xrail+10", "p=38/math.sqrt(2); xinner=p+10.5; xwall=xinner+1.8; xrail=xwall+2; xc=xrail+10")
|
|
source = source.replace("flat=box(xinner-10,y-8,0,12,16,2)", "flat=box(xinner-10.2,y-8,0,12,16,1.8)")
|
|
source = source.replace("cap=cyl(8,2,xinner-10,y,0).common(box(xinner-18,y-8,0,8,16,2))", "cap=cyl(8,1.8,xinner-10.2,y,0).common(box(xinner-18.2,y-8,0,8,16,1.8))")
|
|
source = source.replace("leg=flat.fuse(cap).cut(cyl(2.5,2.1,p,y,-.05))", "leg=flat.fuse(cap).cut(cyl(2.5,1.9,p,y,-.05))")
|
|
source = source.replace("wall=box(xinner,y-8,0,2,16,12)", "wall=box(xinner,y-8,0,1.8,16,12)")
|
|
source = source.replace("cap2=cyl(8,2,xinner,y,12,V(1,0,0)).common(box(xinner,y-8,12,2,16,8))", "cap2=cyl(8,1.8,xinner,y,12,V(1,0,0)).common(box(xinner,y-8,12,1.8,16,8))")
|
|
source = source.replace("wall=wall.fuse(cap2).cut(cyl(2.5,2.1,xinner-.05,y,11.5,V(1,0,0)))", "wall=wall.fuse(cap2).cut(cyl(2.5,1.9,xinner-.05,y,12,V(1,0,0)))")
|
|
source = source.replace("washer=cyl(4.5,2,xwall,y,11.5,V(1,0,0)).cut(cyl(2.2,2.1,xwall-.05,y,11.5,V(1,0,0)))", "washer=cyl(4.5,2,xwall,y,12,V(1,0,0)).cut(cyl(2.2,2.1,xwall-.05,y,12,V(1,0,0)))")
|
|
source = source.replace("20x20x16x2 Ø5", "20x20x16x1.8 Ø5")
|
|
source = source.replace("box(-35,-87,z,70,30,30)", "box(-35,-85,z,70,30,30)")
|
|
source = source.replace("if o:o.ViewObject.Visibility=True\n # An initial fan", "if o:\n o.ViewObject.Visibility=True\n if stem in ('PurchasedAngle','FootHead'):\n ss=o.Shape.copy();ss.translate(V(0,2,0));o.Placement=A.Placement();o.Shape=ss\n # An initial fan")
|
|
marker = " d.recompute();d.saveAs(str(out/'Assembly_2mm垫片装配.FCStd'))"
|
|
inject = r'''
|
|
# Replace every visible old bracket, including the two types of long brackets.
|
|
# New L shape made with round distal ends. Its holes are both Ø5 mm. We model
|
|
# only sharp-bend nominal geometry; countersink and tool access are unknown.
|
|
def l_yz(x, yc, zface, upwards_z, foot_direction):
|
|
# width X=16; foot contacts y=yc, upright contacts z=zface.
|
|
t=1.8
|
|
zz=zface if upwards_z>0 else zface-t
|
|
side=box(x-8,yc,zz,16,12,t).fuse(cyl(8,t,x,yc+12,zz).common(box(x-8,yc+12,zz,16,8,t)))
|
|
side=side.cut(cyl(2.5,t+.1,x,yc+12,zz-.05))
|
|
if foot_direction>0:
|
|
foot=box(x-8,yc,zface,16,t,12).fuse(cyl(8,t,x,yc,zface+12,V(0,1,0)).common(box(x-8,yc,zface+12,16,t,8)))
|
|
foot=foot.cut(cyl(2.5,t+.1,x,yc-.05,zface+12,V(0,1,0)))
|
|
else:
|
|
foot=box(x-8,yc,zface-12,16,t,12).fuse(cyl(8,t,x,yc,zface-12,V(0,1,0)).common(box(x-8,yc,zface-20,16,t,8)))
|
|
foot=foot.cut(cyl(2.5,t+.1,x,yc-.05,zface-12,V(0,1,0)))
|
|
return side.fuse(foot).removeSplitter()
|
|
# Same purchased bracket at connections between each motor 2020 and 3030.
|
|
for i,sgn in enumerate((-1,1)):
|
|
old=d.getObject('MotorBaseCorner%d'%i); old.ViewObject.Visibility=False
|
|
add(d,'NewMotorBase%d'%i,l_yz(sgn*xc,-55,0,-1,-1),'20x20x16x1.8 NEW M4 concept',(.12,.42,.15))
|
|
# Switch cross-beam connections. Both legs assumed the same end geometry.
|
|
for i,sgn in enumerate((-1,1)):
|
|
old=d.getObject('SwitchCrossJoint%d'%i);old.ViewObject.Visibility=False
|
|
add(d,'NewSwitchBase%d'%i,l_yz(sgn*xc,-55,-122,1,1),'20x20x16x1.8 NEW M4 concept',(.12,.42,.15))
|
|
# New small brackets on the four 70 mm cross-beam to 3030 joints. Slot and
|
|
# screw centre alignment checked separately: crossbeam and rail centre Y
|
|
# differ by 2 mm, larger than the available nominal M4/Ø5 clearance.
|
|
def l_xz(side, zface, y):
|
|
t=1.8; inner=side*(xc-15)
|
|
if side>0:
|
|
x0=inner-t; direction=-1
|
|
else:
|
|
x0=inner; direction=1
|
|
if direction>0:
|
|
face=box(inner,y-8,zface,12,16,t).fuse(cyl(8,t,inner+12,y,zface).common(box(inner+12,y-8,zface,8,16,t)))
|
|
face=face.cut(cyl(2.5,t+.1,inner+12,y,zface-.05))
|
|
else:
|
|
face=box(inner-12,y-8,zface,12,16,t).fuse(cyl(8,t,inner-12,y,zface).common(box(inner-20,y-8,zface,8,16,t)))
|
|
face=face.cut(cyl(2.5,t+.1,inner-12,y,zface-.05))
|
|
# Plane on inside of rail; legs extend from zface toward the 3030 slot.
|
|
vert=box(x0,y-8,zface, t,16,12).fuse(cyl(8,t,x0,y,zface+12,V(1,0,0)).common(box(x0,y-8,zface+12,t,16,8)))
|
|
vert=vert.cut(cyl(2.5,t+.1,x0-.05,y,zface+12,V(1,0,0)))
|
|
return face.fuse(vert).removeSplitter()
|
|
for i in range(2):
|
|
for j,side in enumerate((-1,1)):
|
|
d.getObject('BaseJoint%d%d'%(i,j)).ViewObject.Visibility=False
|
|
zface=-84 if i==0 else -179
|
|
# For the rear bearing make the angle face outward, mirror about zface.
|
|
sh=l_xz(side,zface,-70)
|
|
if i==1: sh=sh.mirror(V(0,0,zface),V(0,0,1))
|
|
add(d,'NewBeamBase%d%d'%(i,j),sh,'20x20x16x1.8: nominal screw-axis mismatch',(.12,.42,.15))
|
|
# Four bearing and two switch long-slot brackets intentionally remain, per
|
|
# user clarification. Beam top and long-angle feet rise 2mm to align beam and
|
|
# longitudinal 3030 groove centre lines; plate, shaft, and motor stay fixed.
|
|
new_joint_checks=[]
|
|
for i in range(2):
|
|
for j in range(2):
|
|
n='NewBeamBase%d%d'%(i,j);a=d.getObject(n)
|
|
new_joint_checks.append({'name':n,'cross':cc(a.Shape,d.getObject('Crossbeam%d'%i).Shape),'base':cc(a.Shape,d.getObject('NewRail%d'%j).Shape)})
|
|
'''
|
|
if source.count(marker)<1:
|
|
raise RuntimeError('marker mismatch')
|
|
source=source.replace(marker,inject+marker,1)
|
|
source=source.replace('Assembly_2mm垫片装配','Assembly_新小角码装配_概念')
|
|
source=source.replace('2mm方案_总装.png','新小角码_长角码保留_3D.png')
|
|
source=source.replace("'base_joint_checks':joint_checks", "'base_joint_checks':new_joint_checks")
|
|
source=source.replace('Concept assembly: 70mm crossbeams and original base joints restored; real T slots, screws and fan hubs unmodelled.', 'All 12 small angles replaced with nominal 20x20x16x1.8; 6 long-slot angles retained; real T slots, screws and fan hubs unmodelled.')
|
|
(root/'scripts/build_all_new_corner_18_concept.FCMacro').write_text(source,encoding='utf-8')
|
|
print('ready')
|