engineering-drawing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEngineering drawing
工程图纸
Provenance: maintained in earthtojake/text-to-cad.
Use the installed local skill files as the runtime source of truth.
An engineering drawing is a DOCUMENT derived from a part.
projects views from the part's geometry, places dimensions between points ON
that geometry, finds centre marks on it, and lays the result out on an ISO
sheet with a frame and a title block. Change the model, rerun the drawing
script, and the views, hidden lines and measured values move with it. Nothing
on the sheet is drawn by hand, and nothing on it is a number you typed unless
you chose to override a value.
cadgen.eng_drawingThe output is one PDF. That is what a shop receives and what every
operating system opens. No DXF is written, nothing is paired or linked, and
there is no CLI: the script is the interface. makes cut layouts and flat
patterns, which are toolpaths, not documents; the two are different jobs.
$dxf来源:维护于 earthtojake/text-to-cad。
使用已安装的本地 skill 文件作为运行时的事实来源。
工程图纸是从零件派生出的文档。 从零件几何体投影视图,在该几何体上的点之间放置尺寸,查找中心标记,并将结果布置到带图框和标题栏的 ISO 图页上。修改模型、重新运行绘图脚本后,视图、隐藏线和测量值都会随模型移动。图纸上没有任何内容需要手工绘制,除非你选择覆盖某个值,否则也不会有你手动输入的数字。
cadgen.eng_drawing输出是一份 PDF。 车间收到的就是它,任何操作系统也都能打开它。不生成 DXF,没有配对或链接文件,也没有 CLI:脚本本身就是界面。 用于生成切割排样和展开图样,那是刀具路径,不是文档;两者是不同的工作。
$dxfWorkflow
工作流程
-
Get the part.reads the artifact a
cadgen.read_step(Path(__file__).parent / "../STEP/part.step")model wrote (run@stepfirst); a live build123d shape works just as well. The drawing documents geometry, it does not build it.python <model>.py -
Writebeside the model, from the template. Import the model facts the dimensions reference (hole pitch, overall size, wall) from the model module rather than retyping them, so moving a feature moves its dimension.
<name>_drawing.py -
Place views with, which returns FOUR views: top, front and right in third angle with room for two rows of dimensions, plus an isometric in the free corner.
sheet.three_views(part, iso=True)returns three. Usesheet.three_views(part)(sheet millimetres from the bottom-left corner; A3 is 420 × 297, A4 is 297 × 210) only for a custom layout.sheet.view(part, name, at=(x, y)) -
Dimension what a maker needs, in MODEL coordinates: overall size per view (), feature positions and sizes (
view.overall(), withview.dimortol=where the design requires one), holes as callouts (fit=: thru, depth, counterbore, countersink, thread), and notes with leaders (view.hole). Leaveview.noteunset so the dimension is measured; give a value only where the model does not define it. Leavetextunset too and the dimension takes the next free row outside the view; pass one only to place a dimension deliberately, and remember it is measured from the dimension's own points, not the view's edge. Keep notes few and short; one wider than the sheet's note column is refused, andoffsettakes a LIST (notes=is a sequence of eleven characters, so it is refused too).notes="BREAK EDGES" -
Run. It prints the PDF it wrote, and anything it noticed while drawing — read those first:
python <name>_drawing.py- "measures blank paper": the dimension's model points do not land on the view's geometry. Almost always the part was built from a corner and the script assumed it was centred. Check the part's bounding box.
- "annotation overlaps": two callouts print on top of each other, usually
one view's outermost dimension against the label of the view above it.
Pass a bigger or place one with
three_views(gap=...). The text is measured as the renderer draws it, glyph by glyph, so this fires on ink and not on markup: a chain of toleranced dimensions is silent when the values clear each other.offset=
Steps 3 and 5 stand on their own: a sheet of views with no dimensions on it yet is a drawing, and writes its PDF.When running unattended, setto a writable directory so matplotlib's font cache does not warn.MPLCONFIGDIR -
Read the PDF and fix what collides. Check that no dimension text sits on a view, that hidden lines appear where features are behind faces, that every hole has a centre mark, and that no leader crosses the part. Very small dimensions (a few mm) put their value on their own extension line; dimension the larger feature instead. Moveor
at=and rerun.offset=
-
获取零件。读取由
cadgen.read_step(Path(__file__).parent / "../STEP/part.step")模型生成的工件(先运行@step);一个活动中的 build123d shape 也同样可用。图纸记录几何体,而不是构建几何体。python <model>.py -
在模型旁编写,参考模板。从模型模块导入尺寸所引用的模型事实(孔距、整体尺寸、壁厚),而不是重新输入,这样移动某个特征时,其尺寸也会跟着移动。
<name>_drawing.py -
使用放置视图,它会返回四个视图:第三视角的顶视图、前视图、右视图,并留有放置两行尺寸的空间,另外在空闲角落放置一个轴测图。
sheet.three_views(part, iso=True)返回三个视图。仅当需要自定义布局时,才使用sheet.three_views(part)(图页毫米坐标,从左下角起算;A3 为 420 × 297,A4 为 297 × 210)。sheet.view(part, name, at=(x, y)) -
以模型坐标标注制造者所需的尺寸:每个视图的整体尺寸()、特征位置和大小(
view.overall(),在设计需要时使用view.dim或tol=)、孔作为孔标注(fit=:通孔、深度、沉孔、锥形沉孔、螺纹),以及带引线的注释(view.hole)。让view.note保持未设置,以便尺寸由测量得到;仅在模型未定义该值的地方给出数值。也让text保持未设置,尺寸会自动取视图外的下一空行;只有在刻意放置尺寸时才传入该参数,并记住它是从尺寸自身的点开始测量的,而不是从视图边缘。注释要少而短;比图页注释列更宽的注释会被拒绝,而且offset接收的是列表(notes=是十一个字符的序列,所以也会被拒绝)。notes="BREAK EDGES" -
运行。它会打印生成的 PDF,以及绘制过程中注意到的任何问题——先读这些信息:
python <name>_drawing.py- “measures blank paper”:尺寸的模型点没有落在视图的几何体上。这几乎总是因为零件是从某个角构建的,而脚本假定它是居中的。请检查零件的包围盒。
- “annotation overlaps”:两个标注彼此重叠打印,通常是某个视图最外侧的尺寸与上方视图的标签重叠。传入更大的 ,或用
three_views(gap=...)重新放置。文本是按渲染器实际绘制的方式逐字形测量的,所以该检查基于实际墨迹而非标记:一串带公差的尺寸在数值彼此避开时,不会触发。offset=
第 3 步和第 5 步可以独立使用:一张还没有任何尺寸的视图图页本身也是一张图纸,并能写出它的 PDF。在无人值守运行时,将设置为可写目录,以免 matplotlib 的字体缓存发出警告。MPLCONFIGDIR -
阅读 PDF 并修复冲突之处。检查是否有尺寸文字压在视图上、隐藏线是否出现在特征位于面之后的区域、每个孔是否有中心标记,以及是否有引线穿过零件。非常小的尺寸(几毫米)会把数值放在自己的延伸线上;此时应标注更大的特征。移动或
at=后重新运行。offset=
What the sheet contains
图页内容
- Layers with meaning: (heavy outline),
VISIBLE(dashed),HIDDEN(centre marks),CENTER,DIM,NOTES,TITLE(frame), each printed at its own weight — 0.5 mm down to 0.18 mm, so thick reads against thin on paper. An edge is drawn once: a silhouette that the kernel returns as both visible and hidden stays onSHEET. Hidden TANGENT transitions are not drawn at all — a fillet running into a face, or the seam where a cylinder closes on itself, marks nothing a shop can see, and drawn dashed it reads as a hidden edge that is not there (on a bore, as a line down the hole's own axis).VISIBLE - Dimensions measured from the geometry, with filled arrowheads and witness lines, and true-size values at any drawing scale.
- A title block with title, part number, material, author, scale, units,
projection, revision, and the drawing function's name; numbered notes above it (the general tolerance, when given, is note 1); a revision table top-right when
SHEET n OF mis given. Text longer than its cell is set smaller, and cut with an ellipsis rather than overrun.revisions= - PDF bytes that are a function of the content: no creation date is stamped, so an unchanged drawing rebuilds to an identical file.
- 有含义的图层:(粗轮廓)、
VISIBLE(虚线)、HIDDEN(中心标记)、CENTER、DIM、NOTES、TITLE(图框),每一层按各自的线宽打印——从 0.5 mm 到 0.18 mm,因此在纸上粗线能对照细线读出层次。一条边只绘制一次:内核返回为既可见又隐藏的轮廓线保留在SHEET层。隐藏的 TANGENT 过渡线完全不绘制——例如圆角汇入平面、圆柱闭合自身的接缝,这些对车间来说没有可看的标记;若画成虚线,会被读成一个并不存在的隐藏边(在孔上,则成了沿孔轴线的线)。VISIBLE - 从几何体测量得到的尺寸,带实心箭头和尺寸界线,并且能以任意绘图比例显示真实尺寸值。
- 标题栏包含标题、零件号、材料、作者、比例、单位、投影方式、版本、和绘图函数名;其上方是编号注释(当给出一般公差时,它是注释 1);当给出
SHEET n OF m时,右上角有版本修订表。超出单元格的文字会缩小,并以省略号截断,而不是溢出。revisions= - PDF 字节是内容的函数:不盖章创建日期,因此未改变的图纸重新构建会生成完全相同的文件。
What fails loudly
会明确失败的情况
The script raises rather than writing a wrong or missing document:
- Views that run off the frame, naming a scale that has been laid out and verified to fit, or saying that no standard scale does.
- A part argument the vocabulary does not define: an unknown view name, sheet
size or projection, other than
orientation=/"h", a negative or zero diameter, a counterbore that is not a"v"pair, a(diameter, depth)that is not a number or a pair, a hole that is bothtoland given a depth,thruornotes=given a bare string, a note wider than the sheet,revisions=legs that are collinear or zero-length, a non-finiteangle()orat=.offset= - A missing renderer. The PDF is the drawing, so no matplotlib is a failure, not a skipped half. A failed render leaves no file behind.
- missing or not naming a
out=, at import time..pdf
脚本会直接报错,而不是写出错误或缺失的文档:
- 视图超出图框时,会指出已经布局并验证可容纳的比例,或说明没有任何标准比例可容纳。
- 零件参数不在词汇表定义范围内:未知的视图名称、图页尺寸或投影方式,不是
orientation=/"h",直径为负或零,沉孔不是"v"对,(diameter, depth)不是数字或一对数字,孔同时是tol又给出深度,thru或notes=传入裸字符串,注释比图页宽,revisions=的两条腿共线或长度为零,angle()或at=不是有限数值。offset= - 缺少渲染器。PDF 就是图纸,所以没有 matplotlib 就是失败,而不是跳过一半。渲染失败不会留下任何文件。
- 缺失或未指定
out=文件名,在导入时就会报错。.pdf
Limits to state in the handoff
交接时需要说明的限制
- Tolerances come only from ,
tol=andfit=that you write; get the values from the design requirements or the user, never invented. A dimension without one is nominal.general_tolerance= - Views are orthographic projections with hidden lines from the kernel; no sections, details, or auxiliary views yet. Say what a view does not show.
- The sheet keeps callouts clear of the views it knows about, and reports annotation that still prints over other annotation, but it does not check annotation against line work. Read the PDF.
- 公差只能来自你写的 、
tol=和fit=;这些值要从设计需求或用户那里获取,绝不能自行编造。没有公差的尺寸是标称尺寸。general_tolerance= - 视图是从内核得到的带隐藏线的正交投影;目前没有剖面图、局部放大图或辅助视图。要说明某个视图未显示的内容。
- 图页会避免标注与其已知的视图重叠,并报告仍然打印在其他标注之上的标注,但它不会检查标注与线稿之间的冲突。请阅读 PDF。