Disabling advanced camera tools causing error
-
When disabling "Advanced Camera Tools" both in Sketchup 2015 and in 2016 (maybe further), it causes an undefined method error with scripts that use 'get_attributes' (with the S) on a component definition.
The error:
" Could not load xxx.rb:
undefined method 'get_attributes' for
#Sketchup::ComponentDefinition0x000000.... "I usually disable the 'Advanced Camera Tools' extension (It may cause all sorts of scene problems in some models), but I guess I'll have to live with this one when I want to run a certain script...
- Does this happen to anyone else?
- I can't seem to find 'get_attributes' (with the s) in the Sketchup API, nor in the Ruby Docs... ?
Good Day
Yoni
-
it's a Dynamic Components method...
do you have a model and a code snippet that generates the error...
john
-
You can test it with your DC encrypter decrypter.
-
I'll have a look, it was a test...
ok I can reproduce it with a new model with any DC and this code...
m = Sketchup.active_model m.definitions.each do |d| if defined? d.attribute_dictionaries next unless d.attribute_dictionaries && d.attribute_dictionaries['dynamic_attributes'] if defined? d.get_attributes p d.name d.get_attributes('dynamic_attributes').each do |a| p a end else p d.name.upcase end end end
Run with ACT off and you get the UPCASED definition names, turn ACT on and run again, you get the list...
I only tested on mac, v2017...
it 'looks' like get attributes is defined in ACT...
john
-
it definitely part of ACT...
and is the equivalent of this attribute_dictionaries['dynamic_attributes'].entries.to_h...
proof:
m = Sketchup.active_model m.definitions.each do |d| next unless d.attribute_dictionaries && d.attribute_dictionaries['dynamic_attributes'] p d.name p d.attribute_dictionaries['dynamic_attributes'].entries.to_h == d.get_attributes('dynamic_attributes') end
solution:
do a search and replace in any plugin that uses
get_attributes('dynamic_attributes')
... [untested]john
-
Thanks John!
That definitely clears up a lot of things I couldn't understand.When I was analyzing your decrypter, 'get_attributes' fit in so well it looked like it's part of the API. Maybe it should be?!
-
when I write 'quick and dirty' tests I tend to check for methods using Ruby
:methods
method...that can expose 'undocumented' methods that I have no idea of the owner of...
I must of had ACT on when I first wrote this one [ I don't normally ]...
good thing you found it, I'll find and change my snippet...
john
Advertisement