Can I add new entity in advance attribute?

Can I add new entity in advance attribute?

No, but you can use dynamic components or ruby script to create and work with custom attributes

@pcmoor i have tried set custom attributes to existing dc cabinet. It works. Than when i try to save as the dc and load it back the attributes are not there. Even when i repeat the process and before save as I try to change the Dc definition .
Why is this ? Do i have to write some script to change dc definition?

P.s. when i wrap dc with new attributes to outher shell holder it preserves the newly set attributes.

To clarify, you mean the values are lost, or the actual attribute?
Some values can be overridden by the value retained (“current”) within the component, as with Material, unless there is a formula pointing to a value and that exists in the file. So swatches are used or nesting to safe guard these values.
Could you post an example, then can possible be on the same track?

hi @pcmoor
I ment the arrtibutes are lost made an movie to show what is happening.

it is just to set new attributes to existing cabinets . some of the attributes are already in cabinet but need to be updated and others are new . it seems to me it doesnt want to save DC with new attributes because the definition of DC stays the same. but than i even change the definition to DC with new attributes and “save as” but no change.
it might it be minor problem that i am not avare of but ruby is still something i cannot learn as fast as i wish.
the code has too meny lines for seting the attributes. still very easy code. hope you could have a look what is missing there what supposed to be there. thank you

#mod = Sketchup.active_model # Open model
sel = mod.selection # Current selection
sel.grep(Sketchup::ComponentInstance).each do |s|
# attribute zakaznik
  s.set_attribute 'dynamic_attributes', 'aameno', ''
  s.set_attribute 'dynamic_attributes', '_aameno_formula', ''
  s.set_attribute 'dynamic_attributes', '_aameno_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_aameno_access','TEXTBOX'
  s.set_attribute 'dynamic_attributes', '_aameno_formlabel','ZAKAZNIK'
  s.set_attribute 'dynamic_attributes', '_aameno_label','AAMENO'

# attribute nazov skrinky ci ineho vrapera
  s.set_attribute 'dynamic_attributes', 'ameno', ''
  s.set_attribute 'dynamic_attributes', '_ameno_formula', ''
  s.set_attribute 'dynamic_attributes', '_ameno_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_ameno_access','TEXTBOX'
  s.set_attribute 'dynamic_attributes', '_ameno_formlabel','NAZOV'
  s.set_attribute 'dynamic_attributes', '_ameno_label','AMENO'

# attribute zostava
  s.set_attribute 'dynamic_attributes', 'azcode', ''
  s.set_attribute 'dynamic_attributes', '_azcode_formula', ''
  s.set_attribute 'dynamic_attributes', '_azcode_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_azcode_access','TEXTBOX'
  s.set_attribute 'dynamic_attributes', '_azcode_formlabel','ZOSTAVA'
  s.set_attribute 'dynamic_attributes', '_azcode_label','AZCODE'

# attribute popis
  s.set_attribute 'dynamic_attributes', 'popis', ''
  s.set_attribute 'dynamic_attributes', '_popis_formula', 'CONCATENATE(ameno ," - ",aameno)'
  s.set_attribute 'dynamic_attributes', '_popis_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_popis_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_popis_formlabel','POPIS'
  s.set_attribute 'dynamic_attributes', '_popis_label','POPIS'


# ATTRIBUTES PLOSNY MATERIAL

# attr. material dveri 1. moznost
  s.set_attribute 'dynamic_attributes', 'rdvere', ''
  s.set_attribute 'dynamic_attributes', '_rdvere_access', 'LIST'
  s.set_attribute 'dynamic_attributes', '_rdvere_formlabel', 'material dveri 1.moznost'  
  s.set_attribute 'dynamic_attributes', '_rdvere_units', 'STRING' 
  s.set_attribute 'dynamic_attributes', '_rdvere_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rdvere_label', 'rdvere'
  s.set_attribute 'dynamic_attributes', '_rdvere_options', '&&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'
  s.set_attribute 'dynamic_attributes', '_rdvere_formula', 'dvere1!matcode'



