Hello is there way to collect all hatch patterns in a drop down menu in Python and assign one pattern to an object and assign a pattern in a table row on the UI ?
not sure if this is what you want, it asks to pick on a hatch pattern, displays a popup menu of all pattern names and assigns the picked hatch pattern. It also updates the UI in properties:
import rhinoscriptsyntax as rs
def HatchPatternChanger():
# pick a hatch pattern
rc = rs.GetObjectEx("Pick a hatch pattern", rs.filter.hatch, False, True)
if not rc: return
hatch_id, pre_selected, selection_method, pt, view_name = rc
# get picked hatch pattern name and all hatch names
current_hatch_name = rs.HatchPattern(hatch_id)
hatch_names = rs.HatchPatternNames()
# create modes for the popup menu
modes = [3 if current_hatch_name == n else 0 for n in hatch_names]
# popup a menu
index = rs.PopupMenu(hatch_names, modes, pt, view_name)
if not index >= 0: return
# assign the picked hatch pattern
rs.HatchPattern(hatch_id, hatch_names[index])
HatchPatternChanger()
_
c.
2 Likes
Hi clement,
Many thank. This is what I was looking for “rs.HatchPatternNames()”.
By the way I started working on it but did not get through from Rhino Common.
import rhinoscriptsyntax as rs
import Rhino
names = List[str]()
hatchList = Rhino.DocObjects.Tables.HatchPatternTable
#: IEnumerable<HatchPattern>, IEnumerable
def get_names():
hatchList = Rhino.DocObjects.Tables.HatchPatternTable
hatchList.Add
return hatchList
for name in get_names():
print name