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!
    🚨 Skimp | 25% Off until March 30 Buy Now

    The case of the missing data

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 326 Views 3 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      Not sure if anyone can find my error just in the code snippet below. The first set of puts ID's the start, and dumps the data. The second set of puts, shows the results, and the missing "0.0". I have traced the data and it is OK up to here:
      @block_z = @insert_names[0] @insert_names = @insert_names - [@insert_names[0]]
      In that step, "0.0" vanishes. Any ideas?

      The portion of my code:
      if @line == @insert_names[0
      puts "start"
      puts @insert_names
      @block_name = @insert_names[0]
      @insert_names = @insert_names - [@insert_names[0]]
      @block_x = @insert_names[0]
      @insert_names = @insert_names - [@insert_names[0]]
      @block_y = @insert_names[0]
      @insert_names = @insert_names - [@insert_names[0]]
      @block_z = @insert_names[0]
      @insert_names = @insert_names - [@insert_names[0]]
      puts "end"
      puts @insert_names
      end]
      and the results of the puts:
      %(#0000FF)[start
      GROUP_1
      -4.944653
      -6.740773
      0.0
      GROUP_2
      8.629024
      -6.771204
      0.0
      end
      GROUP_1
      -4.944653
      -6.740773
      0.0
      start
      GROUP_2
      8.629024
      -6.771204
      end
      GROUP_2
      8.629024
      -6.771204
      nil]

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

        not sure about the data - but is this line removing the first item of the array?

        @honoluludesktop said:

        @insert_names = @insert_names - [@insert_names[0]]

        you can do that with:
        @insert_names.shift

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

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

          You are really tangling things by reducing the contents of @insert_names as you go along - it becomes hard to keep track...
          Because you know the order, then why no extract the data 4 items at a time?

          
          blocks=[] ### or whatever you want to call this array of 'blocks'...
          inserts=[]+@insert_names ### == a 'copy'
          while inserts[0]
            block=[]
            block[0]=inserts[0]
            block[1]=inserts[1]
            block[2]=inserts[2]
            block[3]=inserts[3]
            blocks << block
            inserts=inserts[4..-1]
            ### strip out first block recursively...
          end#while
          ### now 'blocks' contains arrays for each block followed by its x/y/z
          ### e.g. [[GROUP_1, -4.944653, -6.740773, 0.0],[GROUP_2, 8.629024, -6.771204, 0.0]...]
          ### '@insert_names' is unchanged.
          
          

          πŸ€“

          TIG

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

            Thanks fellows, let me give those a try:-)

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

              Thanks, they both work:-) Ended up fixing my app in a couple of places. Wounder how I mucked the data:-(

              1 Reply Last reply Reply Quote 0

              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 Login
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement