[求助]无法获取scriptcontext.doc.Objects.Attributes

‘’‘attributes = doc_object.Attributes’’’
Runtime error (MissingMemberException): ‘NoneType’ object has no attribute ‘Attributes’

我是在尝试这个示例中的bake代码:

if B:

    print(type(G)) #debug message to Python output

    #we obtain the reference in the Rhino doc
    doc_object = scriptcontext.doc.Objects.Find(G)
    print(type(doc_object))

    attributes = doc_object.Attributes
    print('the type of attributes is: ' + str(type(attributes)))     #debug message to Python output

    geometry = doc_object.Geometry
    print('the type of geometry is: ' + str(type(doc_object)))     #debug message to Python output

    #we change the scriptcontext
    scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc

    #we add both the geometry and the attributes to the Rhino doc
    rhino_brep = scriptcontext.doc.Objects.Add(geometry, attributes)
    print('the Rhino doc ID is: ' + str(rhino_brep))     #debug message to Python output

    #we can for example change the layer in Rhino...
    if not rs.IsLayer(L):
        rs.AddLayer(L)
    rs.ObjectLayer(rhino_brep, L)

    #we put back the original Grasshopper document as default
    scriptcontext.doc = ghdoc
    a = G

你最好传一下你的文件。你这个错误是空值错误。doc_object 应该返回了空。

1 个赞

明白了,现在问题解决了,非常感谢。

我也出现过这样的问题