Hello dear Honeybee Community and Developers,
@chris @mostapha
I’m trying to create a custom component that mimics the functionality of HB Opaque Material, with the goal of using it as input to the HB Opaque Construction component.
I’ve written a Grasshopper Python component to define a material, and while the script runs without errors, I’m encountering a problem when I try to connect its output to the HB Opaque Construction component. The error I get is:
1. Solution exception:Expected opaque energy material for construction. Got <type 'PyObject'>.
You can see the error in the attached image.
Here is the relevant code I’m using:
# Grasshopper Python Component for PCM Material Definition
# Import Honeybee modules
try:
from honeybee.typing import clean_ep_string
except ImportError as e:
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))
try:
from honeybee_energy.material.opaque import EnergyMaterial
except ImportError as e:
raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))
# Validate required inputs and build detailed messages
missing = []
error_messages = []
if name is None:
missing.append("name")
error_messages.append("Input 'name' (material name) is missing.")
if thickness is None:
missing.append("thickness")
error_messages.append("Input 'thickness' is missing.")
if conductivity is None:
missing.append("conductivity")
error_messages.append("Input 'conductivity' is missing.")
if density is None:
missing.append("density")
error_messages.append("Input 'density' is missing.")
if specific_heat is None:
missing.append("specific_heat")
error_messages.append("Input 'specific_heat' is missing.")
if temp_coeff is None:
missing.append("temp_coeff")
error_messages.append("Input 'temp_coeff' (temperature coefficient) is missing.")
if not temperature_list:
missing.append("temperature_list")
error_messages.append("Input 'temperature_list' is empty or missing.")
if not enthalpy_list:
missing.append("enthalpy_list")
error_messages.append("Input 'enthalpy_list' is empty or missing.")
if missing:
raise ValueError("\n" + "\n".join(error_messages))
# Set default values for optional inputs
roughness = "MediumRough" if roughness is None else roughness
thermal_absorptance = 0.9 if thermal_absorptance is None else thermal_absorptance
solar_absorptance = 0.7 if solar_absorptance is None else solar_absorptance
visible_absorptance = solar_absorptance if visible_absorptance is None else visible_absorptance
# Clean the material name
clean_name = clean_ep_string(name)
# Create the Honeybee EnergyMaterial
material_def_out = EnergyMaterial(
clean_name,
thickness,
conductivity,
density,
specific_heat,
roughness,
thermal_absorptance,
solar_absorptance,
visible_absorptance
)
# The phase change definition can be handled separately if needed
# ... (rest of your phase change code if required)