[Plugin] Import OBJ with Materials v2.1 20131118

Re: [Plugin] Import OBJ with Materials 20100825

Postby pibuz » Thu Dec 02, 2010 12:50 pm

+1 to Wyatt's request! Could be very useful using Tree[d] trees!
1
visit my blog! (italian language)
www.filipposcarso.blogspot.com

pibuz 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby zubenelgennubi » Sat Dec 04, 2010 9:32 pm

thank you so much!!!!!
0

zubenelgennubi 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby rattusNOR » Tue Jan 25, 2011 12:58 am

worked very well... thanks!!
0

rattusNOR 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby 3deviator » Fri Feb 04, 2011 6:53 am

hellow TIG, i got some problem using this plug-ins. i don't know if the import OBJ plug-ins have a problem or the software i used. I use Frecle tree[d] 3.1 its a free tree generator software to generate tree and export it to .obj file and then import it to sketchup pro 8 using Import OBJ. when i finish importing it, the tree has no texture even i use import OBJ[with texture]as seen in the pictures. whats the problem for it TIG? Anyways, heres the link for tree[d]3.1 software http://www.frecle.net/index.php?show=treed.about . It is great help to us if you can fix this one, we can generate trees and load it to sketchup. hope you will reply this post, thanks.
1

3deviator 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby TIG » Fri Feb 04, 2011 12:28 pm

3deviator

The fault isn't with OBJimporter itself but rather with the 'tree[d]' OBJ exporter.
It makes a OBJ file describing the geometry and a MTL file describing the materials but fails to export the image files to which the MTL file refers.
If you open the MTL file with notepad you'll see some image files specified at the end of each material definition - e.g. map_Kd wood03.png
These image files are in the tree[d] 'Textures' folder - typically it's C:\Program Files\gile[s]\plugins\tree[d]\Textures
Copy the missing image files from that folder to the folder into which you have exported your OBJ/MTL files.
Now your image OBJ file imported into a SKP 'with Textures' will have the textures applied...
Now for the rub! The exported/imported tree[d] is relatively 'useless' !!! It has single sided leaf faces and the texture is only applied to the front faces, so all of the backs show as the default back color - usually a blue/gray AND the leaf faces have visible edges and a diagonal line across the middle.
Capture1.PNG

BUT there is a way to fix these issues... :enlight:
Put the attached script [FixtreeD.rb] into ../Plugins folder and reopen the SKP with the tree in it, so that the script is loaded.
Now edit the group containing the tree and type FixtreeD.new into the Ruby Console (it runs on all entities in the current context, so DON'T use it outside of the tree group's edit).
All coplanar edges will be removed.
All other edges are hidden, and no longer cast/receive shadows.
The leaves' front materials are copied to their backs.
Hidden Geometry is switched 'off'.
Progress is reported in the Status Bar and Ruby Console
It can take some time to process a complex tree that has 1000s of parts!
FixtreeD.rb
The attached zip file contains a tree[d] exported OBJ/MTL AND the required images listed in that MTL [but not exported by tree[d]!], it also contains the imported OBJ tree showing the problems...
tree.zip
This image shows what the 'fixed' tree looks like with the edges/back_faces etc sorted...
Capture.PNG
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby pilou » Fri Feb 04, 2011 12:31 pm

TIG is Mac Gyver! :thumb:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby honoluludesktop » Fri Feb 04, 2011 9:45 pm

I'm guessing that's a render of a made-up model? If so, add a zip-gun, wrap it into a bracelet, and represent it:-)
0
User avatar
honoluludesktop 
In Remembrance
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby 3deviator » Mon Feb 07, 2011 12:22 pm

Thanks for your reply TIG, this is very nice script, its a Great Help. Thanks a lot. It works fine although it took too long in processing but you will also satisfied with the output. I'm very impress of what you did TIG,your truly "The Incredible Giant".
0

3deviator 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby Gaieus » Mon Feb 07, 2011 12:23 pm

3deviator wrote:Thanks for your reply TIG, this is very nice script, its a Great Help. Thanks a lot. It works fine although it took too long in processing but you will also satisfied with the output. I'm very impress of what you did TIG,your truly "The Incredible Giant".

3deviator, use the reply (or quote) buttons to reply a post, not the report function, please. (I know, this needs some sort of routine, too). I had to copy/paste/change poster and all for the above post...

Cheers
0
User avatar
Gaieus 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby 3deviator » Tue Feb 08, 2011 5:19 am

