[Bf-committers] extending Blender (Re: What documents should I read in order to embedblender?)

Toni Alatalo antont at kyperjokki.fi
Thu Apr 23 13:47:47 CEST 2009


Ã÷ÓX kirjoitti:
> 2009/4/23 Wael EL ORAIBY <wael.eloraiby at gmail.com>:
>   
>> I would advise you to do it the other way around: embed your code into
>> blender! I think it's better. If not, there are plenty of OSS engine
>>     
> result. So this is program mainly used in mechanical field, it's not
> possible to make blender contain those mechanical analysis code,
>   

It is possible to make Blender 'contain' any code.

Blender is an application, not a set of libraries for other applications
to use -- the embedding you originally thought about would probably be
possible to hack somehow, but much easier would indeed be to make your
application to be added functionality within Blender itself. The
existing things in Blender, like the 3d modelling or the sequencer
(video) editor, are in a way already independent applications on top of
the common base (which gives them the database, UI tools etc).

A way to add functionality to Blender is using the Python API. That has
been limited with regard to e.g. UI, but as a part of the 2.5 work that
has been made better so that tools that register to Blender via py
should be able to integrate to the normal UI in the same way as the
default c written tools are. I don't personally know the status nor the
details of that there yet, but am looking forward to benefitting from
that myself for own custom tools.

You mention wanting to use the C language. If it is for performance, one
thing you can do is to implement the processing things in C, and add a
py api to that so your library can be called from the Python running on
the Blender side. It's pretty straightforward. If the reason for wanting
to use C is because that's what you know well from before, it doesn't
hurt to give Python a chance too 'cause it wont take you many hours to
test something with it.

Another way is to write your own code in C similarily to how the builtin
'applications' in Blender are, define your own spacetype etc if that's
how you wish to do the UI. There is no separate C API for that though,
AFAIK not in 2.5 either, so I'm afraid that would mean having to
maintain your own fork of Blender if you wan't to distribute it to
others too. Via the py API your own code could be used with the
unmodified Blender.

Feasibility of these approaches depend on the exact functionality that
you need (e.g. the UI, data storage etc), but many things are certainly
possible.

~Toni


More information about the Bf-committers mailing list