[solved] a small syntax problem
-
hello,
when i run this code (with 10 faces and NO GROUPS in the selection)
@selection.each { |@entity| if @entity.is_a?(Sketchup;;Face) puts "face" elsif @entity.is_a?(Sketchup;;Group) puts "group" end }the "face" is printed 10 times and
the "group" is printed 10 timesin the console.what is wrong with my elsif condition?
thanx a lot
stan -
Dont use an instance variable in the iterator

@selection.each { |@entity|
Should be
@selection.each { |entity|
Otherwise I'm totally misinformed.
The values get stored in the instance variables during the session wheras the
entity variable gets executed in the iterators scope only, if that makes sense what I say.. -
hello jorlan,
thanx for the tip.
i corrected it, so the code is clearer (i have to trasport this value to another method, so i assigned an independent variable to ,entity'.)
stan -
No problem, glad to help if the tip worked.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement