Scale operation returns false

RhinoDoc activedoc = RhinoDoc.ActiveDoc;
IEnumerable B = activedoc.Objects.GetObjectList(ObjectType.Brep);

RhinoObject object1 = B.ElementAt(0);
bool hasBrepform = object1.Geometry.HasBrepForm;
Brep Brep_body = Brep.TryConvertBrep(object1.Geometry);
BrepEdge edge1 = Brep_body.Edges.ElementAt(0);

A = edge1.Scale(2.0);

Here is a code to access a Brep body from Rhino through a script in c#. I have got the brep body->then a certain circular edge->now I wish to scale it and expect the whole object to modify accordingly as it happens when I select an edge and scale in using tools in Rhino. But the edge.scale(2) opeartion return False why. How can I modify objects geometry?

Hi @Rushank,

Try using Brep.TransformComponent.

– Dale

RhinoDoc activedoc = RhinoDoc.ActiveDoc;

IEnumerable<RhinoObject> B = activedoc.Objects.GetObjectList(ObjectType.Brep);
RhinoObject object1 = B.ElementAt(0);

//obejct1dup = object1.DuplicateGeometry();

bool hasBrepform = object1.Geometry.HasBrepForm;
GeometryBase obj_dup = object1.DuplicateGeometry();
Brep Brep_body = Brep.TryConvertBrep(obj_dup);

BrepFace face1 = Brep_body.Faces.ElementAt(0);
ComponentIndex index =  face1.ComponentIndex();
IEnumerable<Rhino.Geometry.ComponentIndex> componentIndices = new List<Rhino.Geometry.ComponentIndex>();
componentIndices.Append(index);

Point3d point = new Point3d(0, 0, 0);

Transform transform = Transform.Scale(point, 3);

double tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;// Use the document's default tolerance
double timeLimit = 10.0; // Set a time limit of 10 seconds
bool useMultipleThreads = true;

Brep_body.TransformComponent(componentIndices, transform, tolerance, timeLimit, useMultipleThreads);

ObjRef objRef = new ObjRef(object1);
A = activedoc.Objects.Replace(objRef,Brep_body);
object1.CommitChanges();

activedoc.Views.Redraw();

Tried this code. It is returning True at A but no changes in object, also it has given IsDocumnentControlled to be True, for which document suggest that it is the object is read only.

But also I am able to scale the whole Brep body but not one face of it.

Hi @Rushank,

Can you post a .3dm file that contains the “before” and “after” Brep. Make sure to indicate which edge you are trying to scale.

Thanks,

– Dale

Hi Dale
before:
model.3dm (59.1 KB)
after:
model.3dm (59.1 KB)

It looks the same
I checked IsDocumentControlled and it is returning true,
for this documentation says file could be just readonly
but I could scale whole Brep object but not a surface of it, the way we can do it by tools.

Also the edge I was scaling was conical surface just beneath the top surface.

Somehow TransformComponent worked when I restarted the session.