review(#1653): upstream pins, registered expression xdata, table apply refreshes sweeps

- Cargo: drop the fork patches; codec 8e93175, kernel 0665fc9, graph
  3b91e67 in every manifest and lock.
- A swept surface's expression link is written through set_entity_xdata,
  so OCS_SWEEP_EXPRESSION has its APPID record and the record its handle.
- Applying the whole named-parameter table also rebuilds the swept
  surfaces linked to expressions, not only a single-row edit.
- swept_surface_entity keeps its doc comment.
- The native-constraint tests find a scope's network through its own
  dictionary, where it is now stored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-07 21:38:17 +03:00
1 parent 2d1f45eeb3
commit ac086def56
10 files changed
+38 -40

No files matched your search

+1
View File
@@ -417,6 +417,7 @@ impl OpenCADStudio {
let pending = self.begin_undo(i, "Apply named parameters", touched.len(), true);
self.tabs[i].scene.record_undo_named_parameters_before();
self.tabs[i].scene.named_parameters = table;
self.tabs[i].scene.refresh_expression_sweeps();
self.tabs[i].dirty = true;
if !touched.is_empty() {
let changes: Vec<(Handle, crate::scene::ChangeKind)> = touched
+8 -3
View File
@@ -539,9 +539,14 @@ impl OpenCADStudio {
continue;
}
let created = if surface {
let mut entity = sweep_model::swept_surface_entity(&record);
sweep_model::link_sweep_expressions(&mut entity, &expressions);
self.add_surface_model(entity, body)
let created =
self.add_surface_model(sweep_model::swept_surface_entity(&record), body);
sweep_model::link_sweep_expressions(
&mut self.tabs[i].scene.document,
created,
&expressions,
);
created
} else {
self.add_solid_model(
empty_solid3d(),
+2 -8
View File
@@ -3189,14 +3189,8 @@ mod tests {
}
fn native_group_handle(document: &CadDocument, owner: Handle) -> Handle {
let dict = document
.extension_dictionary_handle(owner)
.expect("extension dictionary should exist");
let Some(ObjectType::Dictionary(dictionary)) = document.objects.get(&dict) else {
panic!("expected owner's extension dictionary object to exist");
};
let network_handle = dictionary
.get(NETWORK_DICTIONARY_KEY)
// The scope's network sits under a dictionary of its own.
let network_handle = native_scope_network_handle(document, owner)
.expect("ACAD_ASSOCNETWORK entry should exist");
let Some(ObjectType::Associative(AssociativeObject {
data: AssociativeData::Network(network),
+13 -8
View File
@@ -315,22 +315,26 @@ pub fn swept_with_options(profile: &EntityType, path: &EntityType, mode: Extrude
kernel::acis::rebuild_sweep_with_mode(&record, mode == ExtrudeMode::Surface).ok()
}
/// Preserve native construction parameters alongside the sheet's saved B-rep.
/// The application name of the expressions a swept surface stays linked to.
pub const SWEEP_EXPRESSION_APP: &str = "OCS_SWEEP_EXPRESSION";
/// Links a swept surface to its scale and twist expressions (kept as the
/// surface's own data, so they are saved with the drawing).
pub fn link_sweep_expressions(entity: &mut EntityType, expressions: &[Option<String>; 2]) {
if expressions.iter().all(Option::is_none) { return; }
let mut record = codec::xdata::ExtendedDataRecord::new(SWEEP_EXPRESSION_APP);
/// surface's own data, under a registered application, so they are saved
/// with the drawing).
pub fn link_sweep_expressions(
document: &mut codec::CadDocument,
handle: codec::Handle,
expressions: &[Option<String>; 2],
) {
if handle.is_null() || expressions.iter().all(Option::is_none) { return; }
let mut values = Vec::new();
for (name, expression) in ["ScaleFactor", "TwistAngle"].iter().zip(expressions) {
if let Some(expression) = expression {
record.add_value(codec::xdata::XDataValue::String(name.to_string()));
record.add_value(codec::xdata::XDataValue::String(expression.clone()));
values.push(codec::xdata::XDataValue::String(name.to_string()));
values.push(codec::xdata::XDataValue::String(expression.clone()));
}
}
entity.common_mut().extended_data.add_record(record);
crate::scene::view::dispatch::set_entity_xdata(document, handle, SWEEP_EXPRESSION_APP, Some(values));
}
/// The scale and twist expressions a swept surface is linked to.
@@ -382,6 +386,7 @@ pub fn surface_sweep_record(entity: &EntityType) -> Option<SolidHistorySweep> {
})
}
/// Preserve native construction parameters alongside the sheet's saved B-rep.
pub fn swept_surface_entity(record: &SolidHistorySweep) -> EntityType {
let mut surface = Surface::new(SurfaceKind::Swept);
if let Ok(point) = kernel::acis::sweep_history_reference_point(record) {
+2 -2
View File
@@ -1161,9 +1161,9 @@ impl Scene {
}
}
for (handle, expressions) in links {
let Some(entity) = self.document.get_entity_mut(handle) else { continue };
let Some(entity) = self.document.get_entity(handle) else { continue };
if crate::scene::model::sweep_model::sweep_expressions(entity).is_some() { continue; }
crate::scene::model::sweep_model::link_sweep_expressions(entity, &expressions);
crate::scene::model::sweep_model::link_sweep_expressions(&mut self.document, handle, &expressions);
}
}