Hi, if I make a new document with no template and run a script that adds a hatch, just like the example, then no hatch is made since there are no hatch definitions in the file… so what should I do for it to automatically add “Solid” and use that?
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() )
The problem I guess is that if you run print rs.HatchNames() to an empty file then it returns nothing.
I have the same problem in 6SR13 with Python. There is no ‘Solid’ hatch in the document unless you manually create a hatch yourself first. Is there a work-around?
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
name = Rhino.DocObjects.HatchPattern.Defaults.Solid.Name
pattern = sc.doc.HatchPatterns.FindName(name)
if not pattern:
sc.doc.HatchPatterns.Add(Rhino.DocObjects.HatchPattern.Defaults.Solid)
circle = rs.AddCircle(rs.WorldXYPlane(), 10.0)
rs.AddHatch(circle, name)