Commit Graph

2262 Commits

Author SHA1 Message Date
c77e556b23 - missing a decref for new pytypes
- remove needless strlen
2009-08-11 19:20:31 +00:00
b2a77852ff user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.

* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil

* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 18:53:01 +00:00
1d63cacfe4 fixed mistake made when changing rna prop definition functions, made povray custom props fail. 2009-08-11 02:27:25 +00:00
f6682ab773 RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
  mass, rotation, time, velocity, acceleration). These are not used
  yet anywhere.
* Centralized code that decides the name of array items based on
  subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
  later together with another change.
2009-08-10 21:31:05 +00:00
a27cc1adf0 2.5 audio cleanup:
* Removed CD Actuator
* Removed bSample and bSoundListener
* Removed SoundSystem
* Removed -noaudio parameter
2009-08-10 15:39:11 +00:00
cb9e51bf8a missing include for fluid 2009-08-10 14:15:05 +00:00
6c951fbb98 adding back button evaluation so you can do 1/60, 90*0.1 etc as well as dimension conversion 1km-10cm+4ft
Note...
- Python3.1 you don't need to add the .0 for divisions anymore (was esp annoying for button eval)
- Simple dimension input, imperial mi/yd/ft/in, metric km/m/cm/mm,  Later could display these values and have a pref for scene scale, atm it assumes 1BU == 1m.
2009-08-10 11:58:53 +00:00
7084be920a fix for build problem with audiospace and implicit declaration. 2009-08-10 04:50:48 +00:00
de759dd278 Wrap message with " as the ' was giving issues. 2009-08-10 02:07:34 +00:00
7440fee85c remove python2.x support 2009-08-10 00:07:34 +00:00
2a408c864f - fix error in last commit
- added better error feedback when registering operators fails.
- added some python benchmark timers (prints on exit), times number of times py scripts run, average time and total % of time running py scripts.
2009-08-09 13:20:12 +00:00
a4755dcf2b - report errors on rna name collisions (does not check parent type yet)
- minor cleanup for Py/C api functions that define rna properties from python.
2009-08-09 10:05:33 +00:00
70f011bbce bpy_context_set and bpy_context_clear to replace a number of functions (some were not always called causing bugs).
fix for a leak when trying to run a text with a syntax error too.
2009-08-07 16:20:19 +00:00
2a727083c9 fix for warnings and implicit declarations
also fixed smoke comparing a float's mem-location rather then its value.
2009-07-31 01:40:15 +00:00
39ea55fff1 Operator Copy/Paste
you can copy operator strings from buttons or the reporting interface and run them in the console.

- Ctrl+C over an operator button copies its python string to the clipboard.
- Paste in the console (1 line only for now).
- operators run from python no longer require all arguments.
2009-07-30 01:52:00 +00:00
fe881aa7ad - lamp UI was missing y samples for rectangle area lamps
- returned ID types from RNA funcs didnt get their ID's assigned which crashed in some cases (still not working for members of ID types).
- ob.create_remder_mesh() wasnt assigning any materials.
2009-07-28 01:06:56 +00:00
6c0e9e21cb indentation error with some operators (strip the descriptions)
if 0'd the exec() workaround for running python scripts incase windows devs want to test.

theeth said the problem is when you compile a debug blender against a non debug python (or the ther way I assume), you can get a FILE struct mismatch.

A quick way to test this on windows is to run this from the command line.
 blender -P somescript.py
 
Somescript.py can be anything
2009-07-26 18:56:27 +00:00
4741137fc9 misc py/rna changes
- running a script from a file now uses the PyRun_File(FILE *, ...) rather then PyRun_String("exec(open(r'/somepath.py').read())"...), aparently FILE struct on windows could not ensured to be the same between blender and python, since we use our own python on windows now it should be ok.

- generating docs works again (operator update for py style syntax broke them)

- python operator doc strings was being overwritten

- added rna property attribute "default" to get the default value of a property, not working on arrays currently because variable length arrays are not supported.
2009-07-26 18:18:14 +00:00
7508afe25b pyrna,
calling rna functions with the wrong argument type would raise an error like..
 expected a string type

Added an error prefix so now the message is..
 TypeError: UILayout.item_enumO(): error with argument 3, "value" -  expected a string type
2009-07-23 13:48:15 +00:00
b6db4f8e17 Change to avoid trigraph confusions. 2009-07-22 22:12:55 +00:00
413fa4730b less verbose subtyping Py/C API code, use PyObject_CallFunction which supports packing the function args into a string. 2009-07-22 19:50:21 +00:00
1a42f8c77e removing all functions from bpy.ui module, keeping the module incase its useful later.
removed a check in exotic.c that should be added back later.
2009-07-22 10:09:59 +00:00
ffb8ac01a2 remove scriptlinks,
they were not working and we have plans for better script integration in 2.5
2009-07-22 09:41:41 +00:00
6b8dae0874 RNA
* ID blocks can now get RNA properties defined from python, e.g.:
  bpy.types.Scene.BoolProperty(..)
