algorithmic modeling for Rhino
This error just keeps popping up whenever I refer to the input object of the Python component in a loop statement.
See the image below.
Can anyone tell me how to solve this? Thank you.
Tags:
If the "x" parameter is to "Item Access" instead of "List Access" this would explain the "Iteration over non-sequence of.." error (i.e. you're trying to iterate over an item and not a list or other iterable). However when using rhinoscriptsyntax functions the solution might be less straight forward than that (we can see by the stack trace that the error occurs inside the rs functions ScaleObjects -> TransformObjects). We discussed this over the Rhino.Python board yesterday actually. Hope that helps..
Hi ANders, I set x to "list access", but still error. Actually I think the error is not due to the access type, cuz in my for loop, I'm not iterating x, but sf or factor, which is 1, 0.9, 0.8......0.1.
As you can see by the screenshot above it is likely a bug in the rhinoscriptcontext object library. rs.ScaleObject() is expecting a list and not a single item for the first input, as one would expect. You can try uploading an example file and we'll see if we can come up with a solution.
The exact same code runs perfectly in the editor though
import rhinoscriptsyntax as rs
x = rs.GetObject("get curve")
cog = rs.CurveAreaCentroid(x)[0]
list = []for i in range(1,10,1):
factor = [i/10,i/10,i/10]
list.append(rs.ScaleObject(x,cog,factor,True))
My suggestion is always to switch to Rhinocommon inside GH, to avoid these cases.
Best,
M.
Right there with you Marios. Also, sticking to RhinoCommon may in certain cases afford you a faster solution.
Hi Marios, thank you for replying. The above script you wrote, is it placed in rhino python editor, or is it in python for grasshopper component? I know the code runs perfectly in rhino python editor. But inside python for gh, we just can not run or execute the code like we can in rhino python editor.
And I'm sorry but what do you mean by "switch to rhinocommon inside gh"?
Check your type hints (right-click the input parameter), when using rhinoscriptsyntax you usually have to use Guids (the one called "ghdoc object"). Also, try reading the thread I linked to on the Rhino.Python forum.
Wow thank you Anders, ghdoc object works fine. So it seems the error rises from Type hint, not from Access type. Followed your thread, seems like Mitch encountered the same error as mine.
Mainly yes. But as Mitch' case exemplifies, it may be a bit more involved if one does not explicitly assign the Access type. Glad it worked though :)
@ Friedrich: Sorry for the late reply,
yes it is indeed for the editor in rhino.
@Anders:
Yeah rhinocommon is a lot faster. But good to know that this issue of incompatibility can be resolved with the use of ghdoc object declaration. Thanks for that tip.
Best,
M
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by