Error in GHPython creation of HB Electric Load Center

Hi there,
@chris

I hope you are pretty well.

I tried to modify the HB Electric Load Center with my future custom designed system. However, when I create a GHPython from the code embedded in the component, I received the following error:

ghenv.Component.Name = ‘HB Electric Load Center’
ghenv.Component.NickName = ‘ElectricCenter’
ghenv.Component.Message = ‘1.8.0’
ghenv.Component.Category = ‘HB-Energy’
ghenv.Component.SubCategory = ‘4 :: HVAC’
ghenv.Component.AdditionalHelpFromDocStrings = ‘6’
try:
from ladybug_rhino.grasshopper import all_required_inputs, give_warning
except ImportError as e:
raise ImportError(‘\nFailed to import ladybug_rhino:\n\t{}’.format(e))
if all_required_inputs(ghenv.Component):
# duplicate the input Model to avoid editing it
model = _model.duplicate()
# set default properties
inverter_eff = 0.96 if inverter_eff is None else inverter_eff
dc_to_ac_size = 1.1 if dc_to_ac_size is None else dc_to_ac_size
model.properties.energy.electric_load_center.inverter_efficiency = inverter_eff
model.properties.energy.electric_load_center.inverter_dc_to_ac_size_ratio = inverter_eff

Traceback (most recent call last):
File “rhinocode:///grasshopper/1/89191bc4-da4f-4dae-a506-a9b603961738/b12a971d-e491-4933-8063-c619784ae968”, line 60, in
AttributeError: ‘Object_2$2’ object has no attribute ‘duplicate’

  1. Error running script: ‘Object_2$2’ object has no attribute ‘duplicate’ [60:1]

I followed the data types for the inputs according to the main component.

I would appreciate it if you could kindly let me know how I can solve the challenge.

Thank you very much in advance for your time and assistance.

Sincerely,
Behnam

Hi @behnammmohseni ,

When working with objects created by the standard LBT components, you should use the ‘old’ GhPython component in Grasshopper- not the ‘new’ one. So if you type ‘#ghpython’ you’ll see the old one is still there in grasshopper, but sort of hidden (note the ‘#’ symbol).

If you use the ‘old’ component to write your script, it should work without error for you.

Best,
@edpmay

2 Likes

Hey @edpmay

Fantastic, now it’s working with the old GHPython (#ghpython)

Thanks very much for your help and time

1 Like