Grasshopper

algorithmic modeling for Rhino

what would the equivalent command be to amplitude for adding length to a vector? Thanks

Views: 1354

Replies to This Discussion

a better question would be how do I factor a vector, so take a vector and multiply by itself a number of times. I tried vec=vector**4 but get 

Runtime error (TypeErrorException): unsupported operand type(s) for **: 'Vector3d' and 'int'

The correct syntax is using just one *. Like so:

import Rhino as rc

myVec = rc.Geometry.Vector3d(0,0,1)
myVec = myVec * 2

print myVec.Length

Or:

import Rhino as rc

myVec = rc.Geometry.Vector3d(0,0,1)
myVec *= 2

print myVec.Length


You also can add, subtract etc. using mathematical operators (+,- etc.). You can read more about this in the RhinoCommon SDK.


thanks!

Hi Ethan

 You can use rs. VectorScale () function,Check the attached file

Attachments:

Thanks naruto that is really helpful. I will study it! I worked around the issue by using a for loop. I am trying to dig deeper in to looping and working with python. After scaling the vector i am trying to say, iterate through this vector by increasing scale until the distance is greater than a number... then choose the one just below that... I have it almost working but not sure how to nest an if in a for loop to say if this is condition is met stop the loop... Thanks!

import rhinoscriptsyntax as rs
list = []
for num in range (number):

m = rs.MoveObject(x,y)
pt2 = rs.CurveStartPoint(x)
dist = rs.Distance(pt,pt2)
list.append(m)
if dist < 30:
return
a = lis

t

Can you upload your file?

thanks for your help. I'm also curious why this list num slider doesn't seem to affect the output. i thought it worked like list item where i could choose which item in the list i want...? Thanks so much

Attachments:

Hi Ethan

Check the attached file

Attachments:

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