sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Error in code

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 507 Views 4 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.
    • H Offline
      hlogoma
      last edited by

      Hi,
      I was trying out the beginning ruby 1 exercise and I got this eval for line 11 which reads:

      11:in 'is_a?': wrong number of arguments(0 for 1)

      following is the code I copied to ruby console:

      ` model = Sketchup.active_model
      entities = model.active_entities
      selection = model.selection

      edges = []
      faces = []
      comps = []
      groups = []

      entities.each do |e|
      edges.push e if e.is_a? == "Edge"
      faces.push e if e.is_a? == "Face"
      comps.push e if e.is_a? == "ComponentInstance"
      groups.push e if e.is_a? == "Group"
      end

      puts "Total Edges : " + edges.length.to_s
      puts "Total Faces : " + faces.length.to_s
      puts "Total Components : " + comps.length.to_s
      puts "Total Groups : " + groups.length.to_s
      puts "Total Entities : " + entities.length.to_s`

      The model is a sphere called beginning ruby.

      My question is "where is the error in the code?"

      Thanks.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        .is_a? is a method, so you use it like this .is_a?(Sketchup::Edge)

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • honoluludesktopH Offline
          honoluludesktop
          last edited by

          I went here for methods, but couldn't find ".is_a", should I look elsewhere?

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            .is_a? is a Ruby method - not a Sketchup method. http://ruby-doc.org/core/classes/Object.html#M000373

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              @honoluludesktop said:

              I went here for methods, but couldn't find ".is_a", should I look elsewhere?

              This is the more recent online API documentation:
              http://code.google.com/apis/sketchup/docs/index.html

              Hi

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                OK Thomas, Jim, thanks. Hmm... This will take more effort to learn then I thought:-) I won't even ask for a guess as to how long.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  Get comfortable with Ruby, then apply that to the API documentation. Read other people's code, and most importantly - try things yourself, and ask questions when they don't work.

                  Hi

                  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