Grasshopper

algorithmic modeling for Rhino

Selecting Geometry Problems with the latest Python component

Hi,

I just updated to the newest 0.5 version of the Python scripting component. The attached script  worked in the older Python component, but no longer does. I am trying to get a geometry from Rhino and keep it 'selected'. My code is as follows:

import scriptcontext as sc

if bool_select:
    sc.doc.Objects.Select(x,True,True)                #x is the input geometry

this results in the runtime error:

1. Solution exception:'CustomTable' object has no attribute 'Select'

I have set type of x to Dynamic (rhinoscript guid)

Thanks!

Views: 1717

Attachments:

Replies to This Discussion

Hi Jason

you are right: this does not work in the new component because we simplified the way RhinoScript works and made it fully controllable with Python.

This is what happened before:

  • you could select the target document with a right-click menu: either the Rhino document or the Grasshopper replacement document

This, on the other hand, is what is happening now:

  • by default you always reference the Grasshopper document. If you want to select, turn grips on, and do other User Interface modifications in Rhino, you can switch the current scriptcontext doc like this, and all the calls will be directed to that new document.

    import rhinoscriptsyntax as rs
    import scriptcontext as sc
    import Rhino
    sc.doc = Rhino.RhinoDoc.ActiveDoc
    rs.SelectObject("1d2d1b52-d3db-45c9-8a1c-ddb1303bb8ae")
    #do all RhinoDoc modifications here

    #and then to go back do the Grasshopper document
    #you can do the following:
    sc.doc = ghdoc

 

I hope this is helpful,

- Giulio
________________
giulio@mcneel.com

Hi Giulio,

Thanks for clearing this up. This makes sense now.

About changing the doc's target between rhinoDoc and GHdoc, what about Steve Baer says in this post

oh and yes scriptcontext.doc is better to use than Rhino.RhinoDoc.ActiveDoc. The reason is that multiple docs may exist on the Mac and the ActiveDoc may be switched in the middle of an executing script, whereas scriptcontext.doc is always the RhinoDoc that was active when the script started.

 

is there any way to get sure that the reference of doc is always a concrete document. I mean, how to avoid the possible confusion between two open documents? 

or is just an issue that occurs in Mac? Rhino-Win only accepts one document opened each time, but i can have opened varios rhino apps...

hope my cuestion makes sense..

aitor

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service