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

    MAXWELL plugin Authors?

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 5 Posters 1.0k Views 5 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.
    • AdamBA Offline
      AdamB
      last edited by

      JD, I think you've got to bite the bullet and use the COM interface to get the ISkpMaterial, then extract a ISkpTexture on which you can call WriteToFile().

      On a related note, anyone else experience that TextureWriter is stupidly slow for large images? ie a model has a 2000x1000 bmp texture and Texturewriter can take minutes to write it out.

      Developer of LightUp Click for website

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

        I just tried with a small experiment - related to another thread: posted there:
        http://forums.sketchucation.com/viewtopic.php?f=180&t=31595&p=279046#p279046

        
        tw = Sketchup.create_texture_writer
        model = Sketchup.active_model
        
        model.start_operation('Write Textures', true)
        
        tmp = model.definitions.add('Temp_TextureWriter')
        g = tmp.entities.add_group
        model.materials.to_a.each_with_index { |m,i|
          next if m.texture.nil?
          g.material = m
          tw.load( g )
          p tw.write( g, "c;/temp/mat_#{i}.png" )
        }
        
        model.abort_operation
        
        

        This writes out the textured material in the model without adding to the undo stack and without touching the model's entities - meaning it also doesn't interfere with the Outliner when creating the temp entities.

        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

          @adamb said:

          JD, I think you've got to bite the bullet and use the COM interface to get the ISkpMaterial, then extract a ISkpTexture on which you can call WriteToFile().

          Via C or C++?
          Or calling the SU COM via ruby API? (Is that possible?)

          @adamb said:

          On a related note, anyone else experience that TextureWriter is stupidly slow for large images? ie a model has a 2000x1000 bmp texture and Texturewriter can take minutes to write it out.

          Haven't really timed things - but have some times thought that writing images took longer than necessary.

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

          1 Reply Last reply Reply Quote 0
          • AdamBA Offline
            AdamB
            last edited by

            It has to use C/C++ to talk to the abortion that is COM

            Did a quick test on a Mac and it works fine and doesn't add any Undo transactions. 😍

            require "Texwriter.bundle"
            a_material.dumptexture("/dodah.jpg")


            Texwriter.bundle.zip

            Developer of LightUp Click for website

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

              Was it via the COM interface you managed to get the layer material?

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

              1 Reply Last reply Reply Quote 0
              • AdamBA Offline
                AdamB
                last edited by

                @thomthom said:

                Was it via the COM interface you managed to get the layer material?

                Yep. BTW You can get the Layer color etc but there doesn't exist an actual Material..

                And here's a Windows build of it. Same method name etc


                Texwriter.so.zip

                Developer of LightUp Click for website

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

                  @adamb said:

                  It has to use C/C++ to talk to the abortion that is COM

                  I thought COM was a Windows thing...

                  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

                    Adam - any chance you could post the source for these Ruby Extensions - as simple examples of interacting with the SketchUp COM interface?

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

                    1 Reply Last reply Reply Quote 0
                    • JD HillJ Offline
                      JD Hill
                      last edited by

                      @adamb said:

                      JD, I think you've got to bite the bullet and use the COM interface to get the ISkpMaterial, then extract a ISkpTexture on which you can call WriteToFile().

                      On a related note, anyone else experience that TextureWriter is stupidly slow for large images? ie a model has a 2000x1000 bmp texture and Texturewriter can take minutes to write it out.

                      Ugh. I'd rather not do that. And yes, my recollection is that WriteToFile seemed to be quite slow. But I don't use it; if WriteAllTextures fails, I fall back to using WriteTextureFileFromHandle. Can't say that I specifically compared the performance of that with WriteToFile though.

                      @thomthom said:

                      I thought COM was a Windows thing...

                      Not really, COM is just the definition of a set of contracts which are designed to allow unrelated components to connect to and obtain services from one another; roughly speaking, is_a? and respond_to? for C++.

                      And thanks for the idea of using a Definition; that's perfect.

                      Developer - Bella Render

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

                        @jd hill said:

                        And thanks for the idea of using a Definition; that's perfect.

                        Mind you - if you don't use abort_operation you'll end up making lots of temp definitions cluttering up the In Model definition list.

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

                        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