Orient and Rotate3D


#1

Hi all
the attached Python Script orients and rotate3d objects : it’s more intuitive of Orient3pt

#-*- encoding: UTF-8 -*-
#********* Copia e orienta oggetti e gruppi********
#****** Write by Ing. Vittorio Carlotto ***********
#****** carlottovittorio@gmail.com  20-12-2013 ****
import rhinoscriptsyntax as rs
def ImportaOrientaRuota(stroStart):
    arrplane=rs.ViewCPlane      
    rs.EnableRedraw(True)
    if stroStart==None:  return
    p1,p2=rs.GetPoints(True,False,"1° reference point","2° reference point",2)
    if p1==None: return  # se non prendo punti
    if p2==None:return      
    p1ob=rs.AddPoint(p1)# 1° punto che oriento e mi serve per ruotare     
    p2ob=rs.AddPoint(p2) # 2° punto che oriento e mi serve per ruotare       
    rs.UnselectAllObjects()    
    stroStart.insert(0,p2ob)
    stroStart.insert(0,p1ob)    
    while True:
        rs.UnselectAllObjects()        
        stro=rs.CopyObjects (stroStart) # copia degli oggetti da rototraslare        
        rs.SelectObjects (stro)      # seleziono oggetti copiati e punti          
        #######      oriento oggetti e punti ##################        
        rs.Command("_Orient _Scale=_No  _Copy=_No  w"+str(p1)+"  W"+str(p2)+"  _pause _pause  _enter",False)
        rs.UnselectAllObjects()
        np1=rs.FirstObject()
        ccnp1=rs.PointCoordinates(np1)
        np2=rs.NextObject(np1)         
        ccnp2=rs.PointCoordinates(np2)
        rs.DeleteObjects((np1,np2)) 
        all_Objects=rs.LastCreatedObjects()
        if all_Objects==None:
            rs.DeleteObjects(stro)
            rs.DeleteObjects((p1ob,p2ob))            
            break
        rs.SelectObjects(all_Objects) 
        rs.EnableRedraw(True)
        rs.Command("_Rotate3d  w"+str(ccnp1)+"  w"+str(ccnp2)+" _Copy=_No",False)          
        print "Enter Enter for End"
stroStart=rs.GetObjects("Select objects ")
ImportaOrientaRuota(stroStart)

Ciao Vittorio