Hi,
I want to replicate the old RVB function “RemapObjects” in python.
Essentially I have a planar object that I want to align to the “Top” Cplane.
I saw a suggestion to use XformChangeBasis followed by TransformObjects which seems to work when the object is perpendicular to a cplane, but it doesn’t work when the object is at another angle to a cplane.
Any suggestions on what I should be doing to map a planar object from it’s own plane, to the “Top” CPlane.
Many Thanks,
Regards,
Shane.
Hi @shanew06, XFormChangeBasis
requires two planes, in your case the WorldXY plane and the plane of the planar object. Try below eg. with a freely rotated circle:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
def my_filter(rhino_object, geometry, component_index):
if geometry.IsPlanar(scriptcontext.doc.ModelAbsoluteTolerance):
return True
return False
def DoSomething():
crv_id = rs.GetObject("planar curve", 4, False, False, my_filter)
if not crv_id: return
curve_plane = rs.CurvePlane(crv_id, -1)
world_plane = rs.WorldXYPlane()
xform = Rhino.Geometry.Transform.ChangeBasis(world_plane, curve_plane)
newid = rs.TransformObject(crv_id, xform, copy=False)
DoSomething()
_
c.
@clement
Thank you, I now see what my issue was. The documentation for ChangeBasis has the parameter order the wrong way around -
rhinoscriptsyntax.XformChangeBasis (initial_plane, final_plane)
but I saw in your example you had them in the opposite order which also works for me.
Many Thanks!
Shane.