* RNA structs/functions/properties can now get pointers duplicated
  (mostly strings), since we can't point to some static string then.
* Added ExtensionRNA struct to add into *Type structs for subclassing,
  is a bit more compact than defining the 4 variables each time.
  Only disadvantage is it requires including RNA in more places.
2009-07-21 20:05:16 +00:00
0865bf2959 2.5: python module name for import had trailing "." 2009-07-21 10:40:13 +00:00
0ebf23c0b8 BLI_setenv, use instead of copying ifdefs about for setting env vars.
set PYTHONHOME as well as PYTHONPATH, quiets some warnings.
2009-07-21 09:26:28 +00:00
1b7f1bc72d mistake in own recent change, errors with startup scripts didnt raise errors 2009-07-20 20:00:59 +00:00
8bf9a8cb1e Added error prints if the text's main is not set. 2009-07-20 11:30:27 +00:00
4d0a6fee4a cmake option to disable SDL,
bpy_interface.c - change order of checking scripts to avoid calling stat on .py files.
2009-07-20 10:24:53 +00:00
62ffb81316 d_type isnt a member of dirent on win32. 2009-07-19 18:51:25 +00:00
979bec79c3 - Support for importing python packages. (directories of python scripts containing an __init__.py)
- BLI_add_slash returns the new string length.
- BLI_where_am_i() would often have /./ in the path (not incorrect but annoying, got into python exceptions)
- release/ui/space_image.py, py error referencing invalid keyword args.
2009-07-19 17:45:14 +00:00
d410135408 Sculpt+Paint/2.5:
* Moved brush NKEY panel from C to Python. Could use some UI review :)
* Added a NULL check in bpy_internal_import.c, was crashing here on Python errors
* Added RNA for vpaint brush and for weight paint
* Added context for vpaint/wpaint similar to edit_object and sculpt_object
2009-07-19 17:44:44 +00:00
d9a7e5144f Python operators
- simplified C operator API bpy.__ops__ since its wrapped by python now.
- needs the class to have an __idname__ rather then __name__ (like menus, headers)
- convert python names "console.exec" into blender names "CONSOLE_OT_exec" when registering (store the blender name as class.__idname_bl__, users scripters wont notice)
- bpy.props.props ???, removed
2009-07-19 13:32:02 +00:00
1917e951ca py rna arrays were assumed sizeof(char)*len, should be sizeof(int)*len, was causing end of array corruption errors when running operators that took bool array options - transform. 2009-07-19 09:33:27 +00:00
119844eb23 fixes for errors on startup and compiler errors and draw speedup.
* Drawing the console text now skips all lines outside the view bounds.

* Added dummy C operators for console.exec and console.autocomplete so blender wont complain at startup, its not really a problem but people testing reported it a few times. Eventually we should have some way python operators are initialized before the spaces operators are checked.

* reordered the imports so the "ui" dir is imported before "io", for now this means bpy.ops is defined before exporters and importers need to use it, was causing a python error on startup.

* fixed all compiler warnings for the console (gcc4.4)

* stopped operators were printing out the return flag.

* removed references to ACT_OT_test, TEXT_OT_console_exec and TEXT_OT_console_autocomplete
2009-07-18 16:27:25 +00:00
4fb20358e4 Source code with executable property, manual fix. *sigh* 2009-07-17 18:35:49 +00:00
a705f64245 python access to operators now hides the _OT_ syntax, eg. SOME_OT_operator -> some.operator
this works for the calling operators from python and using the RNA api.

bpy.ops.CONSOLE_exec() is now bpy.ops.console.exec()

eg.
split.itemO("PARTICLE_OT_editable_set", text="Free Edit") becomes... split.itemO("particle.editable_set", text="Free Edit")

For now any operator thats called checks if its missing _OT_ and assumes its python syntax and converts it before doing the lookup.

bpy.ops is a python class in release/ui/bpy_ops.py which does the fake submodules and conversion, the C operator api is at bpy.__ops__

