Why can not I get the value of the lenx, leny and lenz dynamic attributes in ruby?
I’m trying to get the value of _lenx_formula, _leny_formula and _lenz_formula and it does not work, however with the attributes _x_formula, _y_formula, _z_formula, _rotx_formula, _roty_formula, and _rotz_formula works.
Why does this happen, what do I need to do?
My intention is to list some main attributes, put in a substitute component and then delete the resident component.
Here’s a template to make it easier.
Teste.skp (2.9 MB)
This is the code
model = Sketchup.active_model
sel = model.selection
model.start_operation("X")
#Método buscar componentes com modelocategoria e trocar
def get_dc_instances_replace(ents)
ents.grep(Sketchup::ComponentInstance).each do |e|
attribut = e.get_attribute 'dynamic_attributes','modelocategoria'
unless attribut.nil?
if attribut.include?("portas")
x = e.get_attribute 'dynamic_attributes', '_x_formula', ''.to_f
y = e.get_attribute 'dynamic_attributes', '_y_formula', ''.to_f
z = e.get_attribute 'dynamic_attributes', '_z_formula', ''.to_f
lenx = e.get_attribute 'dynamic_attributes', '_lenx_formula', ''.to_f
leny = e.get_attribute 'dynamic_attributes', '_leny_formula', ''.to_f
lenz = e.get_attribute 'dynamic_attributes', '_lenz_formula', ''.to_f
rotx = e.get_attribute 'dynamic_attributes', '_rotx_formula', ''.to_f
roty = e.get_attribute 'dynamic_attributes', '_roty_formula', ''.to_f
rotz = e.get_attribute 'dynamic_attributes', '_rotz_formula', ''.to_f
modcat = e.get_attribute 'dynamic_attributes', 'modelocategoria', ''.to_s
puts [x,y,z,lenx,leny,lenz,rotx,roty,rotz,modcat]
end
end
get_dc_instances_replace(e.definition.entities)
end
end
get_dc_instances_replace(sel)
model.commit_operation
#