Giter VIP home page Giter VIP logo

miklobit / blend_stats Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codemanx/blend_stats

0.0 2.0 0.0 768 KB

A PHP script that shell-executes Blender 3D in background mode and lets a Python script run to fetch Scene statistics. The Python script exchanges the data by writing a start and a stop marker to the shell, and in between a JSON structure that is extracted and parsed by PHP to an associative array.

License: Other

PHP 48.51% Python 49.71% Batchfile 1.78%

blend_stats's Introduction

Blend Stats for PHP

This is a small class/lib for PHP which lets users read file stats from blend files using blender through the command line interface for usage in blender related sites.

Blend Stats calls the Blender binary in your system path and then executes a python script which retrieves some basic stats from the passed file.

Usage:

<?php

// include the lib
include '/path/to/blend_stats.php';

// INSTANTIATE
// pass blend location immediately [*]
$bst = new BlendStats( '/path/to/blend/file.blend' );

// get the stats
$bst->get_stats();

// use the stats
foreach ( $bst->stats->scenes as $scene ) {
    echo $scene->name;
}

// Save to database? Save to File? Whatever you have to do.

?>

Output Structure:

BlendStats::get_stats(); returns an object containing two arrays:

<?php 
object(stdClass) {
    bad_images => array(
        // Contains paths to broken links
        )
    scenes => array(
        (int) 0 => object(stdClass) {
            name => 'Scene'
            objects_mesh => (int) 7
            polygons => (int) 5834
            polygons_modified => (int) 16539
            render_engine => 'CYCLES'
            triangles => (int) 32262
            verts => (int) 5754
            verts_modified => (int) 16675
        },
        (int) 1 => object(stdClass) {
            name => 'Scene.001'
            objects_mesh => (int) 0
            polygons => (int) 0
            polygons_modified => (int) 0
            render_engine => 'BLENDER_RENDER'
            triangles => (int) 0
            verts => (int) 0
            verts_modified => (int) 0
        }
    )
}

?>

Notes:

You will need Blender installed on your website's server, this means that you'll need a dedicated server where you can install software on your own in order to use this lib effectively with PHP. (this lib might be modified in the future to make direct from PHP reads possible, but until then blender is a requirement/dependency).

This lib is rather slow, and you might need a lot of RAM on your server to run Blender from the cli as this lib requires it with acceptable performance.

[*] There's a second argument for the constructor with which the Blender binary call is passed; it defaults to 'blender' and works just fine if you have Blender in your System PATH so this arg is optional. If for some reason you can't have Blender added to your System PATH var, then you should pass the path to your local Blender binary in the second parameter of the constructor; for example:

<?php 

// ON WINDOWS:
$bst = new BlendStats('C:\\path\\to\\file.blend', 'C:\\path\\to\\blender\\blender');

// ON POSIX 
// normally in /usr/local/bin/blender 
// when compiled with WITH_PORTABLE=OFF
$bst = new BlendStats('/path/to/file.blend', '/usr/local/bin/blender');

?>

License

This software is provided as is, without any warranty of any kind, if you mess up your server by using this library it's your responsibility to solve it. We do not provide support for this tool, and we will puclish updates only when we need them.

You are welcome to contribute to this software with customizations and

blend_stats's People

Contributors

thefotolander avatar codemanx avatar

Watchers

James Cloos avatar MK avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.