Gaieus wrote:
3deviator wrote:Thanks for your reply TIG, this is very nice script, its a Great Help. Thanks a lot. It works fine although it took too long in processing but you will also satisfied with the output. I'm very impress of what you did TIG,your truly "The Incredible Giant".

3deviator, use the reply (or quote) buttons to reply a post, not the report function, please. (I know, this needs some sort of routine, too). I had to copy/paste/change poster and all for the above post...

Cheers


ohh! im so sory sir Gaieus, i dont intend to do that, I'm just confuse, if where is the button to reply for a specific post. im so sory for that sir. how can i delete that post sir?
0

3deviator 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby 3rdEye » Wed Feb 09, 2011 5:33 pm

Hi TIG,

First:(I wrote to you in another thread, about the texture mapping import)

After testing the last days with Maya 2009 I can say the following:
Your Plugin imports the Geometry very fine and accurate, and it additionally imports the maya mental ray shader I used there. If the shader has only normal mapping applied without diffuse mapping, on import the mapping seems to get lost. When i applied the same map to the diffuse channel it worked, but:

The texture mapping is applied to the shader, not to the object, because when i replace the shader in SU 8, the texture mapping gets lost.

When I tried to render the object in SU 8 with V-Ray 1.49.91 it did work for hours, but could not complete the Render. When I replace the imported shader with a new one with same textures applied, it renders in usual time, but - as i said - the mapping is lost.

am I doing something wrong?

thx again for your great plugin!
cheers, 3rdEye
0

3rdEye 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby cublique » Tue Feb 15, 2011 1:06 am

Hi TIG

I Have little problem when import a complex big obj file

its very heavy in my little machines..

I made the obj from ivy generator filling full a wall which dimension 5 x 12 meter2

could you teach me..how I can import complex big obj file?

thanks a lot
0

cublique 
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby TIG » Tue Feb 15, 2011 1:14 am

cublique wrote:Hi TIG

I Have little problem when import a complex big obj file

its very heavy in my little machines..

I made the obj from ivy generator filling full a wall which dimension 5 x 12 meter2

could you teach me..how I can import complex big obj file?

thanks a lot

With complex data it takes time...
Try simpler forms...
OR wait overnight... :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials 20100825

Postby Gaieus » Tue Feb 15, 2011 10:53 am

Ivy generator creates extremely complex geometry (mostly unusable in SU actually).
0
User avatar
Gaieus 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby TIG » Wed Feb 23, 2011 5:25 pm

Here's v1.9 viewtopic.php?p=172790#p172790
A glitch with occasional 'reversed faces' on import has been addresses...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby wyatt » Wed Feb 23, 2011 9:08 pm

TIG, the fixtreed.rb is fantastic! The script eliminates several steps from a fairly lengthy process I developed to use Tree[d] models. Thank you!
0

wyatt 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby imaxx » Tue Mar 01, 2011 10:15 am

Hi TIG!
There are problems with import of this file. Familiarize please, and whether it is possible that or to make?
In advance thanks!
Max
0

imaxx 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby imaxx » Tue Mar 01, 2011 10:20 am

Sorry! I forget attach file!
11.zip
0

imaxx 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby TIG » Tue Mar 01, 2011 10:59 am

imaxx wrote:...
Imaxx
You only included the OBJ file ! :roll:
Therefore when it imports there is no MTL to set materials and of course NO texture/image files either...
Here is what imports with what you supplied.
The trunk is there and I suspect the branches/leaves too [as the rectangular slabs at various angles], BUT these need to have PNG texture materials with transparency to look right.
Also the app that has made these triangulated faces AND reversed one part - this is fixable using the 'tree[d]' techniques described in the recent thread BUT you need the OBJ file, the MTL file and the images specified in the MTL file in a subfolder IF given in the MTL; then process the import to remove the coplanar edge, add the material to BOTH sides of the face and hide edges etc..........
This is the present version
Capture.PNG
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby Justo » Tue Mar 01, 2011 10:15 pm

FixtreeD.rb works well with OBJ importer's imports of Xfrog plants as well
Thanks
0
Cheers
Justin

Justo 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby onesimo » Wed Mar 02, 2011 5:08 pm

from 3ds max, how do you export the files properly to have all the textures? in max it is properly textured but when you import to sketchup there is no texture. is it possible?
0

onesimo 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby MartinK » Mon Mar 14, 2011 4:02 pm

Thanks TIG. Your generous plugins and help on this forum have been invaluable to me. Much appreciated.
0

MartinK 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby Rich O Brien » Thu Mar 17, 2011 2:40 am

Don't laugh but I'm getting 'Error: 666' in the Ruby console? Some files import but most don't? They're fine in Modo and 3DS Max?
0
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby Gaieus » Thu Mar 17, 2011 3:59 am

