Dynamic Components problem with arguments


#1

Please, run following code:

new_front = Sketchup.active_model.definitions.add 'aqq’
new_front.name = 'aqq’
new_front.set_attribute(“dynamic_attributes”, “item_price”,‘zielony’)

pts=[]
pts[0] = [0, 0,0]
pts[1] = [0, 20,0]
pts[2] = [10, 20,0]
pts[3] = [10, 0,0]

face = new_front.entities.add_face pts
face.reverse!
face.pushpull(50, false)

new_front_inst = Sketchup.active_model.entities.add_instance(new_front,[0,0,0])

And next go to menu Window\Component Attribiutes and try to change value of “item_price” argument.
What’s happen?
In may case is generating new argument -“item” with new value and argument “item_price” is steel with the same value!

SU 2105.2.685 64-bit win10

Can you observe the same?


#2

The DC needs a little bit more information to work right.

I added two necessary lines. This works.

new_front = Sketchup.active_model.definitions.add 'aqq'
new_front.name = 'aqq'
#the DC needs to be able to identify the component definition
new_front.set_attribute("dynamic_attributes","_name", new_front.name)
#it needs to know what label to show
new_front.set_attribute("dynamic_attributes","_item_price_label", "item_price")
new_front.set_attribute("dynamic_attributes", "item_price",'zielony')

pts=[]
pts[0] = [0, 0,0]
pts[1] = [0, 20,0]
pts[2] = [10, 20,0]
pts[3] = [10, 0,0]
face = new_front.entities.add_face pts
face.reverse!
face.pushpull(50, false)
new_front_inst = Sketchup.active_model.entities.add_instance(new_front,[0,0,0])

#3

Thank You, Neil.