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

    Text , X , Y , Z import

    Scheduled Pinned Locked Moved Plugins
    23 Posts 4 Posters 1.4k 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.
    • K Offline
      khallgren
      last edited by

      Hi , Thanks for the Text and Leader tip

      If I want to import Y, X ,Z rather than X,Y,Z

      Can I just switch around the
      x=data[1].to_f.mm
      y=data[2].to_f.mm
      z=data[3].to_f.mm
      pt=[x,y,z]

      To
      y=data[1].to_f.mm
      x=data[2].to_f.mm
      z=data[3].to_f.mm
      pt=[y,x,z]

      Best Regards
      Kristoffer

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

        Yes.
        The data[] order is the order typed in each line in the .dat file.
        The original code assumed the first was the 'text', then x, y and z values, as in the .dat file supplied.
        You can have the .dat file's entries in any order as long as the code's data[] values are adjusted accordingly - for example if the format were x,y,z,text then the values would all change around to suit with txt=data[3], and then x=data[0], y=data[1] and z=data[2]...
        The code I gave you was only a basis for .dat file reading - it's very flexible...

        PS: DON'T swap the point's values around use pt[x,y,z] always, no matter what the order they were read from the file ! 😒

        TIG

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

          Hi again
          When I try to import a file Negative Co-ordinates I cet an error
          Is this an easy fix ?

          See the example file

          Best Regards
          Kristoffer


          Example_negative.txt

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

            What's the error ? Please post examples...
            The code x.to_f.mm should take the text 'string' of 'x' and make it into a 'number' [+/-] and then tell SUp it's in 'mm', not the default 'inches'?

            TIG

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

              @khallgren said:

              When I try to import a file Negative Co-ordinates I cet an error

              Exactly what does the error say?

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

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

                Hi , I tried to make my own file for testing and the negative co-ordinates workes fine, so the problem is not the negative co-ordinates. But when I export a file from my calculation program and try it import it I get an error, but the files sceems identical to me?

                Here is the error i get

                and the file is attached below

                Error: #<Errno::ENOENT: C:/Programfiler/Google/Google SketchUp 7/Plugins/cptstxt.rb:14:in `readlines': No such file or directory - C:\Documents and Settings\krh\Skrivebord\BeregnetHøyderfile8.txt>
                C:/Programfiler/Google/Google SketchUp 7/Plugins/cptstxt.rb:14

                Best Regards
                KRistoffer


                BeregnetHøyderfile8.txt

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

                  I think I know what the problem is . Its the dicimales.... Its fine importing a file that says:

                  example: text,200.0,200.0,200.0

                  But when the file has a desimale value thats larger than 0 i get an error

                  example: text,200.5,200.5,200.5

                  Best regards
                  Kristoffer

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

                    Ah!
                    I know why that is - because you are Norwegian! Sketchup's ruby doesn't read files that has characters which isn't ASCII (A-Z). So our beloved æøå makes SU's file functions go belly up.

                    I struggled for ages with this some time ago. Found no good solution for that. You can work around be renaming your file.

                    Hilsen fra Bartehovedstaden! 😉

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

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

                      @khallgren said:

                      I think I know what the problem is . Its the dicimales.... Its fine importing a file that says:

                      example: text,200.0,200.0,200.0

                      But when the file has a desimale value thats larger than 0 i get an error

                      example: text,200.5,200.5,200.5

                      Best regards
                      Kristoffer

                      ?? With the same file you tried earlier? Or did you create a new test file with just ASCII chars in the file name & path?

                      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

                        As Thomthom said -
                        It's an 'unrelated' error to the code itself... you have 'special characters' in the filepath - this always causes Ruby / Sketchup problems [it can be trapped form but it's a bit complex for this simple example code!].
                        So please do it without the 'ø' etc in filename 'BeregnetHøyderfile8.txt' >>> 'BeregnetHoyderfile8.txt' ? it should then work !
                        😒

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • Didier BurD Offline
                          Didier Bur
                          last edited by

                          Hi,
                          @Khallgren: I'm just about to modify my points cloud script to achieve what you want. Stay tuned....

                          DB

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

                            Hi , Oppps I missed that issue 😄
                            Diddler Bur: It would be great if your point cloud importer had a "text" option
                            Thanks for all your help 😄

                            Berst regards "fra regn byen"
                            Kristoffer

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

                            Advertisement