سلام.
در راینو، چطور می توان مختصات نقاط کنترلی شکل مورد نظر را به صورت لیستی از اعداد، خروجی گرفت؟
1 پاسخ
سلام.
راینو دستوری نداره که مستقیما این کار رو انجام بده. ولی میتونید با اسکریپتهای زیر این کار رو انجام بدید. اسکریپت اول برای کروها و دومی برای سرفیسها قابل استفادهست. این اسکریپت کنترل پوینتهای کرو یا سرفیس انتخاب شده رو استخراج میکنه و مختصات نقاط رو در یک فایل متنی با فرمت txt ذخیره میکنه. مختصات هر نقطه در یک سطر ثبت میشه و x و y و z هر نقطه با کاما (,) جدا میشن.
برای اجرا اسکریپت دستور EditPythonScript رو در خط فرمان راینو وارد کنید. در پنجرهای که باز میشه اسکریپت رو وارد کنید و روی فلش سبزرنگ کلیک کنید تا اسکریپت اجرا بشه.
اسکریپت پایتون برای استخراج و ذخیره مختصات کنترل پوینتهای کرو در راینو:
# -*- coding: utf-8 -*- import rhinoscriptsyntax as rs
def ExportCurveControlPoints(): # Select a curve object_id = rs.GetObject(“Select a curve”, rs.filter.curve) if not object_id: return
# Get control points points = rs.CurvePoints(object_id) if not points: return
# Choose file save location filename = rs.SaveFileName(“Save control points”, “Text File (*.txt)|*.txt||”) if not filename: return
# Write points to file (one point per line: x, y, z) with open(filename, “w”) as file: for pt in points: file.write(“{}, {}, {}\n”.format(pt.X, pt.Y, pt.Z))
print(“Control points successfully saved to: ” + filename)
ExportCurveControlPoints()
اسکریپت پایتون برای استخراج و ذخیره مختصات کنترل پوینتهای سرفیس در راینو:
# -*- coding: utf-8 -*- import rhinoscriptsyntax as rs import scriptcontext as sc import Rhino
def ExportSurfaceControlPoints(): # Select a surface obj_id = rs.GetObject(“Select a surface”, rs.filter.surface) if not obj_id: return
# Convert to NURBS surface surf = rs.coercegeometry(obj_id) if not isinstance(surf, Rhino.Geometry.NurbsSurface): surf = surf.ToNurbsSurface()
# Collect control points (row-major order: U then V) points = [] for u in range(surf.Points.CountU): for v in range(surf.Points.CountV): cp = surf.Points.GetControlPoint(u, v) points.append(cp.Location)
# Choose file save location filename = rs.SaveFileName(“Save surface control points”, “Text File (*.txt)|*.txt||”) if not filename: return
# Write points to file with open(filename, “w”) as file: for pt in points: file.write(“{}, {}, {}\n”.format(pt.X, pt.Y, pt.Z))
print(“Surface control points saved successfully.”)
ExportSurfaceControlPoints()