Grasshopper

algorithmic modeling for Rhino

The following code is from the RhinoPythonPremerRev3.pdf page 47.

It can be executed via the Python editor in Rhino. However, it doesn't work in the GhPython component in Grasshopper with the following error message:

Runtime error (NotImplementedException): The method or operation is not implemented.
Traceback:
  line 180, in GetObject, "C:\Users\oat\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\selection.py"
  line 32, in script

Appreciate if you can kindly advise why the rhinoscriptsyntax module functions differently in the Python Editor and GhPython component.

Source Script:

import rhinoscriptsyntax as rs

def displayobjectattributes(object_id):
    source = "By Layer", "By Object", "By Parent"
    
    data = []
    data.append( "Object attributes for :"+str(object_id) )
    data.append( "Description: " + rs.ObjectDescription(object_id))
    data.append( "Layer: " + rs.ObjectLayer(object_id))
    #data.append( "LineType: " + rs.ObjectLineType(object_id))
    #data.append( "LineTypeSource: " + rs.ObjectLineTypeSource(object_id))
    data.append( "MaterialSource: " + str(rs.ObjectMaterialSource(object_id)))
    
    name = rs.ObjectName(object_id)
    if not name: data.append("<Unnamed object>")
    else: data.append("Name: " + name)

    groups = rs.ObjectGroups(object_id)
    if groups:
        for i,group in enumerate(groups):
            data.append( "Group(%d): %s" % i+1, group )
    else:
        data.append("<Ungrouped object>")

    s = ""

    for line in data: s += line + "\n"
    
    rs.EditBox(s, "Object attributes", "RhinoPython")

if __name__=="__main__":
    id = rs.GetObject()
    displayobjectattributes(id)

Views: 987

Replies to This Discussion

Hi Grasshoppe

Ghpython does not support rs. ObjectDescription () function,You can call the rhinocommon finish the same work,Check the attached file. I hope this helps。

Attachments:

Thanks, Naruto!

However, I can find ObjectDescription function within rhinoscriptsyntax help file in GhPython (see image below). Then how do I know if a certain rhinoscriptsyntax function is not supported by GhPython? and when is the situation that we should consider calling RhinoCommon?

I'm quite confused ...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service