# attr. material dveri 2. moznost
  s.set_attribute 'dynamic_attributes', 'rdvere1',''
  s.set_attribute 'dynamic_attributes', '_rdvere1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rdvere1_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rdvere1_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rdvere1_label','rdvere1'
  s.set_attribute 'dynamic_attributes', '_rdvere1_options', '&&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'
  s.set_attribute 'dynamic_attributes', '_rdvere1_formula', 'dvere2!matcode'
  s.set_attribute 'dynamic_attributes', '_rdvere1_formlabel', 'material dveri 2.moznost'


# attr. material korpusu 1. moznost
  s.set_attribute 'dynamic_attributes', 'rkorpus',''
  s.set_attribute 'dynamic_attributes', '_rkorpus_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rkorpus_label','rkorpus'
  s.set_attribute 'dynamic_attributes', '_rkorpus_options', '&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'
  s.set_attribute 'dynamic_attributes', '_rkorpus_formula','korpus1!matcode'
  s.set_attribute 'dynamic_attributes', '_rkorpus_formlabel','material korpus 1.moznost'


# attr. material korpusu 2. moznost
  s.set_attribute 'dynamic_attributes', 'rkorpus1',''
  s.set_attribute 'dynamic_attributes', '_rkorpus1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus1_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus1_access', 'LIST'
  s.set_attribute 'dynamic_attributes', '_rkorpu1s_label','rkorpus1'
  s.set_attribute 'dynamic_attributes', '_rkorpus1_formlabel', 'material korpus 2.moznost'
  s.set_attribute 'dynamic_attributes', '_rkorpus1_formula', 'korpus2!matcode'
  s.set_attribute 'dynamic_attributes', '_rkorpus1_options', '&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'

# attr. material chrbatu 1. moznost
  s.set_attribute 'dynamic_attributes', 'rchrbat', ''
  s.set_attribute 'dynamic_attributes', '_rchrbat_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat_access', 'LIST'
  s.set_attribute 'dynamic_attributes', '_rchrbat_label','rchrbat'
  s.set_attribute 'dynamic_attributes', '_rchrbat_formlabel', 'material chrbat 1.moznost'
  s.set_attribute 'dynamic_attributes', '_rchrbat_formula', 'chrbat1!matcode'
  s.set_attribute 'dynamic_attributes', '_rchrbat_options', '&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'

# attr. material chrbatu 2. moznost
  s.set_attribute 'dynamic_attributes', 'rchrbat1', ''
  s.set_attribute 'dynamic_attributes', '_rchrbat1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_formulaunits', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_access', 'LIST'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_label', 'rchrbat1'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_formlabel', 'material chrbat 2.moznost'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_formula', 'chrbat2!matcode'
  s.set_attribute 'dynamic_attributes', '_rchrbat1_options', '&dvere1=%3Ddvere1%21matcode&dvere2=%3Ddvere2%21matcode&dvere3=%3Ddvere3%21matcode&dvere4=%3Ddvere4%21matcode&korpus1=%3Dkorpus1%21matcode&korpus2=%3Dkorpus2%21matcode&korpus3=%3Dkorpus3%21matcode&korpus4=%3Dkorpus4%21matcode&chrbat1=%3Dchrbat1%21matcode&chrbat2=%3Dchrbat2%21matcode&chrbat3=%3Dchrbat3%21matcode&'

# attribute colordv 1
  s.set_attribute 'dynamic_attributes', 'colordv', ''
  s.set_attribute 'dynamic_attributes', '_colordv_formula', 'if(optionindex("rdvere")=1,dvere1!material,if(optionindex("rdvere")=2,dvere2!material,if(optionindex("rdvere")=3,dvere3!material,if(optionindex("rdvere")=4,dvere4!material,if(optionindex("rdvere")=5,korpus1!material,if(optionindex("rdvere")=6,korpus2!material,if(optionindex("rdvere")=7,korpus3!material,if(optionindex("rdvere")=8,korpus4!material,if(optionindex("rdvere")=9,chrbat1!material,if(optionindex("rdvere")=10,chrbat2!material,if(optionindex("rdvere")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colordv_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colordv_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colordv_formlabel','colordv'
  s.set_attribute 'dynamic_attributes', '_colordv_label','colordv'

