forked from 1b-agent/opencadstudio-upstream
Complete parametric drawing interoperability
This commit is contained in:
1 parent
7aff9fa046
commit
753df67ee4
13 files changed
+1602
-138
No files matched your search
@@ -27,6 +27,8 @@ pub struct SketchRef {
|
||||
pub marker: Option<i32>,
|
||||
}
|
||||
|
||||
const POLYLINE_SEGMENT_MARKER_BASE: i32 = -1_000_000;
|
||||
|
||||
impl SketchRef {
|
||||
pub fn whole(entity: Handle) -> Self {
|
||||
Self {
|
||||
@@ -51,6 +53,20 @@ impl SketchRef {
|
||||
marker: Some(-3),
|
||||
}
|
||||
}
|
||||
|
||||
/// Select one straight segment of a polyline.
|
||||
pub fn segment(entity: Handle, index: usize) -> Self {
|
||||
Self {
|
||||
entity,
|
||||
marker: Some(POLYLINE_SEGMENT_MARKER_BASE - index as i32),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn segment_index(self) -> Option<usize> {
|
||||
let marker = self.marker?;
|
||||
(marker <= POLYLINE_SEGMENT_MARKER_BASE)
|
||||
.then(|| (POLYLINE_SEGMENT_MARKER_BASE - marker) as usize)
|
||||
}
|
||||
}
|
||||
|
||||
/// The friendly, user-facing constraint types — the "what button did they
|
||||
|
||||
Reference in new issue
Block a user