From 7a2c0026725657248303186f3d21892050dec348 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 16 Feb 2026 18:57:31 +0000 Subject: [PATCH] fix: use Matrix3x3 for datum plane, property assignment for SketchInPlaceBuilder2 --- .../adaptive-isogrid/src/nx/import_profile.py | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/adaptive-isogrid/src/nx/import_profile.py b/tools/adaptive-isogrid/src/nx/import_profile.py index 4a32eb45..1b5bd7b0 100644 --- a/tools/adaptive-isogrid/src/nx/import_profile.py +++ b/tools/adaptive-isogrid/src/nx/import_profile.py @@ -118,30 +118,32 @@ def _find_or_create_sketch( origin_pt = NXOpen.Point3d(origin[0], origin[1], origin[2]) normal_vec = NXOpen.Vector3d(normal[0], normal[1], normal[2]) x_vec = NXOpen.Vector3d(x_axis[0], x_axis[1], x_axis[2]) + y_axis = transform["y_axis"] + y_vec = NXOpen.Vector3d(y_axis[0], y_axis[1], y_axis[2]) - # Create a Plane object using the normal vector - plane = part.Planes.CreatePlane( - NXOpen.PlaneTypes.MethodType.Distance, # method - NXOpen.PlaneTypes.AlternateType.One, # alternate - origin_pt, # origin - normal_vec, # normal - "", # expression - False, # flip - False, # percent - [], # geometry refs - ) + # Build Matrix3x3 from x_axis, y_axis, normal (row-major: Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz) + mtx = NXOpen.Matrix3x3() + mtx.Xx = x_axis[0]; mtx.Xy = x_axis[1]; mtx.Xz = x_axis[2] + mtx.Yx = y_axis[0]; mtx.Yy = y_axis[1]; mtx.Yz = y_axis[2] + mtx.Zx = normal[0]; mtx.Zy = normal[1]; mtx.Zz = normal[2] + + # Create fixed datum plane + datum_plane = part.Datums.CreateFixedDatumPlane(origin_pt, mtx) + lister.WriteLine(f"[import] Created datum plane: {datum_plane}") # Create sketch-in-place builder - sketch_builder = part.Sketches.CreateNewSketchInPlaceBuilder(NXOpen.Sketch.Null) - sketch_builder.PlaneReference(plane) + sketch_builder = part.Sketches.CreateSketchInPlaceBuilder2(NXOpen.Sketch.Null) - # Set sketch origin as a Point object + # Set plane — PlaneReference is a property setter + sketch_builder.PlaneReference = datum_plane + + # Set sketch origin origin_point = part.Points.CreatePoint(origin_pt) - sketch_builder.SketchOrigin(origin_point) + sketch_builder.SketchOrigin = origin_point - # Set axis reference as Direction + # Set axis reference axis_dir = part.Directions.CreateDirection(origin_pt, x_vec, NXOpen.SmartObject.UpdateOption.WithinModeling) - sketch_builder.AxisReference(axis_dir) + sketch_builder.AxisReference = axis_dir # Commit to create the sketch sketch_feature = sketch_builder.CommitFeature()