Posted: Fri May 21, 2010 9:42 pm
Joined: 21 May 2010
Posts: 4
Do anyone know how to read .blend file ?
I have been looking in documentation and source files provided, but find it a bit overwhelming to figure out how to read SDNA.
What I really want is an example, preferably a console project.
1. It opens .blend file and store a copy of file in RAM.
2. Check if FILE_HEADER is OK, "BLENDER_v249"
3. Prints out main structures:
[FILE_HEADER]
[SR]
[DATA]
[...]
[SDNA]
[...]
[ENDB]
4. Use argv[] flags to query a data structure, ie: /camera
5. Able to print all vertex, normals, texture-uv-coords and indices
6. How about skeletons/bones and animation/movement ?
7. Able to dump to file a complete tree structure (all data included) as text
8. Summary of count vertex, meshes and info about texture
I know this might be a lot to ask but I think more people then just me are in need of an example of this type. I have also tried to compile "readblendfile" but don not get it with test.c file.
What is this BLO_readblenfile() by the way?
Thanks for all inputs
Posted: Mon May 24, 2010 12:32 am
Joined: 21 May 2010
Posts: 4
I have successfully managed to read all file blocks.
Still there are some things that puzzle me, for instance I have not figured it out what this SDNA index is, if someone could enlighten me I appreciate it.
Here is my output:
Code Size Memory SDNA Count
========================================================
[REND] [32] [0017F72C] [0] [1]
[GLOB] [32] [0017F720] [170] [1]
[SR ] [120] [04086C60] [165] [1]
[DATA] [20] [04086D20] [166] [1]
[DATA] [20] [04086D68] [166] [1]
...
... lots of data blocks
...
[DATA] [72] [0407B768] [128] [1]
[IM ] [384] [04041A50] [32] [1]
[CA ] [132] [040417C8] [30] [1]
[LA ] [384] [04041898] [40] [1]
[DATA] [24] [040377C0] [293] [2]
[WO ] [364] [04043880] [121] [1]
[TX ] [120] [04043A20] [28] [1]
[DATA] [4] [05FB9D30] [0] [1]
[OB ] [848] [0409C970] [113] [1]
[DATA] [120] [04044488] [54] [6]
[DNA1] [44572] [06023F70] [0] [1]
[ENDB] [0] [00000000] [0] [0]
========================================================
File name: simeplebox.blend
File version: 2.49
File size: 126892
Blocks: 412
Posted: Thu May 27, 2010 3:53 pm
Joined: 21 May 2010
Posts: 4
Okay folks, after a ton of digging in source code and what little there is of documentation, I finally was able to parse SDNA and to get MVert structure.
Now the big question is WHERE is the vertices actually stored in the blender file.
Here is my latest output of getting MVert:
SDNA signature found, starting SDNA parsing.
NAME found
TYPE found
TLEN found
STRC found
Done parsing SDNA
Querry for MVert
Found MVert, type: block, with 6 number of fields
Nr Type Name
[0]: float, co[3]
[1]: short, no[3]
[2]: char, flag
[3]: char, mat_nr
[4]: char, bweight
[5]: char, pad[3]
Done querring data
Posted: Thu May 27, 2010 7:14 pm
Joined: 21 May 2010
Posts: 4
And there I got my vertices, made a simple cube and extruded it once and then merged the bottom vertices. I think my project is almost done now.
Here is my latest output:
vertex[0]: (0, 1.19209e-007, -1)
vertex[1]: (1, 0.999999, 1)
vertex[2]: (0.999999, -1, 1)
vertex[3]: (-1, -1, 1)
vertex[4]: (-1, 1, 1)
vertex[5]: (-1, 1, 2.60718)
vertex[6]: (-1, -1, 2.60718)
vertex[7]: (0.999999, -1, 2.60718)
vertex[8]: (1, 0.999999, 2.60718)
Total vertices: 9
Posted: Thu Apr 21, 2011 9:35 pm
Joined: 30 Aug 2010
Posts: 63
wow...
almost a year since this was asked,
and you never got no help on any of it O.o
guess I'm not the only one meeting up with
people who have the knowledge and won't give you any lick of it
srs...
people like that just P me off -.-
anyways...
you're farther than me on this...
I want to ask, how would I go about figuring the SDNA stucture??
I'm only semi-good in Py, and am bad at reading C-type codes...
(note: semi-good doesn't mean I'm a noob)
anyways...
your help would be greatly appreciated,
and you're definatly getting credit in the plugin for my project
EDIT:
I take back what I said about the "people not helping you" part...
they never really had any time to help XD
since you posted all of this in a day... heh
_________________
Posted: Fri Apr 22, 2011 3:45 pm
Joined: 13 Oct 2002
Posts: 939
Look at:
http://wiki.blender.org/index.php/Dev:2.5/Source
Specifically the links: Data API / RNA
There are some other good ones there as well.
Posted: Sat Apr 23, 2011 6:43 pm
Joined: 23 Apr 2011
Posts: 1
Hi,
new here. Seems odd that they don't provide at least a C API for loading .blend files? Google turns up nothing. Did they recently change the format?
I'm not an artist, so don't actually use it; but I'm assuming blender can export to other common formats? All the commercial ones look like they have free api/sdks, so that is the way to go?
Posted: Sun Apr 24, 2011 3:38 pm
Joined: 30 Aug 2010
Posts: 63
no...
the format's still the same
the only major change (why blender 25 converts blender 24 files)
is the animation system...
but because of that change,
the 248 specs I have are kinda useless
now I need 257 specs
the notes SirDude gave me did help,
but theres quite an overwhelming amount of reading to do...
I can be shown in C codes,
but there has to be alot of commenting for me to understand it
(including the basic stuff)
_________________
Posted: Tue Oct 04, 2011 10:44 am
Joined: 04 Oct 2011
Posts: 2
Hi,
I want to write a Nautilus blender-render script similar to my Synfig and Anime Studio render scripts.
For this I would need to get info from the blend files on which scenes there are within and the length of these, etc.
The .blend file format doesn't seem to be in plain text so I can't get the info by a simple grep on the files.
How can I get this info?
Posted: Tue Oct 04, 2011 12:24 pm
Joined: 30 Aug 2010
Posts: 63
| marilyn099 wrote: |
Hi,
I want to write a Nautilus blender-render script similar to my Synfig and Anime Studio render scripts.
For this I would need to get info from the blend files on which scenes there are within and the length of these, etc.
The .blend file format doesn't seem to be in plain text so I can't get the info by a simple grep on the files.
How can I get this info? |
click on the link I thanked him for
EDIT:
wait wut...
this appears to be a different thread...
well... there's another thread in this board anyways...
EDIT2:
http://blender.org/forum/viewtopic.php?t=21153
_________________
Posted: Tue Oct 04, 2011 5:29 pm
Joined: 05 Aug 2003
Posts: 3493
| Quote: |
| The .blend file format doesn't seem to be in plain text so I can't get the info by a simple grep on the files. |
A .blend file is basically a memory dump of Blender's internal database (a network model database implemented with linked lists)
You can run 'strings' on the .blend and grep for names of interest, but this is like screen-scraping and highly prone to breakage.
The easiest thing is to use Blender's Python API (BPy) to iterate thru items of interest.
BPy scripts can be run from the command line ( blender -b -P some_script.py ) Since BPy is an extension to Python, you have all of Python's facilities at your disposal.
Posted: Thu Dec 08, 2011 9:32 pm
Joined: 08 Dec 2011
Posts: 3
| KTiger wrote: |
I have successfully managed to read all file blocks.
Still there are some things that puzzle me, for instance I have not figured it out what this SDNA index is, if someone could enlighten me I appreciate it.
Here is my output:
Code Size Memory SDNA Count
========================================================
[REND] [32] [0017F72C] [0] [1]
[GLOB] [32] [0017F720] [170] [1]
[SR ] [120] [04086C60] [165] [1]
[DATA] [20] [04086D20] [166] [1]
[DATA] [20] [04086D68] [166] [1]
...
... lots of data blocks
...
[DATA] [72] [0407B768] [128] [1]
[IM ] [384] [04041A50] [32] [1]
[CA ] [132] [040417C8] [30] [1]
[LA ] [384] [04041898] [40] [1]
[DATA] [24] [040377C0] [293] [2]
[WO ] [364] [04043880] [121] [1]
[TX ] [120] [04043A20] [28] [1]
[DATA] [4] [05FB9D30] [0] [1]
[OB ] [848] [0409C970] [113] [1]
[DATA] [120] [04044488] [54] [6]
[DNA1] [44572] [06023F70] [0] [1]
[ENDB] [0] [00000000] [0] [0]
========================================================
File name: simeplebox.blend
File version: 2.49
File size: 126892
Blocks: 412
|
are these lots of data blocks the data from (for example) the [SR] block?
Posted: Mon Feb 13, 2012 11:51 am
Joined: 07 Nov 2010
Posts: 544