# attribute colordv 2
  s.set_attribute 'dynamic_attributes', 'colordv1', ''
  s.set_attribute 'dynamic_attributes', '_colordv1_formula', 'if(optionindex("rdvere1")=1,dvere1!material,if(optionindex("rdvere1")=2,dvere2!material,if(optionindex("rdvere1")=3,dvere3!material,if(optionindex("rdvere1")=4,dvere4!material,if(optionindex("rdvere1")=5,korpus1!material,if(optionindex("rdvere1")=6,korpus2!material,if(optionindex("rdvere1")=7,korpus3!material,if(optionindex("rdvere1")=8,korpus4!material,if(optionindex("rdvere1")=9,chrbat1!material,if(optionindex("rdvere1")=10,chrbat2!material,if(optionindex("rdvere1")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colordv1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colordv1_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colordv1_formlabel','colordv1'
  s.set_attribute 'dynamic_attributes', '_colordv1_label','colordv1'

# attribute colorkor 
  s.set_attribute 'dynamic_attributes', 'colorkor', ''
  s.set_attribute 'dynamic_attributes', '_colorkor_formula', 'if(optionindex("rkorpus")=1,dvere1!material,if(optionindex("rkorpus")=2,dvere2!material,if(optionindex("rkorpus")=3,dvere3!material,if(optionindex("rkorpus")=4,dvere4!material,if(optionindex("rkorpus")=5,korpus1!material,if(optionindex("rkorpus")=6,korpus2!material,if(optionindex("rkorpus")=7,korpus3!material,if(optionindex("rkorpus")=8,korpus4!material,if(optionindex("rkorpus")=9,chrbat1!material,if(optionindex("rkorpus")=10,chrbat2!material,if(optionindex("rkorpus")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colorkor_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colorkor_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colorkor_formlabel','colorkor'
  s.set_attribute 'dynamic_attributes', '_colorkor_label','colorkor'

# attribute colorkor 1
  s.set_attribute 'dynamic_attributes', 'colorkor1', ''
  s.set_attribute 'dynamic_attributes', '_colorkor1_formula', 'if(optionindex("rkorpus1")=1,dvere1!material,if(optionindex("rkorpus1")=2,dvere2!material,if(optionindex("rkorpus1")=3,dvere3!material,if(optionindex("rkorpus1")=4,dvere4!material,if(optionindex("rkorpus1")=5,korpus1!material,if(optionindex("rkorpus1")=6,korpus2!material,if(optionindex("rkorpus1")=7,korpus3!material,if(optionindex("rkorpus1")=8,korpus4!material,if(optionindex("rkorpus1")=9,chrbat1!material,if(optionindex("rkorpus1")=10,chrbat2!material,if(optionindex("rkorpus1")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colorkor1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colorkor1_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colorkor1_formlabel','colorkor1'
  s.set_attribute 'dynamic_attributes', '_colorkor1_label','colorkor1'

# attribute colorch
  s.set_attribute 'dynamic_attributes', 'colorch', ''
  s.set_attribute 'dynamic_attributes', '_colorch_formula', 'if(optionindex("rchrbat")=1,dvere1!material,if(optionindex("rchrbat")=2,dvere2!material,if(optionindex("rchrbat")=3,dvere3!material,if(optionindex("rchrbat")=4,dvere4!material,if(optionindex("rchrbat")=5,korpus1!material,if(optionindex("rchrbat")=6,korpus2!material,if(optionindex("rchrbat")=7,korpus3!material,if(optionindex("rchrbat")=8,korpus4!material,if(optionindex("rchrbat")=9,chrbat1!material,if(optionindex("rchrbat")=10,chrbat2!material,if(optionindex("rchrbat")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colorch_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colorch_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colorch_formlabel','colorch'
  s.set_attribute 'dynamic_attributes', '_colorch_label','colorch'

