Description

Déplace un objet sur un point central :

  1. Sélectionner l’objet à déplacer ;
  2. Sélectionner le point de base sur l’objet à déplacer ;
  3. Sélectionner le point A ;
  4. Sélectionner le point B ;
  5. L’objet est déplacé au milieu de la ligne AB.

Voir aussi le script CopyHalf.

Le script suivant fonctionne sur :

  • Rhino pour Windows ;
  • Rhino pour macOS.

Script par MLAV.LAND, sous licence GNU GPL 3.

Code

import rhinoscriptsyntax as rs
 
def move_object_to_midpoint():
    # Step 1: Select the object to move
    obj = rs.GetObject("Select an object to move", preselect=True)
    if not obj:
        return
    
    # Step 2: Select a base (reference) point on the object
    base_point = rs.GetPoint("Select a base point on the object")
    if not base_point:
        return
    
    # Step 3: Select the start point
    start_point = rs.GetPoint("Pick the start point")
    if not start_point:
        return
    
    # Step 4: Select the end point
    end_point = rs.GetPoint("Pick the end point", start_point)
    if not end_point:
        return
    
    # Step 5: Compute the middle point between start and end points
    midpoint = rs.PointAdd(start_point, rs.VectorScale(rs.VectorCreate(end_point, start_point), 0.5))
    
    # Step 6: Move the object so the base point aligns with the midpoint
    move_vector = rs.VectorCreate(midpoint, base_point)
    rs.MoveObject(obj, move_vector)
    
    print("Object moved to the midpoint.")
 
# Run the command
move_object_to_midpoint()