Hello to all !
After reading a lot of everything that Icould find
on the net which was related to Dynamic Components and Ruby,
and a good Hint from Dan Rathburn , I managed to add
Lenx, Leny and Lenz to a Component I created with Ruby.
But I cannot find out how to set the _lenx_formula,
_leny_formula and _lenz_formula correctly, which means
if I manually enter a value in the DC Dialog it works,
but not if I set the Values from Code thru a simple dialog box.
Any help would be very appreciated
Sample code:
#set the component dictionary
@Component_dictionary = 'dynamic_attributes'
First prompt for the dimensions. This is done using the inputbox
method. In this case, we will actually use a wrapper for UI.inputbox
that is defined in sketchup.rb which does some extra error checking
The first step is to create some arrays which contain the prompts
and default values.
prompts = [("Bemerkung"),("Artikel"),("Laenge"), ("Breite"),("Staerke"),("Kante_links"),("Kante_rechts"),("Kante_oben"),("Kante_unten"),("Belag_Vorn"),("Belag_hinten")]
values = ["BodenDecke","Material1", 600.mm, 400.mm, 19.mm,"Kante1", "Kante1","","","",""]
list = ["", "Material1|Material2|Material3|Material4|Material5|Material6", "", "", "","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Kante1|Kante2|Kante3|Kante4|Kante5|Kante6","|Belag1|Belag2|Belag3|Belag4|Belag5|Belag6","|Belag1|Belag2|Belag3|Belag4|Belag5|Belag6"]
results = UI.inputbox(prompts, values, list, "Boden")
lenx_formula=laenge.to_f
leny_formula=breite.to_f
lenz_formula=staerke.to_f
comp1_def.definition.set_attribute @Component_dictionary,'lenx', '_lenx_formula'
comp1_def.definition.set_attribute @Component_dictionary,'_lenx_label', 'LenX'
comp1_def.set_attribute @Component_dictionary,'lenx', '_lenx_formula'
comp1_def.definition.set_attribute @Component_dictionary,'leny','_leny_formula'
comp1_def.definition.set_attribute @Component_dictionary,'_leny_label', 'LenY'
comp1_def.set_attribute @Component_dictionary,'leny','_leny_formula'
comp1_def.definition.set_attribute @Component_dictionary,'lenz', '_lenz_formula'
comp1_def.definition.set_attribute @Component_dictionary,'_lenz_label', 'LenZ'
comp1_def.set_attribute @Component_dictionary,'lenz', '_lenz_formula'
$dc_observers.get_latest_class.redraw_with_undo
(comp1_def_instance)