Transformation method not working in 2018 the same as 2017?
-
Hi all,
In a script I was happily using in 2017 version I have run in a problem.
I have selected a group composed of several copies of the same component; I explode it to retrieve the single instances with something like:
exp=sel[0].explode
Than I would like to sort it by the x value of the instance origin like this:
sort=exp.sort_by {|x| x.transformation.origin.x}This was working smoothly in 2017 version but now it gives me this error:
Error: #<NoMethodError: undefined method `transformation' for #Sketchup::AttributeDictionaries:0x0002d167da50f8It seems that if i manually pick an element of exp array like exp[0], I can get the transformation origin no problem.
Does anybody have a solution or advice on this?
Thanks for your time and best regards
-
It's not the transformation it's the explode returning objects which don't have a transformation !
So when you explode the container the reference 'exp
' can contain nested containers [groups/instances/images], raw geometry [i.e. faces/edges], AND things like curves, vertices, loops, edge-use and attribute-dictionaries.
Since you only want to get the transformation of some limited elements in 'exp
' you can eithergrep
it to get say just instances or groups, or filter the value x by its 'kind[s]' and then pass those to the 'sort' stage.
Also look atx.respond_to?(:transformation)
which istrue
if the element has an accessible transformation... -
Thank you so much TIG!
Adding a simple grep for instances solved it.
Best regards and sorry for the newbyness.
Advertisement