Hi-
I’m relatively new to using python in Rhino and am trying to understand the use of Overloads with Transform.DecomposeAffine. When enter the following:
block = rs.GetObject("",4096)
XForm = rs.BlockInstanceXform(block)
decompAff = Rhino.Geometry.Transform.DecomposeAffine.Overloads[Transform, Vector3d](XForm)
print decompAff
I get “Message: ‘method_descriptor’ object has no attribute ‘Overloads’” error. Is this the correct syntax? Or is there a step I’m missing?
Thanks,
David
Hi @David_Moreau,
some methods support Overloads
and some do not. If you cannot get the Overloads
in the python script editor after typing the method ending with a dot like this:
Rhino.Geometry.Transform.Decompose.
you can setup the variables the method is supposed to return as “out” before calling the method. Once the method is called it returns a single boolean value, if it is True
, the out values have been changed.
And example with your code might look like this:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import clr
def DoSomething():
block = rs.GetObject("Select block", rs.filter.instance, True, False)
if not block: return
block_xform = rs.BlockInstanceXform(block)
outXform = clr.StrongBox[Rhino.Geometry.Transform]()
outVector = clr.StrongBox[Rhino.Geometry.Vector3d]()
rc = block_xform.DecomposeAffine(outXform, outVector)
if not rc: return
print outXform.Value
print outVector.Value
DoSomething()
You might also take a look here for further info about python and Overloads
:
_
c.
Thanks so much. This really helps. Points me in the right direction.