[Plugin] Import OBJ with Materials v2.1 20131118
-
If you export an OBJ from SUp the header says this:
` # Alias OBJ Model File
Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
# File units = millimeters
mtllib Untitled.mtl
g Mesh1 G_2016_1 Model
usemtl Mirror_01
v 223.781 841.405 0
vt -1.99553 9.71584
vn 0 0 -1
v 195.802 797.206 0
vt -0.893997 7.97573
v 195.802 831.592 0
vt -0.893997 9.3295
f 1/1/1 2/2/1 3/3/1
...`So it is possible to indicate the units used in the OBJ in its header - in this case '
mm
' ...
https://en.wikipedia.org/wiki/Wavefront_.obj_file
It is just good manners to the OBJ's user...
If you want to remove the status_bar updates, edit the RB file in a plain text editor - like Notepad++ [PC] or TextWrangler [MAC] and find the line #228 saying:
Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
Type a#
at the start of the line to stop it loading...
To optimize the calculations you can also skip the counter by adding a#
before the previous line #227 which saysline_cnt += 1
which will save a few milliseconds on the now unneeded increment...
Save the file and restart SketchUp to see the change...
OBJs define geometry, they are supplied with a linked MTL file defining the materials: this almost always resides in the same folder as the OBJ [the name of the MTL file is given near the start of the OBJ's text].
That makes each material - where it is textured it indicates a reference to an image-file.
Good OBJ exporters will usually write these texture-files into a folder, which is shipped with the OBJ/MTL files.
Good OBJ exporters will also include the relative path to that folder when specifying the texture-file, e.g.
newmtl Mirror_01 Ka 0.000000 0.000000 0.000000 Kd 0.725490 0.725490 0.725490 Ks 0.330000 0.330000 0.330000 map_Kd **Untitled/**Mirror_01.jpg
However, with some poorly set up OBJ exports the image files are put in a subfolder, BUT only the file-name is included in the MTL e.g.map_Kd Mirror_01.jpg
In which case the texture-file in the folder is not found and the material is just made plain-colored.
The way to fix this is either to edit the MTL to include thefolder_name/
before each file-name - or probably easier, either move the OBJ/MTL into the image-files' folder, OR move the image-files into the same folder as the OBJ/MTL - either way the required image-files are then found and used... -
Thanks for the answer, i did manage to comment the line out already. Cant see if it is different though
PS when i do just one small part of a model it imports correct and nicely in quads. Now when i do a bit larger chunk i gets messed up. Model is some sort of easy, no difficult edge flows or so.
Ive tried scaling it up 100x in blender and than import as inch, perhaps i would go faster i thought. The inch models go like lightning speed.... but they have a lot of triangulation and messed up UVs.
-
Hey! I would really like to know if it's possible to have the normals and smoothing groups preserved instead of having all the faces smoothed? Is that something that would require a core change in the code?
The main reason is that defining hard and soft edges is super easy in Maya (and many other software) but it's a drag in Sketchup. That's because selecting multiple edges, edge loops and edge rings is easy in other apps but in Sketchup is a painstaking edge by edge process.
Great plugin btw! Works great otherwise!
-
@filibis said:
Hi TIG, thanks for the plugin!
But i can't make this .obj work in the attachment. It doesn't even ask for units in the beginning, just nothing happens. I suspect it's because .obj includes Turkish characters (ร,ร,ฤ,ล etc.), might that be the reason?I exported an .osm map and converted it to .obj and it worked without problem for USA areas.
There was no attached OBJ ??
Certainly non-ASCII characters in files etc can cause all sorts of unexpected issues...
If it's just the file-name you can fix that easily.
If the file itself contains non-ASCII characters, then try editing the OBJ using a plain-text editor like Notepad++ and globally replacing those - so ร becomes O etc...
If there's an associated MTL file and you have changed its name, then ensure that the OBJ file's reference [at the start of the file] uses the same MTL name.
If the MTL makes materials, then ensure their names are ASCII, and also that the equivalent use in the OBJ match.
It the MTL uses image files then ensure that its filenames are ASCII and that the actual image-files' names match... -
Hi TIG, thanks for the plugin!
But i can't make this .obj work in the attachment. It doesn't even ask for units in the beginning, just nothing happens. I suspect it's because .obj includes Turkish characters (ร,ร,ฤ,ล etc.), might that be the reason?I exported an .osm map and converted it to .obj and it worked without problem for USA areas.
-
@tig said:
There was no attached OBJ ??
(...)
If the file itself contains non-ASCII characters, then try editing the OBJ using a plain-text editor like Notepad++ and globally replacing those - so ร becomes O etc...
If there's an associated MTL file and you have changed its name, then ensure that the OBJ file's reference [at the start of the file] uses the same MTL name.Sorry, i somehow failed to attach. It should be there now.
There are quite amount of non-ASCII characters inside .obj file (only appears in .obj), so manual editing will be painful. And i ensured that .mtl file reference is correct. -
It only took a minute to edit th OBJ although it is nearly 95000 lines long!
I used Notepad++'s Regular Expression with Find [^ \r\nA-Za-z0-9._-] on the file displayed as Turkish
Which spots the Non-western characters.
I then substituted them with an equivalent so ร >>> C etc with Find+Replace for the problem characters in turn.
The fixed OBJ file is attached...The MTL was OK.
Try it and report back...
-
Cool, now it asks for units but when i chose meters (which suggests inside .obj), nothing happens (it only works if i choose 'as mesh' feature. This option works with other units as well).
Also if i chose anything other than meters, it visually imports everything in viewport, counts numbers at bottom left, but then gets erased at the end and gives this error: (happens both 'with textures' and 'no materials' option)
-
How does this Plugin work on Sketchup?
-
@bri11 said:
How does this Plugin work on Sketchup?
Have you installed it ?
Have you read the instructions near the beginning of this thread ?
What problems are you experiencing ? -
Hi,
Installed fine and mesh comes through fine if I pick a big enough unit.
But no textures at all come through no matter what I try. -
Update.
I was exporting an OBJ from SketchUp and it was generating an MTL file but not the textures as .jpgs that were referenced IN the MTL file.
I exported the textures manually from SketchUp via Photoshop into the same file, re-imported and it all worked!
Thank you very much! -
Hallo.. i'm trying to import a .obj file into SU2017 but nothiong happen...
i mean, it seems to load but after a little my draw is empty..on ruby appears that..
the problem should be the error :" Error: #<ArgumentError: invalid byte sequence in UTF-8> "
how could i solve it?!
Thanks
Ritcho
-
I suspect this is an issue with the encoding of the text in .OBJ file itself.
The importer needs to read in the lines of the file to process the data into SketchUp geometry.More recent SketchUp versions can often force text encoding to be Ruby compatible.
This plugin is nine years old and hasn't been changed for five !
So it doesn't do any fancy re-encoding...You can try the following manual fixes on copies of the .OBJ and .MTL files...
Use a plain-text editor like Notepad++.exe to edit the files
If you don't already have it, you can get a free installer - google it for the download...In the editors menu, under Encoding, check that it's set to Encode UFT-8, if not then use Convert to UTF-8.
Ruby needs that encoding.
Check that the text is not unexpectedly changed [e.g. weird name-changes] and that any materials in the .MTL file still reference existing image files - e.g. a jpg name containing an umlaut might need to be changed so that the file-name and .MTL entry match...
Save the files.Try re-importing it and feedback...
-
I got one more question about this version. On one of my mac it was working fine, sadly that one broke down. Now im back to my old macbook mid 2010. When i try the latest version the same model i tried earlier shows the quads half flipped faces. I had an altered version on the other mac, mac didnt seem to have an proper backup of that one.
When i check the main plugin info, it says there was an update "feature proof";
2.2 20131228 Future proofed.
Yet in the addon when added it doesnt state that. There its says this as last update;
2.1 20131118 Import of OBJ files using a -ve counter for f vertices within
sub-groups fixed. View now refreshes with each group completion. -
Don't worry about the version text in the RB file itself.
It's no longer updated.
The Rev notes in the PluginStore page are correct.The v2.2 was stated as 'future proofed'.
That was back when SketchUp was about to migrate to some new API methods and a newer Ruby version in v2014.
Just prior to that version's release, major developers were given some confidential prior knowledge, to let them get their scripts ready for those changes, but they couldn't expand much on what had been changed 'under-the-hood' without revealing what was impending in the SketchUp release... hence 'future proofed'...It is an old script and has not been changed in about five and a half years !
However, it should still work on older and of course the newer SketchUp versions.Install the latest version [v2.2] from the PluginStore...
-
Okay, thanks for answering. I found it weird that the same models now seems to have flipped quades (normals inside-out). I tried the OBJ importer from quad tools, never new this had one as well. Seems much faster and imported perfect. Just like OBJ importer did on my other machine with the exact same model. So i really dont understand why on this machine with the same plugin it acts different.
-
V2.2
I export my objects in OBJ format from MagicaVoxel a terrific Voxel prog! (free)
Reload works fine in Wings 3D (free)
No color inside SU or special result!
Glitch ? ...
Its the same if export the objects from Wings 3D result!or that!
-
@pilou said:
V2.2
I export my objects in OBJ format from MagicaVoxel a terrific Voxel prog! (free)
Reload works fine in Wings 3D (free)
No color inside SU or special result!
Glitch ? ...
Its the same if export the objects from Wings 3D result![attachment=1:2i3yc27k]<!-- ia1 -->glitch_obj_import.jpg<!-- ia1 -->[/attachment:2i3yc27k]
or that!
[attachment=0:2i3yc27k]<!-- ia0 -->glitch.jpg<!-- ia0 -->[/attachment:2i3yc27k]
I dont think mesh color is supported, only textures. Try using the scale or import option and use bigger scale. That sometimes seems to fix the uvs. You can also try the OBJ import with quad tools
-
PS i did a quick check with Blender. These cubes dont have a proper UV map. The texture is super wide as well.
EDIT
here's is that same scene and model, now it imports just fine
Advertisement