solid.hole: position takes length expressions and follows them (#1678) (#1683)

Thanks @DuBearte.
This commit is contained in:
DuBearte authored and GitHub committed 2026-10-16 08:26:23 -04:00
1 parent 838d0e86f2
commit dd5278a402
8 files changed
+128 -17

No files matched your search

+22
View File
@@ -662,6 +662,12 @@ pub enum FeatureKind {
Hole {
#[walk(pick_if = points.is_none())]
position: FacePick,
/// The position as length expressions, when it was given that way (#1678): the hole is
/// drilled where they evaluate, and follows the parameters. `position` keeps the point
/// they gave when the hole was made.
#[serde(default, skip_serializing_if = "Option::is_none", with = "opt_point_expr")]
#[walk(placement)]
at: Option<PointExpr>,
/// Drilling direction (into the material).
direction: Dir,
#[walk(length = "Diameter")]
@@ -1935,6 +1941,22 @@ mod point_expr {
}
}
/// [`point_expr`] for an optional point.
mod opt_point_expr {
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Serialize, Deserialize)]
struct Wrap(#[serde(with = "super::point_expr")] super::PointExpr);
pub fn serialize<S: Serializer>(p: &Option<super::PointExpr>, s: S) -> Result<S::Ok, S::Error> {
p.as_ref().map(|p| Wrap(p.clone())).serialize(s)
}
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Option<super::PointExpr>, D::Error> {
Ok(Option::<Wrap>::deserialize(d)?.map(|w| w.0))
}
}
impl FeatureKind {
/// A sheet metal feature (its result depends on the sheet metal rules).
pub fn is_plastic(&self) -> bool {