sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [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.
    • artmusicstudioA Offline
      artmusicstudio
      last edited by artmusicstudio

      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
      • jolranJ Offline
        jolran
        last edited by

        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
        • artmusicstudioA Offline
          artmusicstudio
          last edited by

          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
          • jolranJ Offline
            jolran
            last edited by

            No problem, glad to help if the tip worked. πŸ˜„

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

            Advertisement