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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Error: undefined method '+' for nil:NilClass

    Scheduled Pinned Locked Moved SketchyPhysics
    3 Posts 2 Posters 3.2k 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.
    • K Offline
      klaufi
      last edited by

      Hi there

      I got a new notebook and now SU8 is finally working. I wanted to script something in Sp3, but it didn't work right. There was an error message, which told me "undefined method 'atan2' for nil:NilClass". So I made a simple testing program and even that didn't work. Here's the code:

      if frame==0
         $a=1
         $b=2
      end
      
      $c=$a+$b
      
      puts "1+2=#{$c}"
      

      it should just handle some variables and send the result to the ruby-console, but by hitting play I always got this error message:
      "undefined method '+' for nil:NilClass"
      Even if I used local variables, it didn't change anything. By using getVar and setVar it worked, but the result was always 0.00
      What's going wrong?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Don't use $ global variables.
        There is rarely a reason that can't be side stepped - use a, b and c.
        If frame is not 0 then a or b are not set to anything, so the error is correct because nil + nil doesn't work !

        TIG

        1 Reply Last reply Reply Quote 0
        • K Offline
          klaufi
          last edited by

          Ok, now this works.
          Now I have another problem: I can't read out the frame in the scripted box.
          if i do so, an error message appears.
          When I write something like

          Math.sin(frame/100.00)
          

          in the controller of a servo, it works, but if I write

          setVar("a",frame/100.00)
          

          and into the controller

          getVar("a")
          

          the error message occurs.
          That's really odd...

          edit: It seems, that my old SP models work well, but if I copy the code into a new Scripted-box ob an object, it doesn't work anymore. Maybe I should get an older Version of SP?

          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