Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

[python] Can't scale breps non-uniformly?

$
0
0

I was unable to scale a brep. And I can’t tell if it is a bug or by design. It was very unexpected, though. The code below did NOT work.

#! python 2
import Rhino.Geometry as rg
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

pln = rg.Plane.WorldXY
ob = rg.Sphere(pln, 10).ToBrep()

xform = rg.Transform.Scale(pln, 1, 2, 1)
ob.Transform(xform)

sc.doc.Objects.AddBrep(ob)

I was pulling my hair out. But fortunately I somehow found the answer here.

So based on that, I was able to scale the sphere by converting it to a NurbsSurface and then converting it to a brep after the scaling operation. But, like I said, it was very unexpected that I couldn’t do a NU scale on a brep directly. And no errors thrown, either…it just refused to scale. In fact, iirc, at some point in time, I recorded the result of ob.Transform(xform) and got True back!

(working code below)

#! python 2
import Rhino.Geometry as rg
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

pln = rg.Plane.WorldXY
ob = rg.Sphere(pln, 10).ToNurbsSurface()

xform = rg.Transform.Scale(pln, 1, 2, 1)
ob.Transform(xform)

ob = ob.ToBrep()

sc.doc.Objects.AddBrep(ob)

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles