Convert .skp to .obj together

[quote=“DanRathbun, post:13, topic:10539”]

You can replace

            dir = UI.select_directory(title: "Select folder of SKPs...")
            return unless dir

with:

            dir = UI.openpanel("Select SKP file in folder...","*.skp","SketchUp Files (*.SKP)|*.skp;||")
            return unless dir
            dir = File.dirname(dir)

It works great… Thanks to all of u…

OBJ=read_wobj(‘examples\zidle_2529df1273423fa7a524f6bfc21eae12.obj’);

Reading Object file : examples\zidle_2529df1273423fa7a524f6bfc21eae12.obj
% Alias OBJ Model File
% Exported from SketchUp, © 2000-2012 Trimble Navigation Limited
% File units = centimeters
Reading Material file : examples\idle_2529df1273423fa7a524f6bfc21eae12.mtl

I’m getting error reading obj beacuse the name of mtl file associated with obj is truncates first letter [idle_2529df1273423fa7a524f6bfc21eae12.mtl] while exporting. What shall I do?

Hello, i was looking for the same solution to changing multiple files formats from .skp to .obj, what i have tried but couldnt get it work.

I downloaded this code : TIG-Export.rb
I loaded this code via sketchup ruby console, and when i load it it says “TRUE” and nothing happends
I tried installing it as .rbz extension but when i installed it, nothing appeared in extension menu. So please, can someone explain me step by step how to convert these files? and how to use this code?

Where did you get that rb file from - above ?

A lone RB file goes in your Plugins folder and is loaded as SketchUp starts.
If you manually load it from the Ruby Console it’s available then, even if it’s not in the Plugins folder.
The instructions are usually provided with a script on its download page.
There are lots of instructions and comments above…
This one is undoubtedly an old simple script - not and Extension - perhaps it is run from the Ruby Console ? [like it says]

From what you say it’s not going to do what you want anyway ?
You want a ‘batch’ tool that takes all of the SKPs in a selected folder and makes OBJs…
Here’s an example RB - Pro only - TIG-ExportBatchOBJ.rb (3.1 KB)
It adds an OBJ Batch Exporter to the File menu, so it’s easier to use on a folder…

If possible, convert all "\" backslashes in pathstrings to "/" forward slashes. (The backslashes and the following characters are read as escape sequences. So it is seeing "\z" as an escape sequence.)

newpath = oldpath.tr("\\",'/')

TIG-Export.rb (829 Bytes)

Keep the name as it is. It is the same provided by TIG sir.

Where does this statement come from ? It uses a ‘’ instead of a ‘/’.

works as a charm, but one more question, is it possible to change code so that before exporting model will be placed on 0,0,0 axies?

I installed TIG-Export.rb ok.
When I run it though, it just does two files and then sends an error report (“bug splat”).
I’m running Sketchup 2016.
Any ideas how to get it working? Or an alternative solution?
Cheers.

open Window >> Ruby Console and try again…

copy paste any error messages into a code block by using backticks

 ```ruby
   paste error here
john

I have exactly the same error, but the program crashes before I can see any error message. Is there some log file that is written to? I sent a crash report (Crash Report #16543).

I also added the line “Sketchup.active_model.close” to the script inside the loop after the export. It was just opening multiple windows otherwise, and I thought that might have been the source of the crashing. But unfortunately, it wasn’t. It actually only gets through about 4 files before crashing, so the number of windows opened never became a problem I guess.

on a mac running batches from ruby can be tricky…

I hadn’t spoted that @Leo is also on a mac…

If you happy coding, you could try an experiment based on something I recently discovered with a plugin I’m developing…

I can private message you a snippet if you want…

john

That sounds good. I am happy coding, although I admit I don’t really know Ruby, but I’m a reasonably experienced Python programmer, so I can probably figure out how to make it work. Please send me the snippet you are talking about. I might be able to try what I’m doing on a Windows VM, too, unless the graphics is an issue doing that.

Thanks!

There is a crash log written. On a Mac you can view it under the User Diagnostic Reports using the Console app. However, it is not likely to be much use to you unless you are expert at UNIX crash reports!

Not especially, but here is what looks like the most important bits.

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000251000007ff

VM Regions Near 0x251000007ff:
    MALLOC_LARGE           000000016f763000-000000016f793000 [  192K] rw-/rwx SM=PRV  
--> 
    __TEXT                 0000123440000000-0000123440865000 [ 8596K] r-x/rwx SM=COW  /System/Library/Extensions/GeForceGLDriver.bundle/Contents/MacOS/GeForceGLDriver

The second of the lines you posted says pretty clearly that there was an issue with the driver for your graphics card (I assume you realized that which is why you posted them).

Yes, I tried it on my MacBook Pro yesterday, as well, and had the same problem (same symptom), but I did not check the log messages. I just assumed it was not a problem with my hardware but something in the program. However, I just checked the log messages on my macbook now, and it is a different exception code: EXC_I386_GPFLT with exception note: EXC_CORPSE_NOTIFY. So I’m stumped. I’ll see about running this on Windows when I get a chance.

How can I export every Scene of a Sketchupfile into the PDF-Format ?
I tried to replace “obj” by “pdf” in the Script and in “TIG::Export.new(“obj”)”.

Answered in your other thread. Please follow forum Guidelines and do not double post, nor take threads off-topic (ie, this topic is about OBJ export):

:arrow_right: Export every Scene to PDF