personally Id still rather rename C id-names not to contain the _OT_ text which would avoid the conversion, its called a lot since the UI has to convert the operators.
2009-07-17 12:26:40 +00:00
70f6255433 bpy rna
Calling rna functions with invalid keywords, too many keywords and too many args would fail silently
- now raise an error with invalid keywords and a list of valid ones, raise an error when too many args are given.
- calling rna functions would alloc a ParameterList each time, changed to use a stack variable (2 pointers and an int).
- store the number of parameters ParameterList
- python exception types were wrong in many cases, (using attribute error rather then type error)
- fixes to small errors in python UI scripts.
2009-07-17 02:31:28 +00:00
Nathan Letwory
2e854ec7cf SCons
* ensure all SConscripts are ready for win64-vc (where necessary).
* ensure we have proper _DEBUG flag for Python when we're doing a debug build.
* some cleaning up of linking etc.
* ensure /EHsc is there for game engine modules.
2009-07-16 19:41:28 +00:00
88e3e8c1c9 - use outliner colors (with subtle stripes) for report so you can see divisions between operators with wrapping.
- added class option for PyOperators __register__ so you can set if py operators are logged in the console.
- PyOperators was refcounting in a more readable but incorrect way. in some cases would be possible to crash so better not drop the reference before using the value.
- console zoom operator was registering which meant zooming in to see some text would push it away :)
2009-07-16 07:11:46 +00:00
2f74b5a260 Console Space Type
* interactive console python console.
* display reports and filter types. defaults to operator display so you can see the python commands for tools as you use them,
  eventually it should be possible to select commands and make macto/tools from them.

Example use of autocomp.  b<tab>, bpy.<tab>, bpy.<tab>, bpy.data.<tab> etc.

basic instructions are printed when opening the console.

Details...
* Console exec and autocomp are done with operators written in python.
* added CTX_wm_reports() to get the global report list.
* The window manager had a report ListBase but reports have their own struct, switched to allocate and assign when initializing the WM since the type is not available in DNA.
* changed report types flags for easier display filtering.
* added report type RPT_OPERATOR
* logging operators also adds a python-syntax report into CTX_wm_reports() so they can be displayed in the console as well as calling a notifier for console to redraw.
* RnaAPI context.area.tag_redraw() to redraw the current area from a python operator.

Todo...
* better interactions with the console, scrolling, copy/paste.
* the text displayed doesnt load back.
* colors need to be themed.
* scroll limit needs to be a user pref.
* only tested with cmake and scons.
2009-07-16 00:50:27 +00:00
2ba8b72157 RNA & PyAPI
* support for dynamic enums to be inspected enumProp.items() from python.
* fix, enums check for a separator was flipped, meant no enums were in docs.
* dynamic enum functions now check for a NULL context and return all possible options for the "items" attribute used for docs.
* added an arg for rna arrays to free the array there looping over (needed to free dynamically allocated enum items)
* python api checks for NULL items since this can happen in some cases.
* python api, When getting an enum ID from an int in an array - If it failed it would get the first enum identifier and return that. Brecht? dont understand, making it return an empty string in these cases.
2009-07-13 19:33:59 +00:00
1227d5d6d3 mathutils types didnt work properly in python2x. vec*matrix failed for eg.
Now with KX_Python.h line 35 commented YoFrankie 1.1 should run unmodified in blender2.5
2009-07-13 12:17:07 +00:00
89830ea0c8 calling operators from python was raising an error without returning an error value.
brecht, switched the order back to fix this, added an argument for WM_operatortype_find() to fail without printing an error.
2009-07-13 08:33:51 +00:00
b1d01dae36 PyApi
* refcount error if StringIO or io modules could not be imported
* importing python modules like math didnt work because the script registration overwrote the script path. now just prepend the path.
2009-07-11 13:57:56 +00:00
2e3e044d27 RNA
* Enums can now be dynamically created in the _itemf callback,
  using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
  for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
  for operators. This doesn't fit design well at all, needed to do
  some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
  _itemf callback, for docs and fallback in case there is no context.

* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
  (unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
64f300ccf4 Use python subtypes so bpy.types.Mesh is a subtype of bpy.types.ID
This means checks like this work.
 isinstance(bpy.data.meshes[0], bpy.types.ID)
 
 bpy.types.Mesh.__base__ == bpy.types.ID
2009-07-10 18:09:53 +00:00
1e85785704 PyRNA api wasnt using python subclasses most of the time.
Now this will return True
 isinstance(bpy.data.meshes[0], bpy.types.Mesh)

Use the StructRNA identifier for the new classes name properties because classes were being named by the data names rather then the type names.

Set the __module__ for the new type which makes printing the class not use the script name where the type is first initialized.
 eg: bpy.types.Mesh instead of buttons_object.Mesh

This still isnt quite right since opertators and panels all get their own type, when they should all use an operator type.
2009-07-10 04:25:49 +00:00
5e659c0b08 2.5
Monthly cleaning round to make it compile warning free.
Mostly it was const stuff (strings, Context), but also
a couple useful fixes, like wrong use of temp pointers.

Only Mathutils callback struct I left alone... design issue.
2009-07-09 15:40:04 +00:00
0d93ad3606 Dictionary style get() to property rna.
eg..
mesh = bpy.data.meshes.get("SomeMesh", fallback)

Set length limits for python string formatting.
2009-07-09 08:06:26 +00:00