RhinoCommon Transofrm.Scale() bug

Hello there,

I found what I think is a bug in the SDK scaling some poly curves, the error happens only scaling using different factors per axis:

Transform.Scale(plane,2,1,1) generate disconnected curves

Scaling by SDK like Transform.Scale(plane,2,2,2) or scaling in design using Gumballs or Scale1D, Scale2D or Scale commands also works fine, although if you scale it using gumball and scale back to the original size, using the SDK Scale() method also works fine

Here a video showing the bug

Here the example project:
ScaleProblemExample.zip (294.0 KB)

Here the 3dm with a lot of curves that fail:
ScaleCurveError.3dm (128.2 KB)

1 Like

Hi @henrydm,

Does this help?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var rc = RhinoGet.GetOneObject("Select curve to scale non-uniformly", 
    false, 
    ObjectType.Curve, 
    out var obj_ref
    );

  if (rc != Result.Success)
    return rc;

  var curve = obj_ref.Curve();
  if (null == curve)
    return Result.Failure;

  var bbox = curve.GetBoundingBox(true);
  var plane = new Plane(bbox.Center, Vector3d.XAxis, Vector3d.YAxis);
  var xform = Transform.Scale(plane, 2, 1, 1);

  var curve_copy = curve.DuplicateCurve();

  // If not a similarity transformation, make sure geometry
  // can be deformed. Generally, this involves converting non-NURBS
  // geometry into NURBS geometry.
  if (xform.SimilarityType == TransformSimilarityType.NotSimilarity)
    curve_copy.MakeDeformable();

  if (curve_copy.Transform(xform) && curve_copy.IsValid)
  {
    doc.Objects.Add(curve_copy);
    doc.Views.Redraw();
  }

  return Result.Success;
}

– Dale

1 Like

Hi @dale

Yes, it helps a lot! thanks for your quick answer it works perfectly.

Regards.