GH空间
import Rhino
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc
#设置操作空间为gh
sc.doc = ghdoc
#gh未输出内容不会显示
pt00 = rs.AddPoint(300,1800,0) #返回Guid
line00 = rs.AddLine((0, 1000, 0), (500, 2000, 0)) #返回Guid
#输出内容,Geometriy临时显示,Guid打开开关显示,Geometriy和Guid都可以bake
print('当前空间ghdoc')
pt01 = rs.AddPoint(100,1500,0) #返回Guid
pt02 = rs.coerce3dpoint(pt00) #通过coerce转换,返回Geometriy
pt03 = rs.CurveEndPoint(line00) #获取实例的要素,返回Geometriy
line01 = rs.AddLine((0, 1000, 0), (1000, 2000, 0)) #返回Guid
line02 = rg.Line(rg.Point3d(400,1000,0), rs.CurveEndPoint(line01)) #返回Geometriy
line03 = sc.doc.Objects.AddLine(line02) #通过add实例化,返回Guid
Rhino空间
import Rhino
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc
sc.doc = Rhino.RhinoDoc.ActiveDoc
#gh未输出内容,会在Rhino空间执行,Rhino空间只执行Guid
pt00 = rs.AddPoint(300,800,0) #返回Guid
line00 = rs.AddLine((0, 0, 0), (500, 1000, 0)) #返回Guid
#输出内容,临时显示同gh空间,Rhino空间只执行Guid
print('当前空间Rhino')
if x:
pt01 = rs.AddPoint(100,500,0) #返回Guid
pt02 = rs.coerce3dpoint(pt00) #通过coerce转换,返回Geometriy
pt03 = rs.CurveEndPoint(line00) #获取实例的要素,返回Geometriy
line01 = rs.AddLine((0, 0, 0), (1000, 1000, 0)) #返回Guid
line02 = rg.Line(rg.Point3d(500,0,0), rs.CurveEndPoint(line01)) #返回Geometriy
line03 = sc.doc.Objects.AddLine(line02) #通过add实例化,返回Guid
if not x:
rs.DeleteObjects(rs.AllObjects())
#gh关闭preview,所有内容依然会在Rhino空间执行,只有Guid实例化才显示