# attribute colorch1
  s.set_attribute 'dynamic_attributes', 'colorch1', ''
  s.set_attribute 'dynamic_attributes', '_colorch1_formula', 'if(optionindex("rchrbat1")=1,dvere1!material,if(optionindex("rchrbat1")=2,dvere2!material,if(optionindex("rchrbat1")=3,dvere3!material,if(optionindex("rchrbat1")=4,dvere4!material,if(optionindex("rchrbat1")=5,korpus1!material,if(optionindex("rchrbat1")=6,korpus2!material,if(optionindex("rchrbat1")=7,korpus3!material,if(optionindex("rchrbat1")=8,korpus4!material,if(optionindex("rchrbat1")=9,chrbat1!material,if(optionindex("rchrbat1")=10,chrbat2!material,if(optionindex("rchrbat1")=11,chrbat3!material,0)))))))))))'
  s.set_attribute 'dynamic_attributes', '_colorch1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_colorch1_access','NONE'
  s.set_attribute 'dynamic_attributes', '_colorch1_formlabel','colorch1'
  s.set_attribute 'dynamic_attributes', '_colorch1_label','colorch1'

# attribute rdvere05 - hrubka materialu rdvere
  s.set_attribute 'dynamic_attributes', 'rdvere05', ''
  s.set_attribute 'dynamic_attributes', '_rdvere05_formula', 'if(optionindex("rdvere")=1,dvere1!ihrubka,if(optionindex("rdvere")=2,dvere2!ihrubka,if(optionindex("rdvere")=3,dvere3!ihrubka,if(optionindex("rdvere")=4,dvere4!ihrubka,if(optionindex("rdvere")=5,korpus1!ihrubka,if(optionindex("rdvere")=6,korpus2!ihrubka,if(optionindex("rdvere")=7,korpus3!ihrubka,if(optionindex("rdvere")=8,korpus4!ihrubka,if(optionindex("rdvere")=9,chrbat1!ihrubka,if(optionindex("rdvere")=10,chrbat2!ihrubka,if(optionindex("rdvere")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rdvere05_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rdvere05_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rdvere05_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rdvere05_label','rdvere05'

# attribute rdvere2 - hrubka materialu rdvere1
  s.set_attribute 'dynamic_attributes', 'rdvere2', ''
  s.set_attribute 'dynamic_attributes', '_rdvere2_formula', 'if(optionindex("rdvere1")=1,dvere1!ihrubka,if(optionindex("rdvere1")=2,dvere2!ihrubka,if(optionindex("rdvere1")=3,dvere3!ihrubka,if(optionindex("rdvere1")=4,dvere4!ihrubka,if(optionindex("rdvere1")=5,korpus1!ihrubka,if(optionindex("rdvere1")=6,korpus2!ihrubka,if(optionindex("rdvere1")=7,korpus3!ihrubka,if(optionindex("rdvere1")=8,korpus4!ihrubka,if(optionindex("rdvere1")=9,chrbat1!ihrubka,if(optionindex("rdvere1")=10,chrbat2!ihrubka,if(optionindex("rdvere1")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rdvere2_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rdvere2_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rdvere2_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rdvere2_label','rdvere2'

# attribute rkorpus05 - hrubka materialu rkorpus
  s.set_attribute 'dynamic_attributes', 'rkorpus05', ''
  s.set_attribute 'dynamic_attributes', '_rkorpus05_formula', 'if(optionindex("rkorpus")=1,dvere1!ihrubka,if(optionindex("rkorpus")=2,dvere2!ihrubka,if(optionindex("rkorpus")=3,dvere3!ihrubka,if(optionindex("rkorpus")=4,dvere4!ihrubka,if(optionindex("rkorpus")=5,korpus1!ihrubka,if(optionindex("rkorpus")=6,korpus2!ihrubka,if(optionindex("rkorpus")=7,korpus3!ihrubka,if(optionindex("rkorpus")=8,korpus4!ihrubka,if(optionindex("rkorpus")=9,chrbat1!ihrubka,if(optionindex("rkorpus")=10,chrbat2!ihrubka,if(optionindex("rkorpus")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rkorpus05_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus05_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rkorpus05_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rkorpus05_label','rkorpus05'

