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

    [Plugin] Export Batch DAE

    Scheduled Pinned Locked Moved Plugins
    29 Posts 7 Posters 44.8k Views 7 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      Of course... with the right code... 😒

      TIG

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

        @rasmusl said:

        Dear TIG

        Sorry, I am completely new to this and I am looking for a batch conversion of 3ds to dae.
        I see that you have already the batch export from skp to dae and I guess that the below code would do the trick. However I am completly incapable of joining the information into something that works. May I kindly ask you to do this? I will be super grateful if you will help me.

        Is it possible to modify this script to batch import 3ds files instead of skp and export to dae? (and how?)

        Reason for asking is that I have more than 1000 3ds files that I need in 3rd party software and I need to have the sketchup version of dae.

        I posted some example code that does [could do] exactly this... it's in another post from earlier today... do a Search...

        TIG

        1 Reply Last reply Reply Quote 0
        • R Offline
          RasmusL
          last edited by

          Dear TIG

          Sorry, I am completely new to this and I am looking for a batch conversion of 3ds to dae.
          I see that you have already the batch export from skp to dae and I guess that the above code would do the trick. However I am completly incapable of joining the information into something that works. May I kindly ask you to do this? I will be super grateful if you will help me.

          Is it possible to modify this script to batch import 3ds files instead of skp and export to dae? (and how?)

          Reason for asking is that I have more than 1000 3ds files that I need in 3rd party software and I need to have the sketchup version of dae.

          1 Reply Last reply Reply Quote 0
          • R Offline
            RasmusL
            last edited by

            I think it is in this topic, from 4:32 today?

            I tried it, but how do I get it to loop through all the 3ds files like a batch.

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

              @rasmusl said:

              I think it is in this topic, from 4:32 today?

              I tried it, but how do I get it to loop through all the 3ds files like a batch.

              Get the user to choose one 3DS file in the folder.
              Currently the code uses the returned file path.
              BUT let's say we have the returned
              filepath=UI.openpanel(...)
              From that you can find
              folder=File.dirname(filepath)
              [There's currently no API UI.getfolder() method... 😞 ]
              From the folder you can find all of the 3DS files...
              There are several ways, e.g...
              files=[] Dir.entries(folder).each{|f|files << File.join(folder,f) if File.extname(f).downcase==".3ds"}
              Now we have an array of all 3ds files in that folder...
              Each array element is a full path...
              Use a 'batch' process like this...
              ` files.each{|file|

              ALL OF THE CODE TO IMPORT/EXPORT '3ds file' GOES HERE...

              }`
              Unless you want to pay to have a properly written script I'll leave it there... 😒
              Hint: to process files in subfolders do something similar to the above but this time make a list of all folders in the 'selected' folder, then iterate through the contents of each of those in turn, adding any 3ds files to the array for the ultimate batch processing 😉

              Please be wary - I have typed this from memory, so it's untested... 😲

              TIG

              1 Reply Last reply Reply Quote 0
              • G Offline
                glro
                last edited by

                @tig said:

                Of course... with the right code... 😒

                OK... i'll keep working on it then.

                My question is linked to ae snapshot plugin, when it is used to collect informations about all skp files on the hard drive, create a thumbnail and a file shortcut in a specified folder.

                I adapted Jim FOLTZ's code to open each skp file in a folder, zoom out and save, so when it is saved, aesnapshot creates automatically the thumbnail and the file shortcut

                
                model = Sketchup.active_model # Open model
                entities = model.entities # All entities in model
                selection = model.selection # Current selection
                
                
                #choose a file
                skppath = UI.openpanel "choose a file","*.skp"
                skppath = File.dirname(skppath)
                skppath = skppath.tr("\\","/")
                skppath = skppath + "/"
                	  
                #skppath ="C;/recap_skp/"
                #open dir and loop all skps
                dir = Dir.open(skppath)
                begin
                  dir.each {|x|
                       next if x !~ /\.skp$/i
                       x = "#{x}"
                       sourcefile = skppath+x
                       x = x[0,x.length-4]
                
                #prompt between files
                        prompt2 = UI.messagebox("registering #{sourcefile} ?",MB_OKCANCEL) 
                			if prompt2 ==2
                			fail
                			end
                 
                              #open model file                 
                       Sketchup.file_new
                         status = Sketchup.open_file sourcefile
                
                      #zoom out
                
                      view = Sketchup.active_model.active_view
                       new_view = view.zoom_extents
                      #save
                      status = model.save sourcefile 
                   
                    }
                      
                ensure
                  dir.close
                end
                
                    UI.messagebox "Finished"
                	
                
                

                I am not sure about the necessity of the prompt between the files register

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

                  I expect that the prompt is a device to get the view zoomed before doing the export, otherwise you might find it's exported before the zoom is finished ?

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • G Offline
                    glro
                    last edited by

                    @tig said:

                    I expect that the prompt is a device to get the view zoomed before doing the export, otherwise you might find it's exported before the zoom is finished ?

                    yes

                    maybe a timer would be enough, so it would not be necessary to wait and click for each file

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

                      model.options["PageOptions"]["ShowTransition"] = false
                      might help...
                      OR this entire thing as an example ?

                      <span class="syntaxdefault">def scenes2images</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault">  model</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />  view</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_view<br />  width</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vpwidth</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_int<br />  height</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vpheight</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_int<br /></span><span class="syntaxcomment">### you can change the width/height away from the default if you desire<br /></span><span class="syntaxdefault">  pages</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">pages<br />  pages_times</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxdefault">  pages</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">page</span><span class="syntaxkeyword">|</span><span class="syntaxdefault">pages_times</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">([</span><span class="syntaxdefault">page</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">page</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transition_time</span><span class="syntaxkeyword">])<br /></span><span class="syntaxdefault">    page</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transition_time</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">0.0 </span><span class="syntaxkeyword">}<br /></span><span class="syntaxcomment">### remembers pages' transition times and sets them all to 0<br /></span><span class="syntaxdefault">  filepath</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)+</span><span class="syntaxstring">"\\"<br /></span><span class="syntaxdefault">  0</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">upto</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">pages</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">count</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)do|</span><span class="syntaxdefault">images</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">    </span><span class="syntaxcomment">### this msgbox pauses and lets each view refresh and the image process...<br /></span><span class="syntaxdefault">    UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Exporting Image of Scene..."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">write_image</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{filepath+pages.selected_page.name}.jpg"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">width</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">height</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">send_action</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"pageNext;"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  end</span><span class="syntaxcomment">#loop<br />### reset pages' transition times<br /></span><span class="syntaxdefault">  pages_times</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|array|array[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">transition_time</span><span class="syntaxkeyword">=array[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]}<br /></span><span class="syntaxdefault">  UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Scenes' Image Exporting - Completed."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#def<br />&nbsp;</span><span class="syntaxdefault"></span>
                      

                      TIG

                      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