ModelObject(Hatch) made with python does not show BackgroundColor

Hi there,

I created a ModelObject (Hatch) in Grasshopper using Python programmatically, but I am unable to find a way to set the “Background Color” attribute for the Hatch I created.

My goal is to access the Hatch Model Object and control its attributes such as PatternIndex, Rotation, Scale, BackgroundColor, Boundary Visibility, etc.

If anyone knows how to manipulate these attributes, please let me know!

Thank you so much!


Make ModelObject (Hatch) with Python.gh (21.8 KB)

import Rhino
import Grasshopper

## Make Hatch Geometry ( Rhino.Geometry.Hatch Class )
BaseGeometry_Hatch = Rhino.Geometry.Hatch.CreateFromBrep( HatchBoundary, 0, PatternIndex, 0, HatchScale, Rhino.Geometry.Point3d.Origin )

## Get Active Document
ActiveDoc = Rhino.RhinoDoc.ActiveDoc

## Make Document DEfault Attributes
DefaultAttributes = ActiveDoc.CreateDefaultAttributes()

## Setting Backgound Color
DefaultAttributes.HatchBackgroundFillColor = BackGroundColor

## Make Hatch ModelObejct ( Grasshopper.Rhinoceros.Model.ModelObject Class )
ModelObject_Hatch = Grasshopper.Rhinoceros.Model.ModelObject( ActiveDoc, DefaultAttributes, BaseGeometry_Hatch )

Finally I resolve for my self.

I wrote

## Convert to GH_Hatch
GhHatch = ModelObject_Hatch.CastTo[gh.Kernel.Types.GH_Hatch]()[1]

## Set Background Attributes
GhHatch.BackgroundColor = BackGroundColor

## Bring back again to Model Object
ModelObject_Hatch = ModelObject_Hatch.Cast( GhHatch )