Grasshopper

algorithmic modeling for Rhino

I posted a bit earlier on generating boxes,

Now the problem I am having is manipulating them.

Ideally would like to enact random rotation, scaling, and color

But the message I am getting now as I try to manipulate the boxes I created is:

Runtime error (TypeErrorException): iteration over non-sequence of type Box

Sorry, not super clear on what this means, though if I make an assumption it sounds like, because I generated the boxes using from the Rhino.Geometry library then I can only manipulate them using Rhino library methods? Because now it needs Rhino's Point3d etc.  it seems once Rhino.Geometry library geometry is called it can only communicate with Rhino library methods...

Thanks, if someone has a second.. /:-(

Views: 1371

Replies to This Discussion

Hi Aaron,

this usually means that you are attempting a for loop over a single item.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Giulio :)  Thankyou for replying :)

I think I'm misunderstanding, is this not generally the case?  I generate the necessary elements to generate geometry, perform a series of alterations to the object, and then move on to the next one in the loop?  As I posted above, I'm trying to generate the boxes, scale, rotate, and change its color...

Thanks for your help!!

import rhinoscriptsyntax as rs
import random
import Rhino.Geometry.Box
import Rhino.Geometry.Interval

random.seed(seed)

a = []
b = []
c = []

for i in range(0,geometryCount):
    x = random.uniform(0,50)
    y = random.uniform(0,50)
    z = random.uniform(0,50)
    
    
    
    pt = rs.AddPoint(x,y,z)
    
    ptX = rs.AddPoint(x+1,y,z)
    ptY = rs.AddPoint(x,y+1,z)
    
    plane = rs.PlaneFromPoints(pt,ptX,ptY)
    
    int = Rhino.Geometry.Interval(0,size)
    
    box = Rhino.Geometry.Box(plane,int,int,int)
    
    
    xR1 = random.uniform(0,50)
    yR1 = random.uniform(0,50)
    zR1 = random.uniform(0,50)
    xR2 = random.uniform(0,50)
    yR2 = random.uniform(0,50)
    zR2 = random.uniform(0,50)
    
    start = rs.AddPoint(xR1,yR1,zR1)
    end = rs.AddPoint(xR2,yR2,zR2)
    

    rAngle = random.uniform(0,360)
    rVector = rs.VectorCreate(end,start)
    rotated = rs.RotateObject(box,pt,rAngle,rVector)
    
    
    
    a.append(start)
    b.append(box)
    c.append(rVector)
    d.append(rotated)

Hi Aaron, please attach the file!
See "How to get help on this forum" for details.

I need to understand the nature of geometryCount., and other things.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Gotya,

 

Here ya go.  Ideally I could manipulate the boxes in a number of ways after rotation, like I mentioned above...

 

 

Thanks again for your time!

Attachments:

Hi Aaron

RotateObject() need Guid,So you need to convert the box class to guid.Check the attached file.

I hope this helps

NARUTO

Attachments:

AWESOME

REALLY appreciate you taking a look at this for me, especially because I'm assuming these are kindof basic issues.

I wonder if I can ask just a couple more questions, it would be SUPER helpful.

1. I think in the past I just assumed GUID was a way to call an object ID, now I'm finding it's a form under which geometry appears in the code, which should be differentiated from classes and whatnot?

I looked through the Python primer and can't find documentation that details out the nature of GUID, (as opposed to classes etc.) could you suggest some documentation or possibly explain??

2.  In your corrections on the code in the file I posted you called a scriptcontext library yeah?  I'm just wondering about the scope and usefulness off this library... where it's coming from.

Thanks for cleaning syntax things up too,

Once again, THANKS, appreciate you taking the time :)

Aaron

1. Guids (Globally Unique IDentifiers) are a way to uniquely "name" every object in a document. You can see this ID in the Rhino property dialog, when the geometry is in the Rhino document.

For Grasshopper, GhPython creates a parallel document (without undo's and redo's, nor preview) that provides support to every Add() or Delete() call in rhinoscriptsytax. This is because rhinoscriptsyntax, with its AddLine(), AddMesh()... always assumes a document to which the function adds. The ID is then just the "name" by which each geometry in the document goes.

Guids are a form of data structure, but they are used as a reference to geometry; they are thus not geometry per se. You could create forged IDs that do not reference any geometry, for example.

2. The scriptcontext module is a helper module for rhinoscriptsyntax. It contains references to items that are needed for the script. It is usually accessed only for the sticky dictionary (shared beween GhPython and EditPythonScript) and for the doc target (the doc variable contains a reference to the active document).

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

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