@@ -771,19 +771,34 @@ pub(crate) async fn do_post_extrude<'a>(
771771 } ;
772772
773773 // If the sketch is a clone, we will use the original info to get the extrusion face info.
774- let mut extrusion_info_edge_id = any_edge_id;
775- if sketch. clone . is_some ( ) && clone_id_map. is_some ( ) {
776- extrusion_info_edge_id = if let Some ( clone_map) = clone_id_map {
777- if let Some ( new_edge_id) = clone_map. get ( & extrusion_info_edge_id) {
778- * new_edge_id
774+ // So let's find an edge of the old body.
775+ let extrusion_info_edge_id = if sketch. clone . is_some ( ) && clone_id_map. is_some ( ) {
776+ if let Some ( clone_map) = clone_id_map {
777+ // clone_map maps old IDs -> new IDs.
778+ // If the `any_edge_id` is an ID of the OLD body
779+ // (we know this if it's a _key_ of the map)
780+ // we should use it (because that's the old body we're querying).
781+ if clone_map. contains_key ( & any_edge_id) {
782+ any_edge_id
783+ // Otherwise, if the `any_edge_id` is an ID of the NEW body
784+ // (we know this if it's a _value_ of the map),
785+ // we should query the corresponding ID in the OLD body.
786+ // i.e. if it's a hashmap value, find the corresponding key.
787+ } else if let Some ( ( old_edge_id, _) ) =
788+ clone_map. iter ( ) . find ( |( _, new_edge_id) | * * new_edge_id == any_edge_id)
789+ {
790+ * old_edge_id
779791 } else {
780- extrusion_info_edge_id
792+ any_edge_id
781793 }
782794 } else {
783795 any_edge_id
784- } ;
785- }
786-
796+ }
797+ // If this isn't a clone, there's no old/new body distinction.
798+ // So just use the edge.
799+ } else {
800+ any_edge_id
801+ } ;
787802 let mut sketch = sketch. clone ( ) ;
788803 match body_type {
789804 BodyType :: Solid => {
@@ -871,8 +886,8 @@ pub(crate) async fn do_post_extrude<'a>(
871886 ModelingCmdMeta :: from_args ( exec_state, args) ,
872887 ModelingCmd :: from (
873888 mcmd:: Solid3dGetAdjacencyInfo :: builder ( )
874- . object_id ( sketch . id )
875- . edge_id ( any_edge_id )
889+ . object_id ( sketch_id )
890+ . edge_id ( extrusion_info_edge_id )
876891 . build ( ) ,
877892 ) ,
878893 )
@@ -1033,7 +1048,7 @@ pub(crate) async fn do_post_extrude<'a>(
10331048 } )
10341049}
10351050
1036- #[ derive( Default ) ]
1051+ #[ derive( Debug , Default ) ]
10371052struct Faces {
10381053 /// Maps curve ID to face ID for each side.
10391054 sides : HashMap < Uuid , Option < Uuid > > ,
0 commit comments