「Dev:Ref/Requests/Python2.6」の版間の差分

提供: wiki
移動先: 案内検索
(Removed "Listing all data blocks in another .blend file", since it's already possible, cf http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.BlendDataLibraries.html?highlight=lib)
 
(1版 をインポートしました)
 
(相違点なし)

2018年6月29日 (金) 04:45時点における最新版

UI Elements

Custom Spaces

As stated in the Quick Starter, the ability to create new space types is unavailable "Yet." However if implemented before 2.66 (Here's Hoping), this feature could open up an infinite number of plugin possibilities.

Ugly scaling occurs when designing large interfaces within a ui panel. Which at the moment, is the only way to add complex interface components (correct me if I am wrong)

For example, if a panel implementation resides withing one of the two 3D viewport sidebars. Scaling a sidebar to adequately display a large custom panel, scales all other ui widgets.. which may not look appealing.

Instancing a separate space can keep Blenders default panels intact, while adding extra functionality.

Such as a "Character Picker" (An application that allows an animator to select rig controls outside of the 3D viewport)

--raschko 18 December 2012

Group/Object Hierarchy

When creating a model it would be nice to organise the individual objects/meshes that make up parts of the model in a hierarchical manner.

Example: A remote control may be made from the following visible components:

  • Rear housing (object)
    • Mesh
  • Front housing (object)
    • Mesh
  • Buttons (group)
    • Button 1 (object)
      • Mesh
    • Button 2 (object)
      • Mesh
    • Button 3 (object)
      • Mesh
  • IR LED (object)
    • Mesh
  • Battery cover (object)
    • Mesh

Currently Blender grouping allows adding the same object to multiple groups, but with no hierachy.

A solution to this problem would be to add a way of creating sub objects/meshes that are displayed logically in the outliner panel.

Selecting the higher level objects in the outliner panel should select all of the sub objects.

In my opinion a great way of displaying this would be similar to the following image from Adobe Photoshop: http://i43.tinypic.com/11ky4b9.png

Collapsible folders for each sub group

This view should be visible from the current scene and all scenes view of the outliner panel. Not just when you go into groups.

An option to link objects/meshes so that moving/scaling/rotating ANY of the objects in that group moves/scales/rotates all of the other objects. Similar to making an object a parent, but instead making the currently active object become the parent for that specific time (dynamic parenting?).

Another option would be to have a single object with multiple individually selectable meshes, again with some sort of hierarchy.

This hierarchical group of objects/meshes should remain intact when appending or linking to another Blender file.

--Mattb5906 09:22, 28 April 2012

Animation Events

Proposal for a non-hackish way to call Python code once per frame of an animation. Some scenarios that would accomplish this task include:

  1. Instantiate an object once per animation and then execute a method on that object once per frame.
  2. Execute an arbitrary function once per frame.

In both cases, variable values would have to be maintained across frames. For example, it should be possible to increment a counter from 0 to 30 for one second of animation at 30 frames per second.

Graph Editor

The implementation could be exposed through the Graph Editor. In addition to the View Properties, Active F-Curve, Active Keyframe, and Modifiers panels, there could be another panel named "Execution", "Function Call", "Animation Event", "Frame Hook", or similar.

User Interface

The first implementation could be simple: a single input field with the name of a function that is called once before every frame is rendered.

Subsequent implementations could add the following features:

  • Call a different function based on different IPO curves.
  • Include a start frame and an end frame.
  • Ability to skip frames.

The last two items could also be done programmatically using a counter within the function; a UI makes it cleaner.

Documentation

There are clever hacks to accomplish this, but these hacks rely on behaviours that might change between versions of Blender, which would mean the Blender file is not upwards compatible.

The current documentation does not describe a way to add a hook for animations. If such documentation exists, it needs to be clarified.

Example

In the code below, a few things happen:

  1. The date and time are incremented once per frame to simulate a long journey (sped up to be watchable).
  2. The sphere (representing a planet) is scaled using an apparent distance and apparent size calculation.
  3. Each frame is incremented and then rendered.
  4. A file name is generated.
  5. The render is saved to a file.

The last three steps are redundant: clicking the "Animation" button in Blender causes them to happen. Without any obvious animation frame event handler function override, the final three steps must be hand-coded. The results from the code below can be viewed at:

http://www.youtube.com/watch?v=xGy3ngTDne4

   PLANET_NAME      = "Saturn"
   PLANET_RADIUS    = RADIUS_SATURN
   PLANET_DISTANCE  = DISTANCE_SATURN
   PLANET_OBLATE    = OBLATE_SATURN
   CAMERA_DISTANCE  = PLANET_RADIUS * 2
   
   TRAVEL_FRAMES        = TRAVEL_FRAMES_SATURN
   TRAVEL_DURATION_DAYS = TRAVEL_DURATION_DAYS_SATURN
   
   RENDER = True
   WARP = True
   
   def render_animation():
       global current_frame
       global current_datetime
   
       distance = PLANET_DISTANCE
       scale = 0
   
       # No planet in the initial frame for travelling.
       #
       if WARP: scale_planet( PLANET_NAME, scale )
   
       while current_frame <= bpy.context.scene.frame_end:
           bpy.ops.anim.change_frame( frame=current_frame )
           print( current_frame, ' ', current_datetime )
           update_text()
           render_frame()
           current_frame = current_frame + 1
   
           distance -= DISTANCE_PER_FRAME
           scale = scale_factor( PLANET_RADIUS, distance + CAMERA_DISTANCE * 2 )
   
           print( "Distance: " , distance, " Scale: ", scale )
   
           # Travel to the planet by scaling it up using its apparent size.
           #
           if WARP:
               if distance > 0: scale_planet( PLANET_NAME, scale )
   
               current_datetime = current_datetime + datetime.timedelta( seconds=SECONDS_PER_FRAME )
           else:
               current_datetime = current_datetime + datetime.timedelta( milliseconds=round( 1000/30 ) )

The actions that Blender cannot do include:

  • update_text() - sets the date and time
  • scale_planet() - change the radius of the sphere to the apparent size

These must be called once per frame, and, to my knowledge, cannot easily be accomplished any other way.

Thangalin 23:46, 26 July 2011 (CEST)


Proposal mesh.screw turns

bpy.ops.mesh.screw(steps=9, turns=1, center=(0, 0, 0), axis=(0, 0, 0))
bpy.ops.mesh.spin(steps=9, dupli=False, angle=1.5708, center=(0, 0, 0), axis=(0, 0, 0))

Change mesh.screw 'turns' from an Int to a Float property. so its the same as mesh.spin 'angle'.

At the moment, turns is limited to 360's.

Or change it to a Float angle.

mesh.spin 'angle' is a radian.

editmesh_tools.c

Regards, Koilz 15 March 2013


View linked objects

there should be an option under "view" to "view Linked" things from the selected entry inside the outliner, it could be like the old "Oops Schematic view" or a treeview.

Sonicdee 21 March 2013


Generic Template List Operators

Template Lists require a collection property id and a int property id for the active index. When making a custom template list with a new collection property, usually people write a set of operators to, add, remove, move up, and move down, items in the list.

There is not much unique about these operators, they work based on the number of items in the collection property and the active index. They are usually drawn after the template list.

    def draw(self, context):

        layout = self.layout

        row = layout.row()
        row.template_list("SCENE_UL_draw", "", context.scene, "UL_props", context.scene, "UL_active", rows=3)

        col = row.column(align=True)
        col.operator("scene.ul_add", text="", icon="ZOOMIN")
        col.operator("scene.ul_remove", text="", icon="ZOOMOUT")

        col.separator()
        col.operator('scene.ul_moveup', text='', icon='TRIA_UP')
        col.operator('scene.ul_movedown', text='', icon='TRIA_DOWN')

A generic set of operators could be written, that point to a custom collection and int property, UL_props, UL_active. Then the template list (and other blender template lists that may use them) would not require an additional set of operators.

2 use examples.

    def draw(self, context):

        layout = self.layout

        row = layout.row()
        row.template_list("SCENE_UL_draw", "", context.scene, "UL_props", context.scene, "UL_active", rows=3, generic_buttons=True)
    def draw(self, context):

        layout = self.layout

        row = layout.row()
        row.template_list("SCENE_UL_draw", "", context.scene, "UL_props", context.scene, "UL_active", rows=3)

        col = row.column(align=True)
        xx = col.operator("ui.ul_add", text="", icon="ZOOMIN")
        xx.collection_prop_path=context.scene
        xx.collection_prop="UL_props"
        xx.index_prop_path=context.scene
        xx.index_prop="UL_active"

        # remove
        # specials menu
        # move up
        # move down

Koilz 5 April 2014