Files
wheel/scripts/compose_motor_base_corner.py

26 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from PIL import Image,ImageDraw,ImageFont,ImageChops
from pathlib import Path
O=Path(r'C:\projects\wheel\models\kfl_3030_motor_corner_concept')
font=r'C:\Windows\Fonts\msyh.ttc'
def f(s): return ImageFont.truetype(font,s)
canvas=Image.new('RGB',(2400,1760),'#f4f6fa');d=ImageDraw.Draw(canvas)
d.text((65,35),'电机与底座型材连接 · 3D装配示意',font=f(50),fill='#18283c')
d.text((65,106),'左右各增加一只 2020 直角角码;两根 3030 底座纵梁向编码器端各延长 20 mm',font=f(27),fill='#3e5065')
def panel(name,xy,wh,title):
x,y=xy;w,h=wh;d.rounded_rectangle((x,y,x+w,y+h),radius=18,fill='white',outline='#d9e0e9',width=2);d.text((x+20,y+15),title,font=f(28),fill='#20344c')
img=Image.open(O/name).convert('RGB');diff=ImageChops.difference(img,Image.new('RGB',img.size,'white'));bounds=diff.getbbox()
if bounds:
left,top,right,bottom=bounds;img=img.crop((max(0,left-35),max(0,top-35),min(img.width,right+35),min(img.height,bottom+35)))
img.thumbnail((w-35,h-75));canvas.paste(img,(x+(w-img.width)//2,y+60+(h-70-img.height)//2))
panel('assembly.png',(45,165),(1130,1010),'总装:红色为新增角码')
panel('motor_corner_top.png',(1225,165),(1130,1010),'电机端局部:2020、3030 与新增角码')
d.rounded_rectangle((45,1205,2355,1710),radius=18,fill='white',outline='#d9e0e9',width=2)
d.text((75,1225),'静态几何检查与说明',font=f(32),fill='#20344c')
rows=['① 新角码与原电机角码的最小模型间距约 1 mm;实物误差、螺丝与工具空间仍需核对。',
'② 新角码与电机本体约 20 mm、与蓝色编码器支架约 22.15 mm;以上均为简化模型测量。',
'③ 角码与两根型材表面相贴,接触处距离为零;筛查未发现新增实体的正体积重叠。',
'④ 型材 T 槽、螺丝及滑块螺母未建;长孔宽按 5.5 mm 假设,安装与强度需实物验证。',
'⑤ 灯光开关和接线为估计包络,本图不能确认其真实外形或运动时的干涉。']
for i,s in enumerate(rows):d.text((75,1290+i*66),s,font=f(25),fill='#9b4939' if i>=3 else '#30445b')
canvas.save(O/'电机角码_3030加长_3D装配示意.png')