+ Reply to Thread
Results 1 to 2 of 2

Thread: rs.MoveObject/MoveObjects - two point option

  1. #1
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    285

    rs.MoveObject/MoveObjects - two point option

    Hi Steve,

    Wonder if these two methods could have the option to pass two 3D points instead of a vector for the translation - as in the current vbRhinoscript counterpart...

    Thanks, --Mitch

  2. #2
    This modification to the object.py module will accomplish what you are asking for. This modification only needs to be made for rs.MoveObjects and then both methods will allow you to pass in a tuple of two points, like this: rs.MoveObject(objectToMove, (point1, point2)). This may not be Steve approved, but it will work.

    Code:
    def MoveObjects(object_ids, translation):
        """Moves one or more objects
        Parameters:
          object_ids: The identifiers objects to move
          translation: list of 3 numbers or Vector3d or    
          tuple of a start point and an end point.
        Returns:
          List of identifiers of the moved objects if successful
        """
        if type(translation) == tuple:
            if len(translation) != 2:
                return None
            else:
                to_point = rhutil.coerce3dpoint(translation[0], True)
                from_point = rhutil.coerce3dpoint(translation[1], True)
                translation = to_point-from_point
        else:
            translation = rhutil.coerce3dvector(translation, True)
        xf = Rhino.Geometry.Transform.Translation(translation)
        rc = TransformObjects(object_ids, xf)
        return rc

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts