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:0x0002d167da50f8>
It 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
Transformation method not working in 2018 the same as 2017?
3 posts
• Page 1 of 1
Re: Transformation method not working in 2018 the same as 20It'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 either grep 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 at x.respond_to?(:transformation) which is true if the element has an accessible transformation... TIG
Re: Transformation method not working in 2018 the same as 20Thank you so much TIG!
Adding a simple grep for instances solved it. Best regards and sorry for the newbyness.
3 posts
• Page 1 of 1
|