# attribute rkorpus2 - hrubka materialu rkorpus1
  s.set_attribute 'dynamic_attributes', 'rkorpus2', ''
  s.set_attribute 'dynamic_attributes', '_rkorpus2_formula', 'if(optionindex("rkorpus1")=1,dvere1!ihrubka,if(optionindex("rkorpus1")=2,dvere2!ihrubka,if(optionindex("rkorpus1")=3,dvere3!ihrubka,if(optionindex("rkorpus1")=4,dvere4!ihrubka,if(optionindex("rkorpus1")=5,korpus1!ihrubka,if(optionindex("rkorpus1")=6,korpus2!ihrubka,if(optionindex("rkorpus1")=7,korpus3!ihrubka,if(optionindex("rkorpus1")=8,korpus4!ihrubka,if(optionindex("rkorpus1")=9,chrbat1!ihrubka,if(optionindex("rkorpus1")=10,chrbat2!ihrubka,if(optionindex("rkorpus1")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rkorpus2_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rkorpus2_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rkorpus2_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rkorpus2_label','rkorpus2'

  # attribute rchrbat05- hrubka materialu rchrbat
  s.set_attribute 'dynamic_attributes', 'rchrbat05', 'chrbat1!ihrubka'
  s.set_attribute 'dynamic_attributes', '_rchrbat05_formula', 'if(optionindex("rchrbat")=1,dvere1!ihrubka,if(optionindex("rchrbat")=2,dvere2!ihrubka,if(optionindex("rchrbat")=3,dvere3!ihrubka,if(optionindex("rchrbat")=4,dvere4!ihrubka,if(optionindex("rchrbat")=5,korpus1!ihrubka,if(optionindex("rchrbat")=6,korpus2!ihrubka,if(optionindex("rchrbat")=7,korpus3!ihrubka,if(optionindex("rchrbat")=8,korpus4!ihrubka,if(optionindex("rchrbat")=9,chrbat1!ihrubka,if(optionindex("rchrbat")=10,chrbat2!ihrubka,if(optionindex("rchrbat")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rchrbat05_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat05_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rchrbat05_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rchrbat05_label','rchrbat05'

  # attribute rchrbat2- hrubka materialu rchrbat1
  s.set_attribute 'dynamic_attributes', 'rchrbat2', 'chrbat2!ihrubka'
  s.set_attribute 'dynamic_attributes', '_rchrbat2_formula', 'if(optionindex("rchrbat1")=1,dvere1!ihrubka,if(optionindex("rchrbat1")=2,dvere2!ihrubka,if(optionindex("rchrbat1")=3,dvere3!ihrubka,if(optionindex("rchrbat1")=4,dvere4!ihrubka,if(optionindex("rchrbat1")=5,korpus1!ihrubka,if(optionindex("rchrbat1")=6,korpus2!ihrubka,if(optionindex("rchrbat1")=7,korpus3!ihrubka,if(optionindex("rchrbat1")=8,korpus4!ihrubka,if(optionindex("rchrbat1")=9,chrbat1!ihrubka,if(optionindex("rchrbat1")=10,chrbat2!ihrubka,if(optionindex("rchrbat1")=11,chrbat3!ihrubka,1)))))))))))'
  s.set_attribute 'dynamic_attributes', '_rchrbat2_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rchrbat2_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rchrbat2_formlabel','HRUBKA'
  s.set_attribute 'dynamic_attributes', '_rchrbat2_label','rchrbat2'

# ATTRIBUTE ABS HRANY
# ATTR. rabs abs ABS korpus 1.moznost
  s.set_attribute 'dynamic_attributes', 'rabs', ''
  s.set_attribute 'dynamic_attributes', '_rabs_formula','abs korpus1!material'
  s.set_attribute 'dynamic_attributes', '_rabs_options', '&abs%20korpus1=%3Dabs%20korpus1%21material&abs%20korpus2=%3Dabs%20korpus2%21material&abs%20korpus3=%3Dabs%20korpus3%21material&abs%20korpus4=%3Dabs%20korpus4%21material&abs%20dvere1=%3Dabs%20dvere1%21material&abs%20dvere2=%3Dabs%20dvere2%21material&abs%20dvere3=%3Dabs%20dvere3%21material&abs%20dvere4=%3Dabs%20dvere4%21material&'
  s.set_attribute 'dynamic_attributes', '_rabs_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rabs_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rabs_formlabel','ABS korpus 1.moznost'
  s.set_attribute 'dynamic_attributes', '_rabs_label','rabs'

