[Radiance-general] Python Radiance Package

David Smith dbs176 at gmail.com
Sat Nov 6 11:59:41 PDT 2010


Dear Radiance community,

Does anybody have any interest in a generic Radiance wrapper package for
Python? I think I'm going to make one (and make it open source), and was
wondering if anybody had any interest, suggestions, advice, code they would
be willing to contribute, etc. I'm aiming for a 1:1 functionality but I know
there are going to be some things that will be tough/impossible to do.

I made what I think a simple program could be like below - it imports
geometry, creates a series of images, manipulates and combines those images,
then saves them.

The benefits of this are the flexibility of working within a higher level
scripting language. You open up the possibility of scripting complex
problems, parameteric geometry, iterative solutions, and ultimately,
adaptive design. This comes at the slight disadvantage of speed and the
flexibility of pipes, etc.

Why Python? I know it isn't as revered or speedy as C or Perl, but it has a
very simple syntax and a lot of the 3rd party tools as of late seem to be
written in Python. It's also available on all platforms and in some modeling
packages such as Rhino 5, Max (Py3dsMax), Blender, etc.

Ultimately, it could be the engine behind an OpenDX / Grasshopper like GUI
for Radiance. I'll leave that up to someone else though.

So, yeah. Any interest?

--Dave

P.S. - I posted here because it's not directly related to the Radiance code,
it would be just calling the Radiance programs and scripts. It's possible to
loop in C code, but I think keeping it separate and modularized is better
practice.






# Python Radiance

# Package would be called Radiance
from Radiance import rpict, obj2rad, HDRImage, RADGeometry, RadianceOptions,
ImportOBJGeometry, ViewFile, CompiledGeometry

ltg_zone1 = RADGeometry("ltg_zone1.rad")
ltg_zone2 = RADGeometry("ltg_zone2.rad")

#these would be equivalent
scene = ImportOBJGeometry("base_geometry.obj")
scene = RADGeometry(obj2rad("base_geometry.obj"))

view1 = ViewFile("view1.vf")

zone1 = CompiledGeometry(scene, ltg_zone1)
zone2 = CompiledGeometry(scene, ltg_zone2)
zone1and2 = CompiledGeometry(zone1, ltg_zone2) #add to an existing octree

opt_hq = RadianceOptions("hq.opt")

hdr_zone1 = rpict(zone1, ab=3, ad=256, ps=1, vf=view1)
hdr_zone2 = rpict(zone2, ab=3, ad=256, ps=1, vf=view1)
hdr_all = rpict(zone1and2, opt_hq, vf=view1)

from somewhere import specialrpictfunction
#this could be a function that you write that analyzes over the course of a
year or special post processing, etc.
hdr_special = specialrpictfunction(zone1and2)

hdr_scene1 = (0.6 * hdr_zone1) + (0.4 * hdr_zone2)
hdr_scene2 = (0.9 * hdr_zone1)
hdr_scene3 = (0.2 * hdr_zone1) + (hdr_zone2)

hdr_scene1.save("img1.hdr")
hdr_scene2.save("img2.hdr")
hdr_scene3.save("img3.hdr")

hdr_all.save("img4.hdr")
hdr_special.save("img5.hdr")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://radiance-online.org/pipermail/radiance-general/attachments/20101106/4f029160/attachment.htm


More information about the Radiance-general mailing list