Files
wheel/scripts/compose_direct_profiles.py

24 lines
2.0 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
R=Path(r'C:\projects\wheel\models\switch_2020_direct_profiles')
def font(s):return ImageFont.truetype(r'C:\Windows\Fonts\msyh.ttc',s)
def crop(name):
im=Image.open(R/name).convert('RGB');bg=Image.new('RGB',im.size,'white');m=ImageChops.difference(im,bg).convert('L').point(lambda p:255 if p>15 else 0);b=m.getbbox();return im.crop(b) if b else im
def paste(can,im,box):
im.thumbnail((box[2]-box[0],box[3]-box[1]));can.paste(im,(box[0]+(box[2]-box[0]-im.width)//2,box[1]+(box[3]-box[1]-im.height)//2))
out=Image.new('RGB',(1900,1400),'#f4f7fb');d=ImageDraw.Draw(out)
d.text((55,25),'型材直接接触:轴线仍上移 10 mm',font=font(40),fill='#1c2c40')
d.text((58,87),'取消蓝色垫块;电机及角码沿 2020 型材调整,2020 与 3030 直接贴合。',font=font(23),fill='#3c526b')
for x1,x2 in [(35,920),(950,1865)]:d.rounded_rectangle((x1,135,x2,915),radius=16,fill='white',outline='#d5dce5',width=2)
d.text((55,149),'完整装配示意',font=font(23),fill='#25384d');d.text((970,149),'电机与型材连接局部(红色为连接角码)',font=font(24),fill='#25384d')
paste(out,crop('assembly.png'),(55,190,900,890));paste(out,crop('motor_top.png'),(970,190,1845,885))
d.rounded_rectangle((35,945,1865,1360),radius=16,fill='white',outline='#d5dce5',width=2)
d.text((60,967),'取消垫块后,电机安装位置可沿型材调整',font=font(28),fill='#a12e1e')
lines=['两侧电机 2020 与底座 3030 接触;两只红色角码保持连接。',
'电机与四只橙色角码上移 10 mm;侧面圆孔对准 2020 中心槽线。',
'按当前模型,圆孔中心距 2020 端部至少 18.13 mm;实际型材槽未建模。',
'灯光开关为估计包络;角码进入包络,真实塑料外壳和接线干涉仍未确定。',
'未建立电机角码与型材之间的螺丝、滑块螺母;连接强度和实物装配未验证。']
for i,line in enumerate(lines):d.text((60,1020+60*i),line,font=font(22),fill='#31485e')
out.save(R/'型材直接接触_3D装配示意.png')