Failing to scale BREPs using Rhino Inside

I am trying to load a 3dm file, scale all BREPs and save it again.
But the resulting object seems unchanged even though I get “scale succeeded”.

Any ideas what I’m doing wrong?

import os
import rhinoinside
try:
rhinoinside.load()
except:
pass
import System
import Rhino

doc = Rhino.RhinoDoc.OpenHeadless(“…\3dm_files\cutout_3dm\cutout_h5021_ct1000.3dm”)

for o in doc.Objects:
if o.Geometry.ObjectType == Rhino.DocObjects.ObjectType.Brep:
if not o.Geometry.Scale(0.5):
print(“ALARM: scale failed”)
else:
print(“scale succeeded”)

fwo = Rhino.FileIO.FileWriteOptions()
fwo.FileVersion = 7
doc.Write3dmFile(“…\DEMO_TEST.3dm”, fwo)

doc.Dispose()

The issue was likely due to me not updating the document after scaling the geometries. Scaling a Brep doesn’t automatically update the RhinoObject in the document. I needed to explicitly update the object in the document after modifying its geometry using

doc.Objects.Replace(o.Id, o.Geometry)

Now it works

1 Like