通过GH_BakeUtility.BakeObject自动bake物件

需要bake一些无效的网格,看到这类的描述是可以作用于无效物件。
image
按照要求完成输入项,没有办法bake出来,输出False,不知道哪里出问题了 :smiling_face_with_tear:


如图所示
下为写的代码:
import rhinoscriptsyntax as rs
import Grasshopper.Kernel as gk
import scriptcontext as sc
import Rhino
sc.doc=Rhino.RhinoDoc.ActiveDoc
attr=Rhino.DocObjects.ObjectAttributes()
te0=gk.GH_Document()
te1=gk.GH_BakeUtility(te0)
a=gk.GH_BakeUtility.BakeObject(te1,x,attr,sc.doc)

参考的官网的这个:https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_Kernel_GH_BakeUtility.htm


:smiling_face_with_tear: :smiling_face_with_tear: :smiling_face_with_tear:

import Grasshopper.Kernel as gk
import Grasshopper
import scriptcontext as sc
import Rhino


attr=Rhino.DocObjects.ObjectAttributes()
backer = gk.GH_BakeUtility(Grasshopper.Instances.ActiveCanvas.Document)
goo = gk.GH_Convert.ToGeometricGoo(x)
a = backer.BakeObject(goo ,attr ,Rhino.RhinoDoc.ActiveDoc)

另外,麻烦下次贴代码的时候,依照下面帖子的介绍格式化一下代码:

1 个赞

非常感谢您的回复,为格式不正确给您添麻烦感到万分抱歉
但是直接复制过去运行代码依然不可以bake
我在照抄编写至backer=gk.GH_BakeUtility(Grasshopper.Instances.ActiveCanvas时提示错误如图:

x 端口这里的输入要改一下