- Tons of addtions
This commit is contained in:
@@ -6,7 +6,7 @@ including projects, components, sketches, and bodies.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Any
|
||||
from typing import Dict, List, Optional, Any, Tuple
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
import numpy as np
|
||||
@@ -46,6 +46,32 @@ class Sketch:
|
||||
created_at: datetime = field(default_factory=datetime.now)
|
||||
modified_at: datetime = field(default_factory=datetime.now)
|
||||
|
||||
def set_workplane(
|
||||
self,
|
||||
origin: Tuple[float, float, float],
|
||||
normal: Tuple[float, float, float],
|
||||
x_dir: Tuple[float, float, float],
|
||||
) -> None:
|
||||
"""Set this sketch's 3D workplane and sync it to the OCC sketch.
|
||||
|
||||
Call this when the sketch is placed on a face/datum plane. UV
|
||||
coordinates are unchanged; only their world mapping moves.
|
||||
"""
|
||||
self.workplane_origin = np.asarray(origin, dtype=float)
|
||||
self.workplane_normal = np.asarray(normal, dtype=float)
|
||||
self.workplane_x_dir = np.asarray(x_dir, dtype=float)
|
||||
self.apply_workplane()
|
||||
self.modified_at = datetime.now()
|
||||
|
||||
def apply_workplane(self) -> None:
|
||||
"""Push the stored workplane fields into the underlying OCCSketch."""
|
||||
if self.occ_sketch is not None:
|
||||
self.occ_sketch.set_workplane(
|
||||
tuple(self.workplane_origin.tolist()),
|
||||
tuple(self.workplane_normal.tolist()),
|
||||
tuple(self.workplane_x_dir.tolist()),
|
||||
)
|
||||
|
||||
def add_point(self, x: float, y: float) -> Any:
|
||||
"""Add a point to the sketch."""
|
||||
self.modified_at = datetime.now()
|
||||
|
||||
Reference in New Issue
Block a user