# ATTR. rabs05 abs ABS korpus 2.moznost
  s.set_attribute 'dynamic_attributes', 'rabs05', ''
  s.set_attribute 'dynamic_attributes', '_rabs05_formula','abs korpus2!material'
  s.set_attribute 'dynamic_attributes', '_rabs05_options', '&abs%20korpus1=%3Dabs%20korpus1%21material&abs%20korpus2=%3Dabs%20korpus2%21material&abs%20korpus3=%3Dabs%20korpus3%21material&abs%20korpus4=%3Dabs%20korpus4%21material&abs%20dvere1=%3Dabs%20dvere1%21material&abs%20dvere2=%3Dabs%20dvere2%21material&abs%20dvere3=%3Dabs%20dvere3%21material&abs%20dvere4=%3Dabs%20dvere4%21material&'
  s.set_attribute 'dynamic_attributes', '_rabs05_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rabs05_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rabs05_formlabel','ABS korpus 2.moznost'
  s.set_attribute 'dynamic_attributes', '_rabs05_label','rabs05'

# ATTR. rabs1 abs ABS dvere 1.moznost
  s.set_attribute 'dynamic_attributes', 'rabs1', ''
  s.set_attribute 'dynamic_attributes', '_rabs1_formula','abs dvere1!material'
  s.set_attribute 'dynamic_attributes', '_rabs1_options', '&abs%20korpus1=%3Dabs%20korpus1%21material&abs%20korpus2=%3Dabs%20korpus2%21material&abs%20korpus3=%3Dabs%20korpus3%21material&abs%20korpus4=%3Dabs%20korpus4%21material&abs%20dvere1=%3Dabs%20dvere1%21material&abs%20dvere2=%3Dabs%20dvere2%21material&abs%20dvere3=%3Dabs%20dvere3%21material&abs%20dvere4=%3Dabs%20dvere4%21material&'
  s.set_attribute 'dynamic_attributes', '_rabs1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rabs1_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rabs1_formlabel','ABS dvere 1.moznost'
  s.set_attribute 'dynamic_attributes', '_rabs1_label','rabs1'

# ATTR. rabs2 abs ABS dvere 2.moznost
  s.set_attribute 'dynamic_attributes', 'rabs2', ''
  s.set_attribute 'dynamic_attributes', '_rabs2_formula','abs dvere2!material'
  s.set_attribute 'dynamic_attributes', '_rabs2_options', '&abs%20korpus1=%3Dabs%20korpus1%21material&abs%20korpus2=%3Dabs%20korpus2%21material&abs%20korpus3=%3Dabs%20korpus3%21material&abs%20korpus4=%3Dabs%20korpus4%21material&abs%20dvere1=%3Dabs%20dvere1%21material&abs%20dvere2=%3Dabs%20dvere2%21material&abs%20dvere3=%3Dabs%20dvere3%21material&abs%20dvere4=%3Dabs%20dvere4%21material&'
  s.set_attribute 'dynamic_attributes', '_rabs2_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_rabs2_access','LIST'
  s.set_attribute 'dynamic_attributes', '_rabs2_formlabel','ABS dvere 2.moznost'
  s.set_attribute 'dynamic_attributes', '_rabs2_label','rabs2'

# ATTR. COLOR abs ABS KORPUS 1.moznost
  s.set_attribute 'dynamic_attributes', 'color', ''
  s.set_attribute 'dynamic_attributes', '_color_formula', 'if(optionindex("rabs")=1,abs korpus1!material,if(optionindex("rabs")=2,abs korpus2!material,if(optionindex("rabs")=3,abs korpus3!material,if(optionindex("rabs")=4,abs korpus4!material,if(optionindex("rabs")=5,abs dvere1!material,if(optionindex("rabs")=6,abs dvere2!material,if(optionindex("rabs")=7,abs dvere3!material,if(optionindex("rabs")=8,abs dvere4!material,0))))))))'
  s.set_attribute 'dynamic_attributes', '_color_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_color_access','NONE'
  s.set_attribute 'dynamic_attributes', '_color_formlabel','color'
  s.set_attribute 'dynamic_attributes', '_color_label','color'

