• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin] Import OBJ with Materials v2.1 20131118

Scheduled Pinned Locked Moved Plugins
279 Posts 87 Posters 378.6k Views
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.
  • T Offline
    TIG Moderator
    last edited by 16 Apr 2011, 22:00

    Immer

    I'd be more than happy for you to take over 'my' OBJimporter - 'Fluid' has recently made an equivalent compiled version [currently PC only].
    BUT if you want to redo aspects of my stuff then please do so and publish them - I only want credit/blame for my bits [note that several others also made earlier contributions to this 'collaboration' !].
    You can start a new thread [then I'll edit mine to direct new browsers to yours...]
    I have too much on right now to do many changes to tools that I feel are now 'spent'...
    BUT if you can improve it please do so πŸ˜„

    TIG

    1 Reply Last reply Reply Quote 0
    • I Offline
      Immer
      last edited by 16 Apr 2011, 23:55

      Thanks, but I've got enough projects on my plate already, I was just lopping a few warts off a new tool in my box. I've seen Fluid, but my main dabbling machine is an old Mac so it's not convenient to use.

      I can completely relate to not wanting to make frequent updates to old projects though, so here's my faster version for anyone interested.much faster version that also reuses existing materials instead of leaving objects untextured

      1 Reply Last reply Reply Quote 0
      • C Offline
        chango70
        last edited by 23 May 2011, 15:03

        @immer said:

        Thanks, but I've got enough projects on my plate already, I was just lopping a few warts off a new tool in my box. I've seen Fluid, but my main dabbling machine is an old Mac so it's not convenient to use.

        I can completely relate to not wanting to make frequent updates to old projects though, so here's my faster version for anyone interested.[attachment=0:1hpltocr]<!-- ia0 -->obj_importer.rb<!-- ia0 -->[/attachment:1hpltocr]

        Cool will give it a spin shortly.

        Cheers

        1 Reply Last reply Reply Quote 0
        • G Offline
          gmfs1410
          last edited by 23 Jun 2011, 21:09

          TY ...

          1 Reply Last reply Reply Quote 0
          • D Offline
            Danobe1964
            last edited by 7 Jul 2011, 10:53

            This plugin is the missing link between SketchUp and "Bryce 7 PLE" (also free) that I use as a renderengine.
            It is a perfect team and this obj-exporter is the hard to find plugin.
            Many thanks!
            Daniel

            1 Reply Last reply Reply Quote 0
            • A Offline
              Arzka007
              last edited by 30 Jul 2011, 18:15

              Great plugin, thanks.

              However, I have a problem with many OBJ files I try to import to SketchUp... Textures are missing. 😞

              From previous posts i realized that this is not actually a "bug" in OBJ importer. The reason is that many OBJ files are originally exported with "hard coded" texture paths (instead of relative pathing). So OBJ importer is trying to find textures from folder that doesn't exist in my computer...

              But hey, maybe it could be possible to do something for this?

              Maybe you could add a setting for "default textures folder", so that OBJ importer would always look for textures from that user-defined folder (and it's subfolders) when OBJ file is imported? Or maybe textures that are in the same folder with OBJ file (or in /Textures folder) could be automatically imported with OBJ file?

              I know that this can be done by editing manually MTL file that comes with OBJ file, but that's too much "hacking" for me... Especially if I have to do this with every sigle OBJ file that I import to SketchUp...

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 30 Jul 2011, 19:43

                The MTL file almost always goes in the same folder as the OBJ file - if you open the OBJ file in a text editor like Notepad it shows the MTL 'relative' path in the first few lines...
                If you open the MTL file in a text editor like Notepad it shows the path expected to each of the image-files used for the textures. Simply place the image-files [if you have them] in the same relationship - either in the same folder as the MTL or a subfolder suitably named...

                TIG

                1 Reply Last reply Reply Quote 0
                • A Offline
                  Arzka007
                  last edited by 1 Aug 2011, 14:24

                  Yeah that can be done of course - it's just not always very handy.

                  For exaple, a guy who originally created the 3d object might have stored his textures into folder like this:

                  C:\Documents and Settings\Leonardo\projects\maya\sci-fi\spaceships\enterprise\textures

                  Before I could place my textures in similar location, I would first have to create folder "Leonardo", then subfolder "projects", then subfolder "maya" etc. As I said, not very handy...

                  Programs like "Accutrans" and "Deep Exploration" have this "default textures folder" function. Or, if they can't find textures either in folder that is defined in MTL file or in "default textures folder" they ask the user "do you want to locate textures manually?".

                  I just thought that OBJ Importer could have some similar function... But maybe it's too much to ask all the features that are in commercial applications from a free plugin...

                  (Don't get me wrong, OBJ Importer is really really great plugin already just the way it is.) πŸ‘

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 1 Aug 2011, 15:33

                    No!
                    A GOOD OBJ exporter typically makes copies all of the linked image-files either in the same folder as the OBJ, OR better in a subfolder called Images or XXX_Images or XXX_Textures, where XXX is the name of the OBJ file - OR it just fails to export them like 'tree3d.exe'.
                    The OBJ file says which MTL file it's using in the first few lines of code - typically it's just a name and the MTL is a file in the same folder as the OBJ, with a matching name but the .mtl suffix.
                    Then for each collection of faces defined in the OBJ it sets the material 'by name' that it'll be used for those faces, and there's a list of materials 'by name' defined within the MTL file - each with its own color, transparency, texture etc.
                    The MTL file sets the path to an image-file, if any, because an MTL can just be a 'color'.
                    That path as I said is typically to a file in a subfolder, kept with the OBJ/MTL, that holds jpg/png files, named exactly as specified in the MTL file...

                    An OBJ importer looks for the MTL file... and if it exists then it applies the materials in it to the appropriate face-sets... it looks for the specified image-file [if any] for each material and if it's found it then uses that too...

                    If you have the image-files it's a simple matter of putting them in the path specified in the MTL - in my experience I have never seen anything other than a list of file names [i.e. the image-files are in the same folder as the MTL file OR more commonly the image-files are in a subfolder kept with the MTL file πŸ˜•

                    IF the MTL file is 'messed up' then manually edit it to repath each of the image-files defined in the lines starting 'map_Kd ' thus:
                    map_Kd Images/image1.png
                    and where 'image1.png' id the name of the file you have that should be used...
                    and where you have made a new folder called 'Images' kept with the MTL file and you have put all of the image-files in there!

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      Arzka007
                      last edited by 1 Aug 2011, 19:46

                      "A GOOD OBJ exporter typically makes copies all of the linked image-files either in the same folder as the OBJ, OR better in a subfolder called Images or XXX_Images or XXX_Textures, where XXX is the name of the OBJ file"

                      I couldn't agree more that that's the way is SHOULD be done. However, many programs, for example popular 3ds Max, don't do it that way by default. (Why not, I have no idea.)

                      When you save an object from 3ds Max in OBJ format (using default settings), linked image-files are NOT copied to the folder where OBJ and MTL files are saved. MTL file only contains links to original texture folder.

                      And when people try to open these files (in other computers) they can't see textures... And they keep filling forums with questions like "missing textures when opening OBJ file" (as seen in this thread also).

                      But hey, who cares, let's forget the whole thing! πŸ’š

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 1 Aug 2011, 20:07

                        http://forums.sketchucation.com/viewtopic.php?p=284378#p284378
                        explains how OBJ should be exported from 3dsMax...

                        Because an MTL is a text file it not that hard to find every image file in the list and remove all but the file name from the path, the replace the first part with a folder path
                        So
                        map_Kd SomeFolder/SomeOtherFolder/YetAnotherFolder/Images/image1.png
                        becomes [if the folder path is always the same a bulk Find+Replace edit is possible]
                        map_Kd image1.png
                        then you use a bulk Find+Replace ' map_Kd' >>> ' map_Kd Images/'
                        so you have
                        map_Kd Images/image1.png
                        etc for all of the image-files...
                        Then move all of the image-files into an 'Images' folder with the MTL...
                        It should work fine...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by 22 Aug 2011, 09:10

                          Got a feature request: Make it use the Importer class: http://code.google.com/apis/sketchup/docs/ourdoc/importer.html

                          That way it can be found under the native importer options.

                          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 22 Aug 2011, 09:11

                            hm...

                            Importing a OBJ file now, I'm getting lots of Error: 666 in the Ruby Console. πŸ˜•

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

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              TIG Moderator
                              last edited by 22 Aug 2011, 09:33

                              Sometimes OBJ files throw an error [I suspect that it depends how they were 'written' originally - there are several different 'formats' - e.g. define some vertices then related faces per group... or define all vertices then all faces en mass; which is more difficult to read 'manually' too] - the geometry for the face is invalid - the three points are perhaps colinear or [effectively] coincident - so I get it to put up an error instead of crashing... The 666 is a longstanding joke with Rich πŸ˜’ http://forums.sketchucation.com/viewtopic.php?p=316402#p316402
                              Although it throws the errors up it usually seems to make the expected geometry - so it's difficult to see what's 'gone wrong' πŸ˜•
                              You can of course easily tweak the 666 rescue message to include the Exception - but frankly I found that little use either...
                              My importer is not [always] as good as the compiled dll version that is available.
                              For MAC it is the only option.

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by 22 Aug 2011, 09:37

                                There is a compiled version?

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

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 22 Aug 2011, 09:40

                                  @thomthom said:

                                  There is a compiled version?

                                  Here http://forums.sketchucation.com/viewtopic.php?p=316470#p316470
                                  Fluid's free OBJ importer [PC only]...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • Rich O BrienR Offline
                                    Rich O Brien Moderator
                                    last edited by 22 Aug 2011, 11:01

                                    Fluid obj importer in the extensions forum.

                                    Download the free D'oh Book for SketchUp

                                    1 Reply Last reply Reply Quote 0
                                    • Rich O BrienR Offline
                                      Rich O Brien Moderator
                                      last edited by 22 Aug 2011, 11:03

                                      Sorry, I posted this earlier but lost web connection.

                                      Download the free D'oh Book for SketchUp

                                      1 Reply Last reply Reply Quote 0
                                      • N Offline
                                        niks
                                        last edited by 20 Sept 2011, 10:57

                                        hi Tig..thank you for this ama 😍 ing...plugin

                                        1 Reply Last reply Reply Quote 0
                                        • C Offline
                                          capsssa
                                          last edited by 6 Oct 2011, 09:15

                                          Please,
                                          i need help.
                                          I've got the version 7 pro, i am on a mac, but when i installed this plugin it doesn't work.
                                          I am on a mac. When i poen sketchup the plugin is absent.
                                          Can you help me, please ?

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 6
                                          • 7
                                          • 8
                                          • 9
                                          • 10
                                          • 13
                                          • 14
                                          • 8 / 14
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement