2014-09-13 35 views
0

我想實現一個Rhino插件來提取NURB曲線控制點的位置屬性。如果您繪製曲線或像Sphere一樣的實體形狀,則可以使用這種方法。你有一些點畫,你也有一些控制點。如何從犀牛NURB文件中提取曲線控制點

更多地瞭解NURB廣告控制點,你可以閱讀本link

+0

你是什麼意思的「犀牛插件?」你指的是在Java虛擬機上運行的Rhino JavaScript引擎嗎? – 2014-09-14 13:59:57

+0

不,Rhino是3D設計應用程序,如果您檢查鏈接,您會看到 – Mohammad 2014-09-15 04:29:11

+0

確定。我添加了一個編輯來刪除「rhino」標籤,因爲該標籤意味着Stack Overflow中的其他內容。 (我對這個犀牛一無所知,所以我很抱歉地說我不能幫你。)你可能想嘗試找到更具體的標籤; 「插件」將不太可能提供幫助。 – 2014-09-15 11:54:21

回答

0

在VS 2012,您應該安裝新組件犀牛。那麼您可以像這樣檢索NURBS屬性:

Surface sr = obj_ref.Surface(); 
if (null == sr) 
    return Result.Failure; 

NurbsSurface ns = sr.ToNurbsSurface(); 
if (null == ns) 
    return Result.Failure; 


foreach (var point in ns.Points) 
{ 
    doc.Objects.AddPoint(point.Location); 
} 

foreach (var knot in ns.KnotsU) 
{ 
    // do anything by KnotsU 
} 


foreach (var knot in ns.KnotsV) 
{ 
    // do anything by KnotsV 
} 

doc.Views.Redraw(); 
1

此Python代碼提取選定曲線的控制點並將曲線名稱關聯到提取的控制點。

import rhinoscriptsyntax as rs 
from System.Drawing import Color 
import Rhino as Rh 
#Collecting the curves 
obj = rs.GetObjects("Select curves",4) 
#adding a Layer as a parent layer 
rs.AddLayer("Knots") 
for curve in obj: 
    if rs.IsCurve(curve): 
#Creating new layers from objects name 
      LayerName = rs.ObjectName(curve) 
      rs.AddLayer(LayerName,Color.Aqua,True,False,"Knots") 
      points = rs.CurvePoints(curve) 
      if points: 
       for pt in points: 
        CtrlPoint = rs.AddPoint(pt) 
        rs.ObjectLayer(CtrlPoint,LayerName) 
        rs.ObjectName(CtrlPoint,rs.ObjectName(curve))