新版本公告
~~空空如也
加载中
加载中
表情图片
评为精选
鼓励
加载中...
分享
加载中...
文件下载
加载中...

再贡献一个脚本 直接从图片转换和zip压缩生成可用的CWS文件

同样图片生成3层 每层曝光45秒 我这里干膜曝光一层即可停止取下 油墨曝光3层比较合适

不同打印机需要自己修改脚本中内嵌的.gcode和slice.conf文件内容

---

少了一句以为是注释的“; Number of Slices = 3” 而且slice.conf文件是不必要的 脚本已被修改

----cwsmake.bat---

Python
0<0# : ^ '''  @python %~f0 %*  @goto :eof ''' import zipfile from PIL import Image import numpy import sys import io import os if len(sys.argv)<2 : print('Make a CWS zipped file with 3 layers using an image file') print('Usage: python',sys.argv[0],'<image file name> <output CWS filename>') print('Example: python',sys.argv[0],'circuit.bmp circuit.cws') exit(1) if len(sys.argv)>2: cwsfile=sys.argv[2] else: cwsfile=os.path.splitext(sys.argv[1])[0]+'.cws' img = numpy.array(Image.open(sys.argv[1]).convert('L')) (h,w)=img.shape nw=int((w+2)/3) img2=numpy.empty([h,nw,3], dtype=img.dtype) for y in range(h): for x in range(nw): img2[y,x,2]=img[y,x*3] img2[y,x,1]=img[y,x*3+1if x*3+1<w else 0 img2[y,x,0]=img[y,x*3+2if x*3+2<w else 0 imgio=io.BytesIO() Image.fromarray(img2).save(imgio, format='PNG') b_png=imgio.getvalue() b_gcode=b''' ;Number of Slices = 3 G28 G21 ;Set units to be mm G91 ;Relative Positioning M17 ;Enable motors <Slice> Blank M106 S0 ;<Slice> 0 M106 S255 ;<Delay> 45000 M106 S0 ;<Slice> Blank G1 Z4.000 F20 G1 Z-3.950 F20 ;<Delay> 34000 ;<Slice> 1 M106 S255 ;<Delay> 45000 M106 S0 ;<Slice> Blank G1 Z4.000 F20 G1 Z-3.950 F20 ;<Delay> 34000 ;<Slice> 2 M106 S255 ;<Delay> 45000 M106 S0 ;<Slice> Blank G1 Z4.000 F20 G1 Z-3.950 F20 ;<Delay> 34000 M18 ;Disable Motors M106 SO G1 Z80 ;<Completed> ''' try: import zlib zipcompmode=zipfile.ZIP_DEFLATED except: zipcompmode=zipfile.ZIP_STORED with zipfile.ZipFile(cwsfile, mode='w', compression=zipcompmode) as zf: zf.writestr('b.gcode', b_gcode) zf.writestr('b000.png', b_png) zf.writestr('b001.png', b_png) zf.writestr('b002.png', b_png) print ('CWS File', cwsfile, 'created') exit(0)


游客没有发表内容的权限。想参与大家的讨论?现在就 登录注册
文号 / 900481

千古风流
名片发私信
学术分 1
总主题 58 帖总回复 933 楼拥有证书:进士 学者 机友
注册于 2020-01-22 18:44最后登录 2025-05-31 09:26
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:上海

个人简介

个人开源项目: m24h.github.io

文件下载
加载中...
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

插入资源
全部
图片
视频
音频
附件
全部
未使用
已使用
正在上传
空空如也~
上传中..{{f.progress}}%
处理中..
上传失败,点击重试
等待中...
{{f.name}}
空空如也~
(视频){{r.oname}}
{{selectedResourcesId.indexOf(r.rid) + 1}}
处理中..
处理失败
插入表情
我的表情
共享表情
Emoji
上传
注意事项
最大尺寸100px,超过会被压缩。为保证效果,建议上传前自行处理。
建议上传自己DIY的表情,严禁上传侵权内容。
点击重试等待上传{{s.progress}}%处理中...已上传,正在处理中
空空如也~
处理中...
处理失败
加载中...
草稿箱
加载中...
此处只插入正文,如果要使用草稿中的其余内容,请点击继续创作。
{{fromNow(d.toc)}}
{{getDraftInfo(d)}}
标题:{{d.t}}
内容:{{d.c}}
继续创作
删除插入插入
插入公式
评论控制
加载中...
文号:{{pid}}
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的