Description

Copie un objet sur un point central :

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

Voir aussi le script MoveHalf.

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 copy_object_to_midpoint():
    # Step 1: Select the object to copy
    obj = rs.GetObject("Select an object to copy", 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
 
    while True:
        # Step 3: Select the start point
        start_point = rs.GetPoint("Pick the start point (or press Enter to finish)")
        if not start_point:
            break
        
        # Step 4: Select the end point
        end_point = rs.GetPoint("Pick the end point", start_point)
        if not end_point:
            break
        
        # 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: Copy the object so the base point aligns with the midpoint
        move_vector = rs.VectorCreate(midpoint, base_point)
        rs.CopyObject(obj, move_vector)
        
        print("Object copied to the midpoint.")
    
    print("Copying process finished.")
 
# Run the command
copy_object_to_midpoint()