# ATTR. COLOR05 abs ABS KORPUS 2.moznost
  s.set_attribute 'dynamic_attributes', 'color05', ''
  s.set_attribute 'dynamic_attributes', '_color05_formula', 'if(optionindex("rabs05")=1,abs korpus1!material,if(optionindex("rabs05")=2,abs korpus2!material,if(optionindex("rabs05")=3,abs korpus3!material,if(optionindex("rabs05")=4,abs korpus4!material,if(optionindex("rabs05")=5,abs dvere1!material,if(optionindex("rabs05")=6,abs dvere2!material,if(optionindex("rabs05")=7,abs dvere3!material,if(optionindex("rabs05")=8,abs dvere4!material,0))))))))'
  s.set_attribute 'dynamic_attributes', '_color05_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_color05_access','NONE'
  s.set_attribute 'dynamic_attributes', '_color05_formlabel','color05'
  s.set_attribute 'dynamic_attributes', '_color05_label','color05'

# ATTR. COLOR1 abs ABS dvere 1.moznost
  s.set_attribute 'dynamic_attributes', 'color1', ''
  s.set_attribute 'dynamic_attributes', '_color1_formula', 'if(optionindex("rabs1")=1,abs korpus1!material,if(optionindex("rabs1")=2,abs korpus2!material,if(optionindex("rabs1")=3,abs korpus3!material,if(optionindex("rabs1")=4,abs korpus4!material,if(optionindex("rabs1")=5,abs dvere1!material,if(optionindex("rabs1")=6,abs dvere2!material,if(optionindex("rabs1")=7,abs dvere3!material,if(optionindex("rabs1")=8,abs dvere4!material,0))))))))'
  s.set_attribute 'dynamic_attributes', '_color1_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_color1_access','NONE'
  s.set_attribute 'dynamic_attributes', '_color1_formlabel','color1'
  s.set_attribute 'dynamic_attributes', '_color1_label','color1'

# ATTR. COLOR2 abs ABS dvere 2.moznost
  s.set_attribute 'dynamic_attributes', 'color2', ''
  s.set_attribute 'dynamic_attributes', '_color2_formula', 'if(optionindex("rabs2")=1,abs korpus1!material,if(optionindex("rabs2")=2,abs korpus2!material,if(optionindex("rabs2")=3,abs korpus3!material,if(optionindex("rabs2")=4,abs korpus4!material,if(optionindex("rabs2")=5,abs dvere1!material,if(optionindex("rabs2")=6,abs dvere2!material,if(optionindex("rabs2")=7,abs dvere3!material,if(optionindex("rabs2")=8,abs dvere4!material,0))))))))'
  s.set_attribute 'dynamic_attributes', '_color2_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_color2_access','NONE'
  s.set_attribute 'dynamic_attributes', '_color2_formlabel','color2'
  s.set_attribute 'dynamic_attributes', '_color2_label','color2'

# ATTR. COLOR3 farba nezadanej abs
  s.set_attribute 'dynamic_attributes', 'color3', ''
  s.set_attribute 'dynamic_attributes', '_color3_formula', '"#f00202"'
  s.set_attribute 'dynamic_attributes', '_color3_units', 'STRING'
  s.set_attribute 'dynamic_attributes', '_color3_access','NONE'
  s.set_attribute 'dynamic_attributes', '_color3_formlabel','color3'
  s.set_attribute 'dynamic_attributes', '_color3_label','color3'

# DELENIE
# oddelenie ABS
  s.set_attribute 'dynamic_attributes', 'ra', '                 ABS        '
  s.set_attribute 'dynamic_attributes', '_ra_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_ra_label',' '

# oddelenie Materialy
  s.set_attribute 'dynamic_attributes', 'rb', '             Materialy            '
  s.set_attribute 'dynamic_attributes', '_rb_access','VIEW'
  s.set_attribute 'dynamic_attributes', '_rb_label',' '
$dc_observers.get_latest_class.redraw_with_undo(s)
end

need to apply it to the definition

change s to e, then s to e.definition

mod = Sketchup.active_model # Open model
sel = mod.selection # Current selection
sel.grep(Sketchup::ComponentInstance).each do |e|
s = e.definition

leaving

s.set_attribute 'dynamic_attributes', 'aameno', ''
# and so on

then

$dc_observers.get_latest_class.redraw_with_undo(e)
end

Thank you @pcmoor ,
I new it had to do with dc definition but did not know how to script it.
Lots to learn still

thank you very much for the recommendations