Grasshopper

algorithmic modeling for Rhino

Hi, I'm trying to write a Gh Python script to be able to do an offset to a trimmed surface as a solid. I don't have any experience with Gh Python, so erverything I managed to do was by watching some videos. I'm not really sure if it's even possible to do the offset surface as a solid, but I thought if it is possible in Rhino, it must be possible in Grasshopper through Python probably. And according to the Rhino IronPython help window, the OffsetSurface command shows the solid=True option.

So, I wrote the script, connected the input surface and the distance, and when I tested it the script it sayid: "Execution completed successfully". However, the Rhino viewport shows no results, and the script's component output seems empty. I'm attaching an image and the definition, in case anyone can take a quick look at it and help me out.

Views: 1190

Attachments:

Replies to This Discussion

Hi Fernando,

It looks like you are using an older version of Rhino 5, which OffsetSurface function was restricted to non-trimmed brep faces only.
Try searching for "surface.py" on your hardisk. Once you find it, open it, and replace the following line:

if brep.IsSurface: face = brep.Faces[0]

with:

if (1 == brep.Faces.Count): face = brep.Faces[0]

Save the surface.py file. Close your Rhino and grasshopper, and run them again.

Other than that, you need to assing the OffsetSurface function result to some ghpython component output parameter. "a" for example:

a = rs.OffsetSurface(Brep, Distance, create_solid=True)

For any further rhino/grasshopper python issues, I would recommend introducing yourself with learning material from mcneels website, first.

Attachments:

Hi djordje, I am trying to follow the instructions you gave me. However, the "surface.py" file does not have any line:

if brep.IsSurface: face = brep.Faces[0]

the only line it has that contains "if brep" is the one I highlited on the image attached. What should I do with this? I'm attaching the "surface.py" file.

I'll take a look to the referenced learning material. Thank you very much for the corrected definition; which, by the way, I noticed you also imported "scriptcontext", though you didn't use it within the script, may I ask why?

Regards,

Attachments:

Hi,
If upper line does not exist in your surface.py file, then you are ok, and you only had to assign the result of the OffsetSurface function to "a" output parameter. The attached LampShade2.gh file should work.
Disregard the "imported "scriptcontext". It is not important for your case.

Yes, I realised an hour later that the file you attached worked perfectly as it was, no need to edit the "surface.py" file. Thank you very much for your time djordje.

Regards,

Fernando Maytorena

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service