Hi all,
when I try to update a dynamic component with a custom Ruby plugin I get the following errors:
Error: #<ArgumentError: comparison of Length with nil failed>
or
Error: #<TypeError: can't convert nil into an exact number>
depending on the value type I pass to set_attribute
method.
In my code, I import a dynamic component saved in a hidden project and add it to current project, updating some dynamic attributes: length, width, …
my_instance = my_group.entities.add_instance(my_component, [0, 0, 0])
# updating custom_width, not LenX, because I need to perform some formulas
my_instance.definition.set_attribute('dynamic_attributes', 'custom_width', 20)
Once I force the redraw with
$dc_observers.get_latest_class.redraw(my_instance)
I get the errors above.
I’ve also tried to use 20.cm
or "20"
but I always get an error.
I get an error even when forcing the redraw without applying any changes.
my_instance = my_group.entities.add_instance(my_component, [0, 0, 0])
$dc_observers.get_latest_class.redraw(my_instance)
I also tried to apply changes before adding the component to the project:
my_component.set_attribute('dynamic_attributes', 'custom_width', 20)
my_instance = my_group.entities.add_instance(my_component, [0, 0, 0])
$dc_observers.get_latest_class.redraw(my_instance)
So my guess is that there’s an error somewhere in my dynamic component, but…
If I apply the change without redrawing the component, I see it in the “Component Options” window so it’s accepted. If I click on the “Apply” button the component is updated without any error.
Do you know where’s the problem?
Thanks for your help.