- tech drawing and render improv
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import os, sys
|
||||
os.environ["QT_QPA_PLATFORM"] = "offscreen"
|
||||
sys.path.insert(0, "/Volumes/Data_drive/Programming/fluency/src")
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtGui import QPixmap, QPainter, QColor
|
||||
from PySide6.QtCore import QRectF
|
||||
import math
|
||||
|
||||
app = QApplication.instance() or QApplication([])
|
||||
|
||||
from fluency.geometry.base import Point2D
|
||||
from fluency.geometry_occ.kernel import OCGeometryKernel
|
||||
from fluency.models.data_model import Body, Component, Project, DrawingView, TechnicalDrawing
|
||||
from fluency.technical_drawing import generate_drawing, render_drawing, _A3_WIDTH_MM, _A3_HEIGHT_MM
|
||||
|
||||
kernel = OCGeometryKernel()
|
||||
# Long thin bar: 120 x 25 x 30 (matches the "wide bar" screenshot case).
|
||||
points = [Point2D(0, 0), Point2D(120, 0), Point2D(120, 25), Point2D(0, 25)]
|
||||
box = kernel.extrude(kernel.create_polygon(points), 30.0)
|
||||
body = Body(name="Bar", geometry=box)
|
||||
comp = Component(name="BarComp")
|
||||
comp.bodies[body.id] = body
|
||||
project = Project()
|
||||
project.components[comp.id] = comp
|
||||
project.active_component = comp.id
|
||||
|
||||
W = 2400
|
||||
H = int(W * _A3_HEIGHT_MM / _A3_WIDTH_MM)
|
||||
pm = QPixmap(W, H)
|
||||
pm.fill(QColor(255, 255, 255))
|
||||
|
||||
for name, kinds in [
|
||||
("four", ["front", "top", "right", "back"]),
|
||||
("six", ["front", "top", "right", "left", "back", "bottom"]),
|
||||
("sixiso", ["front", "top", "right", "left", "back", "bottom", "isometric"]),
|
||||
]:
|
||||
drawing = TechnicalDrawing(
|
||||
source_kind="component", source_id=comp.id,
|
||||
views=[DrawingView(kind=k) for k in kinds],
|
||||
auto_dimensions=True, title=name,
|
||||
)
|
||||
result = generate_drawing(drawing, project, kernel)
|
||||
p = QPainter(pm)
|
||||
render_drawing(p, result, QRectF(0, 0, W, H))
|
||||
p.end()
|
||||
out = f"/tmp/drawing_{name}.png"
|
||||
pm.save(out)
|
||||
print(name, "saved", out, "prims", len(result.primitives), "scale",
|
||||
round(result.view_transforms.get("front", (None,))[0] or 0, 3))
|
||||
Reference in New Issue
Block a user