• Dummy Article For Plugin Page

Import OBJ with Materials    v2.2

  • Overview
  • Quick Start
  • Release Notes

(c) TIG 2009-2013 in parts


Note: Based heavily on Jim Foltz's 'obj_import.rb'* AND with Whaat's UVW texture mapping ideas... Many thanks !

BUT it's now with added materials with opacity/texture, also units setting and YZ axes swap dialogs.

On running it a dialog asks you to select units [pick from list] the file uses any 'units' in the .obj's header as the default value, if not then default=Inches.

The vt info in the .obj file is used for UVW texture mapping. There's a warning in the console if .obj's .mtl or any texture files are missing. If the .mtl is missing or incomplete the #default material# is used. If a texture file is missing the material's color/opacity is used.

The zoom goes to extents at the end.

A closing dialog asks if you want to swap the YZ axes - Yes/No reply -
some .obj files are created flipped like that... so if the import appears flipped over Yes will right it... The 'swap YZ axes' has a one step undo. The imported materials and geometry in the OBJ groups is only undoable in multi-steps - instead simply erase the OBJ imported groups and delete any new materials...


Sometimes very complex OBJ shapes don't receive their textures at all. Some OBJ files have tiny numbers: then faces might not be created: if so, retry with larger 'units', you can scale group(s) down afterwards. Some OBJ files have tiny face planar discrepancies: then some faces might get triangulated to compensate: if so, retry with smaller 'units' and scale group(s) up afterwards. Some complex files might need a bit of manual healing: they can also have erroneous vertices - so it's recommended you use 'Fix Problems' accessed from the 'Model Info > Statistics' dialog - especially if the result takes a long time to process or have divided faces forced to form geometry or if it feels jittery when orbiting around the model etc... Some complex files with excessive smoothing etc might fail to import.

View textured results in 'Monochrome' to see any reversed faces...

Get an OBJ file and supporting MTL file and any textures in a folder etc as specified in the MTL [these files can be read using Notepad or TextWrangler].

Open an empty SKP and choose the tool of the menu.

Select the OBJ file.

Select the Units - this defaults to 'inches' if no "#units=" in the OBJ file's header.

The import progresses with a counter showing the number of lines processed so far.

After each subgroup [if any] is processed the view refreshes to show what has been made.

On completion there is an auto-zoom_extents and you are asked if you want to Flip its YZ axes - note that many OBJ files will not use SketchUp's axes conventions, so the imported objects will often arrive laid on their back !

The flip and then the import are one step undoable.

View in Monochrome mode to see 'reversed faces' - many OBJs are sloppily model and need fixing...

1.0 20090714 First release.

1.1 20090715 Existing Materials re-used/make variant option added.
Swap Y & Z axes ? Yes/No, option added.

1.2 20090723 Name changed to 'obj_importer.rb' / 'Import OBJ' Proper UV texture mapping added.
Added dialog geometry & texture mapping Units.

1.3 20090728 Submenu added with '..no Materials' and '...as Mesh' options. Material/usemtl duplicated entries trapped.
Failure to import geometry - warning message added.
Scaling errors corrected.
Model.startaction()...commitaction removed as it was causing errors on complex files.

1.4 20100406 Different format obj file text now accepted.

1.5 20100816 Missing group in obj trapped [with "g OBJ"].

1.6 20100825 Negative face indices allowed.

1.7 20100825 Fill from mesh changes.

1.8 20100825 Trapped for spaces in image-names/paths.

1.9 20110223 Errors with occasional reversed faces resolved.

2.0 20130321 Blender-quads now import as two tri-facets. The OBJ file must contain header-text "# Blender" or similar.

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.

2.2 20131228 Future proofed.