Grasshopper

algorithmic modeling for Rhino

hi all,

I'm trying to use the next example from ironpython guide but it doesn't works for me.

any help or suggestion?

thanks a lot,

regards,

roy

hatch

AddHatch(curve_id, hatch_pattern=None, scale=1.0, rotation=0.0)
Creates a new hatch object from a closed planar curve object
Parameters:
curve_id = identifier of the closed planar curve that defines the     boundary of the hatch object hatch_pattern[opt] = name of the hatch pattern to be used by the hatch     object. If omitted, the current hatch pattern will be used scale[opt] = hatch pattern scale factor rotation[opt] = hatch pattern rotation angle in degrees.
Returns:
identifier of the newly created hatch on success None on error
Example:
import rhinoscriptsyntax as rs
circle = rs.AddCircle(rs.WorldXYPlane(), 10.0)
if rs.IsHatchPattern("Grid"):
rs.AddHatch( circle, "Grid" )
else:
rs.AddHatch( circle, rs.CurrentHatchPattern() )

Views: 1627

Replies to This Discussion

hi tom,

thank you very much for your message.

your solution works perfectly.

anyway why I need to pass inside rhino baking the geometry to apply the hatch? the guide suggest to use the command directly in GH so I thought to see the hatch inside grasshopper before to bake it as others geometries. could you explain me why this is not (yet?) possible? 

thanks again,

roy

Hi guys,

Grasshopper has no concept of Hatches, nor any other dimension/annotation for the time being. That is why you can only make them work if you use them directly in Rhino, which of course has support for them.

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

Interesting,

How is syntax highlighting possible in Ning text boxes?

I think elefront was did in c# as gh plugin, so you can do this easier in c# as in elefront and with more difficult in python? we need to translate others rhino common API to python or the problem is different?

Hmmm,

Interesting. Thanks

tom, you're a genius.

to return an hatch instead of lines what do you think would we need? it's a problem of the limitation of rhino common API, grasshopper or what other limits ?

and why in the rhinoscriptsyntax there is this example as could be easy also to use hatches in GH?:

import rhinoscriptsyntax as rs
circle = rs.AddCircle(rs.WorldXYPlane(), 10.0)
if rs.IsHatchPattern("Grid"):
rs.AddHatch( circle, "Grid" )
else:
rs.AddHatch( circle, rs.CurrentHatchPattern() )

I did it, tom,  mixing your two solutions.

a output show the preview as lines, b output bake the hatch as hatch.

anyway what do you think about my last points?

Attachments:

You can add the following for picking through the available hatches.

active_doc = Rhino.RhinoDoc.ActiveDoc
h_patterns = active_doc.HatchPatterns
h_active = active_doc.HatchPatterns.CurrentHatchPatternIndex
h_cnt = h_patterns.Count

if style>cnt:
print("Not enough hatch patterns")
print("your current hatch pattern is " + h_active.ToString())
print("You can choose one from the hatches below:")
for j in range(h_cnt):
print(str(j)+ " = " + active_doc.HatchPatterns[j].Name.ToString())
active_doc.HatchPatterns.CurrentHatchPatternIndex = style

You need to register an int input named style

Ta,

M

hi Marios,

thank you very much for your message.

so now I can see the list of the hatches that are inside the rhino active documents.

how can I use them in grasshopper? it's possible to apply them to a closed curve and see the current hatch's preview inside grasshopper?

and what about the fact that inside the rhinoscriptsyntax commands there is this example:

import rhinoscriptsyntax as rs
circle = rs.AddCircle(rs.WorldXYPlane(), 10.0)
if rs.IsHatchPattern("Grid"):
rs.AddHatch( circle, "Grid" )
else:
rs.AddHatch( circle, rs.CurrentHatchPattern() )

as it could be very simple to use this command?


Previewing is not possible. As Tom mentioned you might be able to hack your way around it. I haven't tried it.

if you merge Tom's snippet and mine you will something working.

Best,

M

import Rhino
from Rhino.Geometry import Hatch

active_doc = Rhino.RhinoDoc.ActiveDoc
h_patterns = active_doc.HatchPatterns
h_active = active_doc.HatchPatterns.CurrentHatchPatternIndex
h_cnt = h_patterns.Count

if style>h_cnt:
print("Not enough hatch patterns")
print("your current hatch pattern is " + h_active.ToString())
print("You can choose one from the hatches below:")
for j in range(h_patterns.Count):
print(str(j)+ " = " + active_doc.HatchPatterns[j].Name.ToString())
active_doc.HatchPatterns.CurrentHatchPatternIndex = style

if bake:
hatches = Hatch.Create(curves,style,0.0,1.0)
for i in range(len(hatches)):
Rhino.RhinoDoc.ActiveDoc.Objects.AddHatch(hatches[i])

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