• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

[solved] a small syntax problem

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 2 Posters 212 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    artmusicstudio
    last edited by artmusicstudio 19 Jun 2014, 20:25

    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

    1 Reply Last reply Reply Quote 0
    • J Offline
      jolran
      last edited by 20 Jun 2014, 09:12

      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..

      1 Reply Last reply Reply Quote 0
      • A Offline
        artmusicstudio
        last edited by 21 Jun 2014, 10:15

        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

        1 Reply Last reply Reply Quote 0
        • J Offline
          jolran
          last edited by 21 Jun 2014, 11:04

          No problem, glad to help if the tip worked. 😄

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement