grasshopper | 通過圖層引用線條 報錯:“ Data conversion failed from Guid to Curve ”的避免方法


需求:通過 LunchBox - > layer reference 電池 可以快速選中圖層所在的線條,但是選擇的數據流錯誤 

直接選擇會報錯——“Data conversion failed from Guid to Curve”:

因為是通過圖層電池會選擇 instance 實例化的物體,物體的類型是多種的 ,所以需要剔除不符合所要的數據類型:

import rhinoscriptsyntax as rs
import Rhino.Geometry.InstanceReferenceGeometry 

# 遍歷版本
curveLst = []
def judgeCurve():
    
    for i, item in enumerate(x):
#        print(item.GetType())
        
        if item.GetType() == Rhino.Geometry.Curve or item.GetType() == Rhino.Geometry.ArcCurve \
        or item.GetType() == Rhino.Geometry.Arc \
        or item.GetType() == Rhino.Geometry.PolyCurve \
        or item.GetType() == Rhino.Geometry.Polyline \
        or item.GetType() == Rhino.Geometry.PolylineCurve \
        or item.GetType() == Rhino.Geometry.Line \
        or item.GetType() == Rhino.Geometry.Circle \
        or item.GetType() == Rhino.Geometry.Ellipse \
        or item.GetType() == Rhino.Geometry.NurbsCurve \
        or item.GetType() == Rhino.Geometry.BezierCurve \
        or item.GetType() == Rhino.Geometry.LineCurve:
            curveLst.append(item)
        
    
judgeCurve()
a = curveLst

篩選出數據即可正常運行:

 

IGH_Goo 數據類型定義 

https://developer.rhino3d.com/guides/grasshopper/grasshopper-data-types/

在 C# 中的用法:

GH_Structure<IGH_Goo> tree11 = new GH_Structure<IGH_Goo>();

對數據層級進行操作 

Layer and Sublayer creation in C#

左側有個推薦,有用就推薦下吧?☺

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM