You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
4.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# -*- coding: utf-8 -*-
"""Модель для чертежей: детали из cad/build_model.build() и их «чертёжные» копии (условности ГОСТ 2.109/2.305/2.311)."""
from drawings.dw_env import bm, BOM, MODEL2POS
from drawings import dw_geom as G
# Штриховка (ГОСТ 2.306): металлы — 45°; смежные детали — разный наклон или шаг; та же деталь на всех
# изображениях — одинаково; узкие сечения (≤ 2 мм на листе) — зачернены; неметаллы — «в клетку».
# Ключ — номер детали в модели (cad/build_model.py); «2н»/«4н» — наплавки.
HATCH = {
1: dict(angle=45.0, step=4.0), 2: dict(angle=135.0, step=2.0), "2н": dict(angle=45.0, step=1.0),
3: dict(angle=45.0, step=1.5, phase=0.7), 4: dict(angle=45.0, step=1.2), "4н": dict(angle=135.0, step=0.8),
5: dict(angle=135.0, step=2.5), 6: dict(angle=45.0, step=2.0, phase=1.0), 7: dict(angle=45.0, step=1.5),
8: dict(angle=135.0, step=2.0), 9: dict(angle=45.0, step=1.2), 10: dict(angle=135.0, step=2.0),
11: dict(angle=135.0, step=4.0), 12: dict(angle=45.0, step=2.0, phase=0.5), 13: dict(angle=135.0, step=1.5),
14: dict(angle=45.0, step=3.0), 15: dict(angle=45.0, step=1.0), 16: dict(angle=135.0, step=1.5),
17: dict(angle=45.0, step=2.0), 18: dict(angle=135.0, step=1.5), 19: dict(angle=45.0, step=1.0, cross=True),
20: dict(angle=45.0, step=1.2), 21: dict(angle=135.0, step=1.2), 22: dict(fill=True), 23: dict(fill=True),
24: dict(angle=45.0, step=1.2), 25: dict(angle=135.0, step=1.2),
}
class Model(object):
"""Детали модели (по номерам модели) + чертёжные копии."""
def __init__(self):
parts, info = bm.build()
self.parts = {p["pos"]: p for p in parts}
self.info = info
self.bom = {b["pos"]: b for b in BOM["parts"]}
def S(self, m):
return self.parts[m]["shape"]
def X(self, m, i=0):
return self.parts[m]["extra"][i]["shape"]
def name(self, m):
return self.parts[m]["name"]
def pos(self, m):
return MODEL2POS[m]
def items(self, plane):
"""Состав разреза по плоскости 'xz' (А–А) или 'yz' (Б–Б): (ключ, тела, режим). Кэшируется."""
cache = self.__dict__.setdefault("_items", {})
if plane not in cache:
cache[plane] = self._items_build(plane)
return cache[plane]
def _items_build(self, plane):
S = self.S
noz, noz_ov, disc, disc_ov = S(2), self.X(2), S(4), self.X(4)
st, nu = G.conv_fasteners(S(24), S(25), plane)
body = G.conv_body(S(1), plane, st)
body = G.thread_cut(body, [noz, S(20), S(21)] + st)
bonnet = G.thread_cut(G.conv_bonnet(S(11), plane), [S(12)])
ring = G.thread_cut(S(3), [noz])
locknut = G.thread_cut(S(13), [S(12)])
head = G.thread_cut(S(16), [S(7)])
cap = G.thread_cut(S(14), [S(11), S(18)])
whole = {7, 24, 25} # шток, шпильки, гайки — не рассекаются (ГОСТ 2.305, ГОСТ 2.109)
if plane == "xz":
whole |= {20} # стопорный винт — ось в плоскости А–А
else:
whole |= {15, 21} # вал (ось в плоскости Б–Б), пробка
shapes = {1: body, 2: noz, "2н": noz_ov, 3: ring, 4: disc, "4н": disc_ov, 5: S(5), 6: S(6), 7: S(7),
8: S(8), 9: S(9), 10: S(10), 11: bonnet, 12: S(12), 13: locknut, 14: cap, 15: S(15), 16: head,
17: S(17), 18: S(18), 19: S(19), 20: S(20), 21: S(21), 22: S(22), 23: S(23), 24: st, 25: nu}
out = []
for k, s in shapes.items():
mode = "sec" if k == 9 else ("whole" if k in whole else "cut")
out.append((k, s, mode))
return out

Powered by TurnKey Linux.