• Login
sketchucation logo sketchucation
  • Login
๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[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 30 Sept 2013, 17:01

    Without seeing the relevant OBJ and MTL how could I say ๐Ÿ˜’
    Can you ZIP them and attach them to a post or PM them ?

    It's likely something wrong with the MTL etc - both files are human-readable so you should be able to see issues ?
    ๐Ÿ˜•

    TIG

    1 Reply Last reply Reply Quote 0
    • Z Offline
      Zylescozar19
      last edited by 13 Nov 2013, 04:07

      Hi TIG, this is a AWESOME PLUG-IN!
      But when i try to import this simple cube (see image)
      there is no object that have been imported.

      Thanks.


      CUBE.png


      1.png


      2.png


      3.png


      4.png

      1 Reply Last reply Reply Quote 0
      • Z Offline
        Zylescozar19
        last edited by 13 Nov 2013, 04:11

        Hi TIG. this is a AWESOME PLUG-IN!

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 13 Nov 2013, 11:18

          What units are you using?
          If the imported object is very tiny geometry can't be created.
          So a number like 0.1 might be very tiny in mm but x1000 using m !
          The radiused edges look very faceted ?
          Try using meters ?
          The imported object might then be enormous, but can be scaled.
          Can you attach the OBJ/MTL to a post or a PM ?

          TIG

          1 Reply Last reply Reply Quote 0
          • Z Offline
            Zylescozar19
            last edited by 14 Nov 2013, 02:29

            I did try all of the units.

            Ok ill send you the copy of obj. file.
            BTW im using WINDOWS 7 ULTIMATE - 32 BIT

            Thanks TIG! ๐Ÿ˜›

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 18 Nov 2013, 11:26

              OK

              I now have your ZIP file by PM for this OBJ.

              I note that there are no materials specified in the OBJ, by referencing an associated MTL file ?

              Also the 'object' seems to have some tiny facets.
              I think it was exported in 'mm' - but there's no units info in the header !
              It does now import OK in 'mm'.

              There are 68,000 lines of code in the OBJ file - which seems a lot for such a simple thing !

              BUT... you have discovered a typo in my script's code.

              This typo causes a failure - with a message in Ruby Console - but only when a particular rare combination of definitions in the OBJ file occur - that is when there are negative [-ve] values for 'f' face vertices specification: most OBJ's make +ve values to count the vertices when referring to v/vt/vn down the list etc... but -ve ones are allowed to count up the list... and my code did try to trap for that possibility... however, with certain combos of v/vt/vn it does fail because of this typo with the 'vn' counter...
              However, your OBJ file's format is odder still in that it makes 26 subgroups [one for each external cube] and it restarts the vertex negative count back up the file for each subgroup it defines, rather than counting through the the whole file - making it awkward to 'reverse-engineer' it to the more normal [logical] downward count which always runs from the top and is always ignoring any subgroups - so '1' is always the very first vertex defined and any grouping is ignored - but it is trappable...

              Also I note that many faces are 'reversed' in this OBJ's code.
              These need fixing manually...

              Frankly you could more easily make and assemble these cubes in SketchUp - there are only 3 variants for corners, centrally and mid-side, with 3d rotation etc and suitable face coloring [which is entirely missing from this OBJ anyway]...

              However, you reported issue has made me make the script work better for these -ve values ๐Ÿ˜‰

              I have fixed the script and an update will be published shortly... ๐Ÿค“


              Capture.PNG

              TIG

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 18 Nov 2013, 11:43

                There is an update available: http://sketchucation.com/forums/viewtopic.php?p=172790#p172790
                or http://sketchucation.com/resources/pluginstore?pln=obj_importer
                Previously unpublished:
                v2.0 20130321 'Blender-quads' now import as two tri-facets. The OBJ file must contain header-text "# Blender" or similar.
                Recently fixed:
                v2.1 20131118 Import of OBJ files using a -ve counter for 'f' vertices within sub-groups fixed. View now refreshes with each group completion.

                TIG

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Mill29
                  last edited by 25 Nov 2013, 12:53

                  Hi,

                  Thanks for your job, really apreciate.

                  there is something i missunderstood.

                  1/ I open a .vray.mat in 3DS
                  2/ I export in obj format, wih mat as you can see on the picture.

                  http://img600.imageshack.us/img600/38/jmqm.jpg

                  3/ i put in the export folder, the map furnished with the .vray.max.

                  4/ i import in SU using your plugin, i choose cm

                  The problem is i don't have any mat with the model.

                  Could you help me?

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 26 Nov 2013, 09:19

                    When you make a .OBJ file it should also make a similarly named .MTL file which defines the materials.
                    These materials are referenced in the header of the OBJ and can be plain colors with optional transparency or with mapped textures.
                    The textures are defined with a reference to an imgae file.
                    Most OBJ exporters put these in a folder - named something like Textures or OBJName_Textures...

                    The normal rule is that the OBJ and MTL files go in a common folder - the OBJ's code typically looks for the MTL file 'by name only' [with no 'path'] and therefore expects it to be in the same folder as the OBJ... The 'Texture' folder goes in the same folder as the OBJ and MTL because the MTL's code looks for "Textures/ImageName.png" etc.

                    If the OBJ can find the MTL then no materials are made/used.
                    If the MTL can't find an image file then the a plain-color is used instead.

                    You can read an OBj or MTL file with a plain-text-editor...

                    So see what the OBJ and MTL files are expecting and ensure that you keep all of the exported parts together: that is - the matching OBJ + MTL + ImageFilesInsideTextureFolder

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      chandlerplusbass
                      last edited by 5 Dec 2013, 02:33

                      For some reason the file will not show the textures. I checked the .mtl and everything seems fine, and the textures are where they need to be. But when I import the file, all the textures are replaced with a matte grey. Is there anyway I can get this to show the textures? It's working fine in blender but not SketchUp.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 5 Dec 2013, 10:23

                        Without seeing the files who can say ? ๐Ÿ˜’

                        Are the faces made 'inside out' ?
                        So you are seeing their backsides ?
                        Are you importing 'with textures' - there are different options...

                        Can you ZIP and attach or PM+attach the files ๐Ÿ˜•

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • X Offline
                          XAIR134
                          last edited by 26 Dec 2013, 21:38

                          Some textures are not loading, the model had 26,000 lines though. Is that usual?

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 26 Dec 2013, 22:14

                            Who knows? ๐Ÿ˜’
                            What's the object?
                            What are the Textures? ๐Ÿ˜ฎ
                            Are ALL Texture files listed in the MTL sub-file also in the Textures sub-folder ? ๐Ÿ˜ฒ
                            If it's a manageable size when made into a ZIP can you attach it to a post or PM it ?... โ˜€

                            It might be an issue with the files themselves rather than the plugin ???

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              Janice
                              last edited by 24 Jan 2014, 03:01

                              Hi,

                              I am using Sketchup 2013 and installed obj_importer_v2.2.rbz. I am trying to import a .obj file in to Sketchup.

                              I installed by going to Window > Preferences and then clicking Extensions. The Extensions panel is displayed and then I clicked the Install Extension button.

                              Then I restarted sketchup.

                              Then I select import and the file format for obj still doesn't appear.

                              I was hoping you might now what I am doing wrong. Should I be importing a different way?

                              Thanks in advance.

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 24 Jan 2014, 18:31

                                This tool is NOT an importer that is listed under the File menu...
                                That would need a special kind of coding...

                                This tool makes its entries in the Plugins menu...

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  komeyl
                                  last edited by 25 Feb 2014, 11:33

                                  @chris fullmer said:

                                  And thanks!

                                  how to import materials obj?

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    TIG Moderator
                                    last edited by 25 Feb 2014, 13:50

                                    @komeyl said:

                                    @chris fullmer said:

                                    And thanks!

                                    how to import materials obj?
                                    Help us to help you... ๐Ÿ˜• You question is useless ๐Ÿ˜ž
                                    Let's assume you have the plugin's RB file correctly installed in the Plugins folder and you have restarted SketchUp...
                                    And also that you have an OBJ file, and it related MTL file defining materials - this must be kept with the OBJ file.
                                    If there are textures specified they come as image-files inside a subfolder that is kept with the MTL file [its exact name varies - open the MTL in notepad to see the expected folder-name/relative-path...]

                                    Run the Import OBJ tool from its Plugins menu item [I assume you'll want 'with Textures'].
                                    Answer the dialog prompts [if you don't know the original units accept the default 'inches'], then wait as it is processed.

                                    Answer the prompt at the end - you will probably want to flip the imported geometry upright.
                                    You should now have the imported object using the specified materials and textures.

                                    To see progress watch the status bar.
                                    If you have the Ruby Console open rare error-message might appear...

                                    If the geometry is exceptionally tiny and arrives with 'holes', then try reimporting it as 'meters' [scaling down to the real size later] - that way you'll avoid the known tolerance issues, where very tiny edges are not created by SketchUp when it considers their ends 'coincident' [~/1000"], then the related face is lost because it has a gap in its edge-loop - tiny geometry can 'exist' [say after scaling down] but it can't be 'created'.

                                    Should you need further help, please come back and ask concisely and clearly, ...

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • bagateloB Offline
                                      bagatelo
                                      last edited by 4 Mar 2014, 17:27

                                      The inverse option, for export obj files from SU is possible?
                                      Thanks anyway....

                                      While the cat's away, the mice will play

                                      1 Reply Last reply Reply Quote 0
                                      • S Offline
                                        sketchorro
                                        last edited by 20 Oct 2014, 04:53

                                        Hi,

                                        Let me start by saying thanks for this plugin, it's great.

                                        I've started using it to import models from Structure Sensor.

                                        I decided to do a little hacking to make my life easier; basically setting the units to default to metres and taking a look at how to bulk import mesh models (todo). I also discovered that when the models were loading in the background/covered by another window, they loaded much faster (I'm on OSX/'14 Make).

                                        The reason for this is because the UI is getting hammered with several tens/hundreds of thousands of repaints (1 per obj file line) to updated the status bar from this:

                                        	 Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
                                        

                                        I took a crack at fixing this by making the status line update on a change in percentage. I obviously screwed it up not being a ruby coder, but in the process discovered my 40K+ line (991kb) models loaded in about 2 seconds.

                                        It still slows down when you get really big models; I have a 13.2MB file that starts to grind after about 90%, but I suspect this is a memory/swap bottleneck.

                                        Anyway, I fixed my update code and it looks like this:

                                        Initialize the percentage variables before the looping starts

                                        
                                         old_percentage=-1
                                         new_percentage=0
                                        
                                         ### trap in case of a missing 'g'
                                         lines=["g OBJ\n"]+lines
                                        
                                        

                                        Update the status and force sketchup to repaint once per percentage point.

                                        
                                         # Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
                                         new_percentage = ((line_cnt * 100.0)/lines.length).round;
                                         if old_percentage != new_percentage
                                           Sketchup.set_status_text("Importing Model - #{new_percentage}% (#{line_cnt} of #{lines.length})")
                                         end#if
                                         old_percentage = new_percentage
                                        
                                        

                                        Probably something that would help others enjoy this plugin a little more.

                                        -G

                                        1 Reply Last reply Reply Quote 0
                                        • E Offline
                                          enuminous
                                          last edited by 6 Jan 2015, 20:16

                                          I've just installed Import OBJ with Materials 2.1 and am running into the same problem, with materials being replaced with white/grey. I'm exporting from Poser, and the .obj and .mtl files are in a folder, with a Textures subfolder containing the generated PNG files. I've also tried it with the PNG materials in the same folder at the .obj and .mtl files. Neither works. I'm running Sketchup2015 64 in Yosemite on a 5K Retina iMac if that helps. Any suggestions?

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

                                          Advertisement