Grasshopper

algorithmic modeling for Rhino

while I was reading a tutorial from a China Publishing, which they introduce python in the defination, to do some offset surface and at the same time, make it solid. I try to copy it from the book and put them into my very first python script, but it turns out it didnt work. 

from the error message I guess I should have a line of Global variables which should looks like:

Srf = rs.xxxxxx(whatever it is)

Thicken = rs.GetReal(whatever it is)

but the problem is, why the code on the left of the attached image actually works? while they dont have a global variables part in their code?

it will be great if anyone can help on this, thanks

Views: 549

Attachments:

Replies to This Discussion

It surely didn't work because your component has not an input named Srf (with a Surface type) ! 

The entries of component you don't write then in the code editor but in Grasshopper, with clicks, renaming, selecting types ... For more help post your code. 

this is the where the code is

one of them I just copy from the tutorial material

the other one is what I copy back in

thanks a lot

Attachments:

Ok, you have some work to do. Little advice, find some videos explaining how to use Python for Grasshopper.

First the most simple is to use entry from grasshopper. So take a component that get surfaces and connect it to the "Srf" entry of your Python. You could name it like you want, and its name will be used in program as a variable. By default their names are x, y ... In the good program it is named "Srf",  "Thicken" is a number so you need to feed a number, here with a slider. 

import rhinoscriptsyntax as rs

OffsetSrf = rs.OffsetSurface(Srf,Thicken,None,False,True)

It is the same for the output, you have to use the same name as the name on the right part of the component. here "OffsetSrf" on your component "a". By default the output names are a, b ... 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service