Those must be some evil files, Rich. Pray to St Patrick today :?
0
User avatar
Gaieus 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby TIG » Thu Mar 17, 2011 9:53 am

Rich O'Brien wrote:Don't laugh but I'm getting 'Error: 666' in the Ruby console? Some files import but most don't? They're fine in Modo and 3DS Max?

The '666' is my joke error value - it means I don't know what the bleep is causing this but I'll struggle on regardless !
It is quite possible to get some 666 error messages but to end up with what appears to be a perfect result anyway. Some OBJ files seem to have a few faces coded in an awkward way that won't get made - usually too small to handle or perhaps with three effectively co-linear points - I can trap for these but NOT 'fix' them - so it just puts '666' when it is presented with one that fails... Do you say that some files fail completely? Can you post or PM me one so I can test with perhaps so more helpful error messages temporarily allowed on my own setup... Have you tried just doing the import as a 'mesh' - this can overcome some issues with this type of problem...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby honoluludesktop » Wed Mar 23, 2011 1:21 pm

TIG, thanks for this importer. I am playing with the "3D Modeling with Silhouettes" application, and using your plugin to bring its models into sketchup.
0
User avatar
honoluludesktop 
In Remembrance
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby pibuz » Wed Mar 30, 2011 4:20 pm

Hei TIG, sorry to bother...
I can run your script easily, but at the end of the transformation progress SU exits giving a BUGsplat message... How can I fix this?
0
visit my blog! (italian language)
www.filipposcarso.blogspot.com

pibuz 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby TIG » Wed Mar 30, 2011 4:50 pm

pibuz wrote:Hei TIG, sorry to bother...
I can run your script easily, but at the end of the transformation progress SU exits giving a BUGsplat message... How can I fix this?

Not sure - without loads more details about version, OS the OBJ itself etc...
Have you tried the OBJimporter by Fluidimporter viewtopic.php?p=316470#p316470 that is quicker and less prone to error than my old thing...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby pibuz » Thu Mar 31, 2011 11:32 am

No I didn't! I'll try that thanks!
0
visit my blog! (italian language)
www.filipposcarso.blogspot.com

pibuz 
 

Re: [Plugin] Import OBJ with Materials v1.9 20110223

Postby Immer » Sat Apr 16, 2011 8:48 pm

Hi TIG, I've got a few more patches for you, on your importer this time. I've been running into " - Material already exists..." errors a lot, which cause the associated group to be imported untextured.

I changed the following code to reuse the existing material, but it might be nice to have an option to automatically mangle the material name if it really is a different texture.
Code: Select all
   when "newmtl"
      mat_name=values[0]
                matnames=[];materials.each{|mat|matnames << mat.display_name}
                if matnames.include?(mat_name)
                  puts mat_name+" - Material already exists..."
                  ### traps for usemtl called x2 in obj or pre-existing materials
                  current_mat=nil
        ## NEW: make sure pre-existing materials are re-used
        if nil==new_mats.find{|mat|mat.name==mat_name}
         new_mats << materials[mat_name]
        end


I also noticed that the vast majority of import time is spent updating the progress bar. A quick fix that shortens a minute-long import to a few seconds:
Code: Select all
change
   Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
to
    if line_cnt % 73 == 0 # could be any number, 73 just makes the digits spin nicely
      Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
    end


Finally, one of my test models suffered from the "some faces get reversed" bug mentioned above - but I noticed that when I then imported the same object again, without my material reuse code so it ended up untextured, the problem disappeared. When I tested by commenting out the "position_material" line in the following code the problem also went away, but obviously so did the texture.
Code: Select all
if new_face and @current_mat!= nil
   if @current_mat.texture != nil
      pt_array=[]
      pt_array=[verts[0],face_uvs[0],verts[1],face_uvs[1],verts[2],face_uvs[2]]if verts_length==3 and face_uvs
      pt_array=[verts[0],face_uvs[0],verts[1],face_uvs[1],verts[2],face_uvs[2],verts[3],face_uvs[3]]if verts_length>3 and face_uvs
      # new_face.position_material(@current_mat,pt_array,true)
   else
...


I'll keep poking at it, but I'm having to figure out both Ruby and Sketchup's API as I go, so you might have more luck.

Here's the globe model I noticed the problem on for reference
globe.zip
0

Immer 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

PreviousNext


 

Return to Plugins

Who is online

Users browsing this forum: LionByDesign, skuca91, TheRedTide and 20 guests

Visit our sponsors: