sketchucation logo sketchucation
    • 登入
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] ImageTrimmer

    已排程 已置頂 已鎖定 已移動 Plugins
    364 貼文 58 Posters 228.2k 瀏覽 58 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • TIGT 離線
      TIG Moderator
      最後由 編輯

      CADfather

      I have looked at your '.jar' issue... I can reproduce it! IF I let a 'zip/unzip' application like AlZip or WinRar 'poach' the '.jar' file-type as one that it will open. If so then when Ruby tries to 'open' a '.jar' file instead of it 'executing' in Java [like it should], it 'opens' in the decompression application...

      The solution = look at your WinRar settings and ensure '.jar' is NOT one of its file-types for opening...

      TIG

      1 條回覆 最後回覆 回覆 引用 0
      • CadFatherC 離線
        CadFather
        最後由 編輯

        thanks TIG, that's exactly what i did - (perhaps wasn't too clear in the edit)

        one specu-question: could you, adjust the sampling rate/area of the script? suppose you didn't want so much precision, it could perhaps speed up the trimming process - having said that, the simplifier is well integrated
        once the trim is achieved

        1 條回覆 最後回覆 回覆 引用 0
        • TIGT 離線
          TIG Moderator
          最後由 編輯

          @cadfather said:

          thanks TIG, that's exactly what i did - (perhaps wasn't too clear in the edit)

          one specu-question: could you, adjust the sampling rate/area of the script? suppose you didn't want so much precision, it could perhaps speed up the trimming process - having said that, the simplifier is well integrated
          once the trim is achieved

          Sorry - didn't see the 'edit' ! 😒
          It first has to 'get' all of the edges of the solid/transparent areas - it's 'easier' to draw all of the edges as boundaries to these pixels - this is the most complex outline - a Factor 2 simplification will often improve the steppiness of these edges, BUT it can trim small solid areas or leave small transparent areas... Most of the time in the initial processing is finding which edge bits get faces or 'holes' and of course therefore which are part of which 'loops'... The 'simplifier' works on the face perimeter loops once they are made - it's much easier than trying to decide which edges could be the loops initially... You will have seen that the simplifier at Factor 2 reprocesses the faces' loops quite quickly... I can see how to easily recast the code to allow simplification before processing 😕

          TIG

          1 條回覆 最後回覆 回覆 引用 0
          • CadFatherC 離線
            CadFather
            最後由 編輯

            i see.. still a pretty amazing feat.. in fact so are the images produced in the folder.. Thanks again

            1 條回覆 最後回覆 回覆 引用 0
            • TIGT 離線
              TIG Moderator
              最後由 編輯

              @cadfather said:

              i see.. still a pretty amazing feat.. in fact so are the images produced in the folder.. Thanks again

              The Image's original 'image' file, 'edged' .png and a .dat file [01s] are put into the temporary folder [it is removed IF it's empty] made inside the SKP model's folder. If you answer 'No' when asked if you want to remove temporary files you can open/use them. I didn't automate this deletion because you might want the Image's 'image' file and/or the 'edged' .png. The .dat file does go but it's just a load of 0s and 1s !!! If you leave one of the dialogs open you can always read/copy it before it 'goes' 😉

              TIG

              1 條回覆 最後回覆 回覆 引用 0
              • CadFatherC 離線
                CadFather
                最後由 編輯

                very useful indeed.. 😄

                1 條回覆 最後回覆 回覆 引用 0
                • soloS 離線
                  solo
                  最後由 編輯

                  What am I doing wrong? I have a .png. I made it a component, selected it and then clicked on Image trimmer and get a warning 'Image trimmer: You selected an Image first.', so I exploded and tried again with same warning, I tried simplyfier and it works, but trimming does not, what am I doing wrong?

                  http://www.solos-art.com

                  If you see a toilet in your dreams do not use it.

                  1 條回覆 最後回覆 回覆 引用 0
                  • TIGT 離線
                    TIG Moderator
                    最後由 編輯

                    @solo said:

                    What am I doing wrong? I have a .png. I made it a component, selected it and then clicked on Image trimmer and get a warning 'Image trimmer: You selected an Image first.', so I exploded and tried again with same warning, I tried simplyfier and it works, but trimming does not, what am I doing wrong?

                    You don't use 'ImageTrimmer' on a 'Component' - you use it on a plain imported [unexploded] 'Image' - check in Entity Info to see what it is...
                    After it's 'trimmed' that Image is copied as a Material applied to Faces inside a new Component...
                    so then you can no longer 'trim' it, but of course you can 'simplify' the outlines later within the Component... 😕

                    TIG

                    1 條回覆 最後回覆 回覆 引用 0
                    • Dave RD 離線
                      Dave R
                      最後由 編輯

                      Oxer, you might try importing the image as an image and then immediately running the plugin on it. See if that does what you want.

                      Etaoin Shrdlu

                      %

                      (THERE'S NO PLACE LIKE)

                      G28 X0.0 Y0.0 Z0.0

                      M30

                      %

                      1 條回覆 最後回覆 回覆 引用 0
                      • OxerO 離線
                        Oxer
                        最後由 編輯

                        Hello TIG!

                        I don't know how use the plugin, i do this:

                        1. I import a png file like image.
                        2. I make a new component, its name the same like image.
                        3. I make a new material with the png file with the same name, and i apply this material to the face inside the component.
                        4. I select the image into SU and run the plugin.
                          Nothing happens, only the plugin creates a folder named "TrimmedImages" in the same directory that Model file, it contains the png file.
                          What i do bad?

                        I use Mac with OSX 10.6 and SU 8.

                        EDIT: Appears this message in Console Ruby
                        Console Error

                        "The result is the end what is important is the process" by Oxer
                        [http://www.oxervision.blogspot.com/(http://www.oxervision.blogspot.com/)]

                        1 條回覆 最後回覆 回覆 引用 0
                        • OxerO 離線
                          Oxer
                          最後由 編輯

                          @dave r said:

                          Oxer, you might try importing the image as an image and then immediately running the plugin on it. See if that does what you want.

                          I have done so too, but appears a message error in Ruby Console.

                          "The result is the end what is important is the process" by Oxer
                          [http://www.oxervision.blogspot.com/(http://www.oxervision.blogspot.com/)]

                          1 條回覆 最後回覆 回覆 引用 0
                          • TIGT 離線
                            TIG Moderator
                            最後由 編輯

                            @oxer said:

                            Hello TIG!

                            I don't know how use the plugin, i do this:

                            1. I import a png file like image.
                            2. I make a new component, its name the same like image.
                            3. I make a new material with the png file with the same name, and i apply this material to the face inside the component.
                            4. I select the image into SU and run the plugin.
                              Nothing happens, only the plugin creates a folder named "TrimmedImages" in the same directory that Model file, it contains the png file.
                              What i do bad?

                            I use Mac with OSX 10.6 and SU 8.

                            EDIT: Appears this message in Console Ruby
                            [attachment=0:2kel5wb4]<!-- ia0 -->Consola.jpg<!-- ia0 -->[/attachment:2kel5wb4]

                            NO!

                            1. Import the Image. [no need to make other things yourself]
                            2. Place/Scale it like you want.
                            3. Select the Image.
                            4. Run 'ImageTrimmer' [the clue is in its name!]
                            5. It makes a new Component Instance that has trimmed Faces matching the Image's transparent areas with the Image now applied as a new Material.
                            6. You then choose to stand-up the new component, delete temporary files or 'simplify' the outlines.
                            7. Later, you can Select the new Component Instance and use the 'simplify' tool on its outlines...

                            Please run it with the Ruby Console open - there might be a MAC error.
                            Check that .jar files are 'executable' Java files on your OS and not inadvertently set to open with your 'Zip/UnZip' application...
                            😕

                            From the Ruby messages it seems that the 'EdgeDetector.jar' file isn't in the correct directory ?? There should be one file called 'SKMtools.rb' in the 'Plugins' folder and then a sub-folder in the 'Plugins' folder called 'SKMtools' that contains various .rb and .jar files etc. Your error message is saying it can't find the specified .jar file. Is it there? If so does the file path contain accented characters etc [unlikely] - that can cause Ruby's File operations to fail!

                            TIG

                            1 條回覆 最後回覆 回覆 引用 0
                            • TIGT 離線
                              TIG Moderator
                              最後由 編輯

                              Oxer

                              PS: are you sure you have your files/folders in the correct 'Plugins' ? Type/Copy+Paste this into the Ruby Console to check the correct path to your Plugins folder... Sketchup.find_support_file("Plugins")

                              TIG

                              1 條回覆 最後回覆 回覆 引用 0
                              • OxerO 離線
                                Oxer
                                最後由 編輯

                                @tig said:

                                Oxer

                                PS: are you sure you have your files/folders in the correct 'Plugins' ? Type/Copy+Paste this into the Ruby Console to check the correct path to your Plugins folder... Sketchup.find_support_file("Plugins")

                                Yes, i have all file into Plugins folder
                                Plugins folder

                                "The result is the end what is important is the process" by Oxer
                                [http://www.oxervision.blogspot.com/(http://www.oxervision.blogspot.com/)]

                                1 條回覆 最後回覆 回覆 引用 0
                                • TIGT 離線
                                  TIG Moderator
                                  最後由 編輯

                                  Oxer

                                  I apologize - I have double checked my code and there was a stupid typo [for MAC users] that messed it up - two lines were 'transposed'... 😳
                                  Here is the updated file-zip http://forums.sketchucation.com/viewtopic.php?p=293677#p293677
                                  Please retry and report back...

                                  TIG

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • OxerO 離線
                                    Oxer
                                    最後由 編輯

                                    I have downloaded the revision and the error persists.
                                    Ruby Console.jpg

                                    "The result is the end what is important is the process" by Oxer
                                    [http://www.oxervision.blogspot.com/(http://www.oxervision.blogspot.com/)]

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • HumpmetwiceH 離線
                                      Humpmetwice
                                      最後由 編輯

                                      I am getting these messages. The first one just after I click the Image Trimmer but then it says please wait then the second message appears "the edges images and data were not made". I using vista and java is up to date and I'm not sure if win zip or anything else is trying to open the .jar file or not. Not that big of a deal just thought I would post.


                                      2010-12-20_1746.png

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • TIGT 離線
                                        TIG Moderator
                                        最後由 編輯

                                        @unknownuser said:

                                        I am getting these messages. The first one just after I click the Image Trimmer but then it says please wait then the second message appears "the edges images and data were not made". I using vista and java is up to date and I'm not sure if win zip or anything else is trying to open the .jar file or not. Not that big of a deal just thought I would post.

                                        To see if anything is messing with .jar files double-click on ../Plugins/EdgeDetector.jar and see what happens - if it opens with say 'WinRar' then edit that App's options to NOT open jar files... 'Jar' files should 'open' [execute] with Java...
                                        From the message it seems that Java IS trying to execute the jar file.
                                        Do you have appropriate access-rights to read-write-execute files in the ../Plugins/SKMtools folder/sub-folder ?
                                        Can you edit the permissions to that folder to allow you full access.
                                        Can you try this to see if the 'jar' is executable.
                                        Find a simple .png file with some transparent areas and copy it to say ' C:\Temp\my.png'.
                                        Open the ../Plugins/SKMtools folder and make two files called ' from.ini' and ' to.ini' [if they exists use them].
                                        Edit them with 'Notepad' or equivalent plain-text editor, so the 'from.ini' contains one line of text C:\Temp\my.png [no carriage return] and the 'to.ini' contains one line of text C:\Temp\my [no carriage return].
                                        Now double-click on the file in SKMtools called EdgeDetector.jar - you should now find two extra files in 'C:\Temp' folder named C:\Temp\my[Edged].png and C:\Temp\my[Edged].dat.
                                        If you open the Edged .png file you should see it is the outlines of the solid areas black-on-white, the .dat file opened in Notepad should be a lot of 01s gobbledygook...
                                        Please try these ideas and report back... 😕

                                        TIG

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • TIGT 離線
                                          TIG Moderator
                                          最後由 編輯

                                          @oxer said:

                                          I have downloaded the revision and the error persists.
                                          [attachment=0:3hofwgns]<!-- ia0 -->Ruby Console.jpg<!-- ia0 -->[/attachment:3hofwgns]

                                          Oxer can you test the ideas outlined in my last post, regarding access and if the 'jar' will 'execute' - adjust the 'Temp' folder and 'plain-text editor' to the MAC's equivalents... 😒

                                          TIG

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • Dave RD 離線
                                            Dave R
                                            最後由 編輯

                                            Hi TIG,

                                            I have updated to the most recent version of the plugin and tried running it on my PC. I get the following in the Ruby console and it appears the plugin quietly exits.

                                            Error; #<NoMethodError; undefined method `length' for nil;NilClass>
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;241;in `add_edges'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;220;in `make_edges'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;170;in `process_image'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;147;in `initialize'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;618;in `new'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/ImageTrimmer.rb;618
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/image_class.rb;946;in `call'
                                            C;/Program Files/Google/Google SketchUp 8/Plugins/SKMtools/image_class.rb;946
                                            

                                            Etaoin Shrdlu

                                            %

                                            (THERE'S NO PLACE LIKE)

                                            G28 X0.0 Y0.0 Z0.0

                                            M30

                                            %

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 18
                                            • 19
                                            • 2 / 19
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement