Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

The Seraphim - A custom Ship OXP from start to finish.

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

I think that's what the script I had was originally called. On my machine it's actually renamed O2D.py (and D2O.py) as I got fed up with typing the longer version.

When I'm doing a conversion I copy the Obj2Dat.py into the same folder as the rest of the files (the obj file, the png texture file and the material mtl file if I remember correctly) using explorer.

Then open a command prompt, and go to the folder that way. CD \ to go to the root, then c: (or whatever drive you're files are on), cd <foldername>, cd <nextfoldernamedown> etc etc (or cd \<folder1>\<folder2>\<folder3> down the tree if you prefer).

Then when you get where you should be, do the script execution as previously mentioned. If you want and can zip them all up and put them somewhere suitable, I'd be happy to grab a copy and see if I can convert them on my machine here to test it's nothing wrong with the files or anything.
Last edited by Thargoid on Fri Jan 09, 2009 10:17 pm, edited 1 time in total.
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Nah, my copy is definately called obj2dat.py and Dat2Obj.py - the upper and lower cases are correct too.

I have a suspicion that I'm just not in the right path, or entering the line correctly. It keeps pointing to seemingly random characters in the line with a ^ and stating that it's incorrect syntax.

In the Windows DOS command line if I type CD\ it takes me to the root of the C drive. Is this the same for Python? When I do that, there's no indication which drive or subdirectory I'm in. I just get ...

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

The other question is what version of python do you have installed, and do you have it associated with the .py file extension?
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Okay, I type CD\ and I get ...

Then I type C: and I get:

Code: Select all

File "<stdin>", line 2
   c:
   ^

Syntax Error: Invalid Syntax.
I tired Cd\c and CD\C:

And got the same thing with:

Code: Select all

Syntax Error: Unexpected character after line continuation character
Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Yes, I have Python 3.0 installed and it is associated with the py file type.
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

To change drives, it's just c: or d: or whatever, no cd.

You only use cd to change directory (that being what it stands for).

I just checked the scripts on my webspace and they're ascii (was just wondering if I'd managed to upload them as binary or something) as they should be.

Can you post a list of the files in the folder you're trying to convert? So we can see if everything's there that should be?

Or as I said upload a zip file somewhere and I'll try it here and check them for you.
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

The folder is:

c:\Oolitegubbins

it contains the following files (with correct casing):

obj2dat.py
flobit.obj

I simply cannot get the Python command line to go to either C: or the folder without giving me a suntax error.

Crow

PS - I appreciate all your help and patience on this.
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2479
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Hi Scarecrow! Great to see someone else from Wales here!
You can download the latest versions of the scripts from here:
http://svn.berlios.de/svnroot/repos/ool ... onverters/
even though the above path says oolite-linux these scripts definately work on my windows pc, and probably on apple macs as well
I use the Obj2DatTex.py script to convert an .obj file to the .dat format Oolite likes, and i use the Dat2ObjTex.py script to convert a .dat back to a .obj (the Dat2ObjTex.py keeps any UV map data in the model during the conversion process, the Dat2Obj.py script doesn't seem to do this)

regarding the syntax error there might be confusion here between the python command prompt and the windows command prompt, you need to use the windows command prompt to run the python scripts rather weirdly!
try this
click the start button, then select Run.. from the menu
in the box labeled "open:" type cmd then press enter
you should get a command prompt window open up with something like
c:\Documents and Settings\your_username by a flashing cursor,
type cd \ and press enter
this should get you to the root of your c drive, next type
cd Oolitegubbins and press enter
the text by the flashing cursor should now read C:\Oolitegubbins
if it does type obj2dat.py flobit.obj and press enter
now, back in windows, navigate to the Oolitegubbins folder and you should find a newly created flobit.dat file, you can then close the command prompt window and pop the flobit.dat file in your oxp's Models subfolder
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Exactly what the man sez :)

I think the key point here is the scripts run out of a windows command prompt, not the python command line. I just had a look at that (I must admit I hadn't noticed it actually existed :oops: ), and I get the same kind of errors you talked about earlier. So I think that's the root of your problems here.

Sorry, I should have been more clear before perhaps :oops:

The scripts Griff mentions are the ones you have (if you got them from my webspace, and they've not been updated on Berlios for the last few months), or at least that's where I downloaded from. I just renamed them as I got fed up with typing all that filename into the command prompt every time (they're called O2D.py and D2O.py on my machine, cos I'm a lazy alien).
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

HA windows command line! I didn't even think to try it. I assumed that a Python script would need to be run through the Python command line :oops:

I think I did try the windows command line yesterday but I think it was before I installed Python so naturally it didn't have a clue what I was talking about.

Okay.....

I tried the Windows command line and I got this:

Code: Select all


C:\>o2d.py flobit.obj
  File "C:\o2d.py", line 24
    print "converting..."
                        ^
SyntaxError: invalid syntax

NOTE: I've put the script and the obj file into the root of C to make things simpler. I've also renamed the script to o2d.py because I, too am lazy :)

So the path and file names are correct. The interesting thing is that when I opened the script in the Python editor and tried to run it from there, it also highlighted that same line as an error. It didn't like the quotation marks!

Crow

PS - Griff, whereabouts are you? I was a Barry boy originally - now living in Coventry.
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Hmm, it sounds like there's something not right in your obj file. When I export mine from Wings3D I get a materials file too (.mtl), but I just tried a conversion of the obj without the mtl and whilst I get an error then it's not the same as the one you get.

Are there any settings or configurations you can do within Maya in relation to obj output? As I said I use Wings so I can't be much help there.

You're doing everything I do in exactly the same way I do it and mine works. The only difference of course is your obj file itself (and your Python install, mine's 2.5 rather than 3 but I doubt that's a factor).
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Thargoid wrote:
You're doing everything I do in exactly the same way I do it and mine works. The only difference of course is your obj file itself (and your Python install, mine's 2.5 rather than 3 but I doubt that's a factor).
Actually, it is. Python 2.x and Python 3 are incompatible. It should be possible to install them side by side, and there’s a tool to convert Python 2 scripts to Python 3.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Well that's my learning point for today ;)
User avatar
Scarecrow
Dangerous
Dangerous
Posts: 99
Joined: Fri Jan 09, 2009 9:21 am
Contact:

Post by Scarecrow »

Right! I wonder if that's the problem then.

I might just uninstall Python 3 and go back a 2.x version - I have absolutely no use for Python beyond these scripts anyway.

I'll be sure to bung the MTL in there too just to be sure :)

Crow
Senior Artist - Blitz Games
My other work
The Crow's Nest
User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post by ZygoUgo »

TutOorial sticky!
Post Reply