def SurfaceFitter():
    srf_id = rs.GetObject("Surface to fit", 8, True, True)
    if not srf_id: return

    pts = rs.GetPointCoordinates("Points to fit to", False)
    if not pts: return

    for n in range(100):
        nSrf = FitSurface(srf_id, pts)
        rs.DeleteObject(srf_id)
        srf_id = nSrf
Beispiel #2
0
def DistributedSurfaceFitter():
    srf_id = rs.GetObject("Surface to fit", 8, True, True)
    if not srf_id: return

    pts = rs.GetPointCoordinates("Points to fit to", False)
    if not pts: return

    for n in xrange(10000):
        rs.EnableRedraw(False)
        nSrf, dTrans, dProx = FitSurface(srf_id, pts)
        #Call Rhino.DeleteObject(idSrf)
        rs.EnableRedraw(True)
        rs.Prompt("Translation = %.2f  Deviation = %.2f" % dTrans, dProx)
        if dTrans < 0.1 or dProx < 0.01: break
        srf_id = nSrf
    print "Final deviation = %.4f" % dProx
def dividePointsInX():
    points = rs.GetPoints()
    x = 0
    for point in points:
        arCoord = rs.GetPointCoordinates();
Beispiel #4
0
#Some information about the author
#When it was written

#import statements
import rhinoscriptsyntax as rs
import math

print("hello")
print("my message")

print(rs.GetPointCoordinates("Select a Point: "))
Beispiel #5
0
    def create_spatial_domain_by_sphere(self):
        """自空間の領域を構成する球体の母点を生成、周辺に外部空間(外部とのつながり)の母点を生成"""
        global coordinate

        # 自空間がGLに設置するか否かを判定
        gl_flag = False
        gl_value = rs.GetInteger('Input 1(from GL) or 2(not from GL)')

        if gl_value == 1:
            gl_flag = True
        elif gl_value == 2:
            pass
        else:
            raise Exception('not intended num selected, please retry')

        # 自空間の隣接関係(球体の数)を決定 --> 意味ある?
        neighbor_num = rs.GetInteger(
            'Input the numbers of neighbor sphere')  # 近接数(球体)
        neighbor_ids = []
        for _ in range(neighbor_num):
            neighbor_id = rs.GetInteger(
                'Input the neighbor sphere ID(int)')  # IDを割り当て?
            neighbor_ids.append(neighbor_id)

        # 自空間の大まかな領域を構成する球体の半径を決定
        radius = rs.GetInteger(
            'Enter the radius of sphere to create space')  # sphere of radius

        # ユーザによる空間領域の位置を母点(球体)の取得によって決定 --> 重要
        sphere_center_coordinate = rs.GetPointCoordinates(
        )  # TODO ゆくゆくは自動生成にしたい
        coordinate = sphere_center_coordinate[0]  # [int, int ,int]の値を取得。あとで改善

        # 自身のID番号
        self_id = 111

        # 空間領域を決定するための球体を生成(インスタンス)
        self.spatial_domain_sphere = Sphere.Sphere(self_id, gl_flag,
                                                   sphere_center_coordinate[0],
                                                   radius, neighbor_ids, None)

        # 他の空間領域との相互関係を決定するための外部球体を生成
        temp_coordinate_list = []
        coordinate_1 = Rhino.Geometry.Point3d(coordinate[0] + 90,
                                              coordinate[1] + 20,
                                              coordinate[2])
        coordinate_2 = Rhino.Geometry.Point3d(coordinate[0] - 100,
                                              coordinate[1] - 5, coordinate[2])
        coordinate_3 = Rhino.Geometry.Point3d(coordinate[0] + 1,
                                              coordinate[1] + 90,
                                              coordinate[2])
        coordinate_4 = Rhino.Geometry.Point3d(coordinate[0] - 1,
                                              coordinate[1] - 100,
                                              coordinate[2])
        coordinate_5 = Rhino.Geometry.Point3d(coordinate[0] - 2,
                                              coordinate[1] - 1,
                                              coordinate[2] + 100)
        coordinate_6 = Rhino.Geometry.Point3d(coordinate[0] + 3,
                                              coordinate[1] + 10,
                                              coordinate[2] - 100)
        coordinate_7 = Rhino.Geometry.Point3d(coordinate[0] + 50,
                                              coordinate[1] + 10,
                                              coordinate[2] + 50)
        temp_coordinate_list.append(coordinate_1)
        temp_coordinate_list.append(coordinate_2)
        temp_coordinate_list.append(coordinate_3)
        temp_coordinate_list.append(coordinate_4)
        temp_coordinate_list.append(coordinate_5)
        temp_coordinate_list.append(coordinate_6)
        temp_coordinate_list.append(coordinate_7)

        for i in range(7):
            outer_id = i
            radius = 500
            neighbor_ids = []
            gl_flag = False

            outer_sphere = Sphere.Sphere(self_id, gl_flag,
                                         temp_coordinate_list[i], radius,
                                         neighbor_ids, outer_id)
            self.sphere_outer_lists.append(outer_sphere)

        # 不必要なオブジェクトを削除
        del temp_coordinate_list