Tornavís Project

Tornavís logo

Motivation

Most of engineering software is proprietary and only a few companies are developing it. Using it professionally is linked to paid licenses.

Tornavís is a project that aims to give mechanical engineering and design tools to a really awesome piece of software. It's not conceibed as product, it's project developing a set of enhancements for Blender.

Also it wil try to not adding dependencies, as dependencies can add layers of complexity, maybe including more things than needed, and they need to be updated regularly because issues may occur due to upgrades (in both sides), specially if not upgraded, or not available any more. Also having all tools integrated in a single software is great specially if you want to re-use data/information from closed/past projects

About Name

Tornavís it's a catalan word for screw-driver. It's a common tool used during assembly of things that could be designed in CAD software.

Current Status

At this moment, the Tornavís project is on early stage development. Do not expect something functional, and some developer acknowledgements could be required to apply patches and build Blender, although some tests builds could be available.

Roadmap

Although I had some Blender acknowledgement, it's important to learn how Blender it self works, UI, and procedures. The development should fit inside current Blender procedures.

At this early stage, we focus on get past development works, and improve documentation and feedback.

Collaboration

Give some Money

Development is time, and time is money. Time and resources are limited, so if you want this project to be speed up you can collaborate, so more time and resource could be assigned. You can contribute directly or via Patreon or via Paypal.

Dedication is listed on Activity.

As this project would not exist without Blender and it's foundation, 30% of incomes will be donated to Blender development Fund.

Targets

Targeted development is welcome. The only requirements are

If needed, an invoice can be emitted. Contact here for more info.

Contributions

Also you can also contribute with code, proposals, or just feedback.

License

The license of the code and usage is the same as Blender. It comes with no warranties.

Documentation

This chapter considers that all patches have applied. The documentation found here is User Documentation, no links or references are set to development decisions. They are available on Development Notes

Learn Blender

This should be the case when you get here and do not have any previous Blender's acknowledgements.

Blender Manual

The Blender Manual is the place were you should go for specific Blender questions.

Blender Video Tutorials

There is a lot of video tutorials freely available.

Blender Guru

Blender Beginner Tutorial

It gives a good background to get a general idea about procedures, although some maybe not be interesting for your targets, it's good to have a general idea of what can be done.

Command line options

Tornavís info

Tornavís info can be displayed on terminal, at Blender start, when adding --tornavis-info at command line.

D:\WORK\MBLEND\blender-git\blender>..\build_windows_Lite_x64_vc16_Debug\bin\Debug\blender.exe --tornavis-info
Color management: using fallback mode for management
Read prefs: "C:\Users\jaume\AppData\Roaming\Blender Foundation\Blender\4.1\config\userpref.blend"
Color management: scene view "AgX" not found, setting default "Standard".
Vendor: ATI Technologies Inc.
Renderer: AMD Radeon(TM) Vega 8 Graphics
Version: 4.5.13497 Core Profile Context 23.20.840.0
Context Version: 4.5
Vendor: ATI Technologies Inc.
Renderer: AMD Radeon(TM) Vega 8 Graphics
Version: 4.5.13497 Core Profile Context 23.20.840.0
Context Version: 4.5
Tornavis Info
---------------------
Applied Patch MB_0008
---------------------
Saved session recovery to "C:\Users\jaume\AppData\Local\Temp\quit.blend"

UI

Branding

Splash Screen

The Splash Screen contains a link to Tornavis' website, and a "Tornavis Project" label.

splash screen

Help

A link to this documentation is available on Help menu on Blender's top bar.

help menu

About Tornavís Splash

More links and info on the project is available on a splash windows, accessed from Blender Menu on top bar.

Tornavís Splash

Transform

Tornavís includes some improvements while transforming geometry or objects. This applies to move, scale, rotate.

Repeat Operator

While transform, the current operator can be executed again once finished, pressing the M Key. This is different on executing Last Operator (SHIFT+R) because new input is needed.

The video does not show keyboard input during a modal operation see issue on ScreenCast. On first execution, M_KEY is pressed while executing the operator.

No modal

This is possible on Blender using the ALT key while transform. The procedure covered here is likely to be removed.

While transform, there may be a need to change the scene position. This can be achieved pressing N-key, which stops the modal transform and allows scene movement. Once ok, pressing it again continues the transform operation.

In the current version, the key must be set manually on Blender Preferences window. It should be set to N-Key.

The following video shows how can be used to snap to a hidden part of the object. Alternative there should be enabling X-Ray

The video does not show keyboard input during a modal operation see issue on ScreenCast. N_KEY is pressed to enable / disable modal mouse events.

The following video shows how can be used to snap to a really small object.

Available on Youtube. The video does not show keyboard input during a modal operation see issue on ScreenCast. N_KEY is pressed to enable / disable modal mouse events.

User Cordinates Systems

The user cordiantes systems, are an ampliation over Transform Orientations.

Use of Custom Transform Orientation when creating data

When a Custom Transform Orientation is selected, the data is created using it. This is not the behaviour on bf-blender.

Transform Orientation Origin

Each custom transform Orientation has an origin, that is the origen of the UCS.

Using the UCS

Python

Some part of code can be accessed via Python. This part of documentations is intended for users that want to use added functionality via Python Script.

Open Tornavís' website on default browser

# Opens https://www.tornavis.org
bpy.ops.wm.url_open_preset(type='TORNAVIS')
# Opens https://www.tornavis.org/#documentation
bpy.ops.wm.url_open_preset(type='TORNAVIS_DOC')

Get Tornavís applied patches over source

This makes possible to check if Blender's code get the changes from an specific patch.

>>> bpy.app.tornavis.patches
['MB_0008']
import bpy


def register():
    if not hasattr(bpy.app, "tornavis"):
        print ("ERROR: bpy.app.tornavis not found!")
        return

    if not "MB_0008" in bpy.app.tornavis.patches:
        print ("Error MB-0008 is not applied on sources")
        return

    # Code using patch functions
    print ("hi!")

if __name__ ==  "__main__":
    register();

Blender API Improvements

Add a menu option referenced

An option menu can be placed referenced to other menu labels, before or after. This allows to insert options in a logic place, not just at the end of menu.

Example file: mb-0009-addon-menu-references.blend.

import bpy


class CustomMenu(bpy.types.Menu):
    bl_label = "Custom Menu"
    bl_idname = "OBJECT_MT_custom_menu"

    def draw(self, context):
        layout = self.layout

        layout.label(text="Hello world!")

def draw_item(self, context):
    layout = self.layout
    layout.menu(CustomMenu.bl_idname)

bpy.utils.register_class(CustomMenu)

# Add ourselves to menus
bpy.types.TOPBAR_MT_file.append(draw_item, label_referenced = "Open")
bpy.types.TOPBAR_MT_file.prepend(draw_item, label_referenced = "Open")
bpy.types.VIEW3D_MT_object_context_menu.append(draw_item, label_referenced= "Paste Objects")
bpy.types.VIEW3D_MT_edit_mesh_delete.append(draw_item, label_referenced ="Delete")  #this is a Enum
bpy.types.VIEW3D_MT_edit_mesh_delete.append(draw_item, label_referenced ="Fail Test")  #this will fail

If you want to know the label, this is shown on terminal, using

bpy.types.VIEW3D_MT_edit_mesh_delete.reference_debug = True

Operator handlers

Addons can execute functions over operators. Currently can

Example file mb-0011-Operator-handlers.blend

import bpy

#custom bpy operators
class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        return {'FINISHED'}

bpy.utils.register_class(SimpleOperator)


# Any Python object can act as the handler owner.
owner = object()

# Poll
def handler_poll_true(context, event, params):
    return True

def handler_poll_false(context, event, params):
    return False

def handler_poll(context, event, params, arg):
    return arg == True

# Callbacks
def pre_invoke_callback(context, event, params):
    print("[PRE] invoke", params)
def post_invoke_callback(context, event, params, ret_code):
    print("[POST] invoke", params, "returned", ret_code)

def pre_invoke_callback_owner(context, event, params):
    print("[PRE] invoke (with owner)", params)
def post_invoke_callback_owner(context, event, params, ret_code):
    print("[POST] invoke (with owner)", params, "returned", ret_code)

def pre_invoke_callback_args(context, event, params, args):
    print("[PRE] invoke args", args, params)
def post_invoke_callback_args(context, event, params, ret_code, args):
    print("[POST] invoke args", params, "returned", ret_code, "args", args)

def pre_invoke_callback_owner_args(context, event, params, args):
    print("[PRE] invoke (with owner) args:", args, params)
def post_invoke_callback_owner_args(ctx, evt, params, ret_code, args):
    print("[POST] invoke (with owner)", params , "returned", ret_code, "args:", args)

def pre_invoke_callback_override(context, event, params):
    print ("Overrided")
    return False


def modal_callback(context, event, params, ret_code):
    print (context.active_object)
    print (event)
    print ("modal")

def modal_callback_args(context, event, params, ret_code, args):
    print (context.active_object)
    print (event.mouse_x, event.mouse_y)
    print ("modal", args)

def modal_end_callback(context, event, params, ret_code):
    print("modal end", ret_code)

def pre_invoke_custom_op_callback(context, event, params):
    print("[PRE] invoke custom operator", params )
def post_invoke_custom_op_callback(context, event, params, ret_code):
    print("[POST] invoke custom operator", params, ret_code)

# Registration
bpy.ops.mesh.primitive_cube_add.handlers.invoke_pre.append(pre_invoke_callback)
bpy.ops.mesh.primitive_cube_add.handlers.invoke_post.append(post_invoke_callback)

bpy.ops.mesh.primitive_cube_add.handlers.invoke_pre.append(cb=pre_invoke_callback_args, poll = handler_poll, args=(False,))
bpy.ops.mesh.primitive_cube_add.handlers.invoke_post.append(cb=post_invoke_callback_args, args=(1,))

bpy.ops.mesh.primitive_cube_add.handlers.invoke_pre.append(pre_invoke_callback_owner, owner)
bpy.ops.mesh.primitive_cube_add.handlers.invoke_post.append(post_invoke_callback_owner, owner)

bpy.ops.mesh.primitive_cube_add.handlers.invoke_pre.append(pre_invoke_callback_owner_args, owner,(1,))
bpy.ops.mesh.primitive_cube_add.handlers.invoke_post.append(post_invoke_callback_owner_args, owner,(1,))

bpy.ops.object.simple_operator.handlers.invoke_pre.append(pre_invoke_custom_op_callback)
bpy.ops.object.simple_operator.handlers.invoke_post.append(post_invoke_custom_op_callback)

#Showing the splash will not print "overrided" and do anything
bpy.ops.wm.splash.handlers.invoke_pre.append(pre_invoke_callback_override)


# Unregistration
# Remove one handler from pre_invoke
bpy.ops.mesh.primitive_cube_add.handlers.invoke_pre.remove(pre_invoke_callback)
#remove all handlers from post_invoke owned
bpy.ops.mesh.primitive_cube_add.handlers.invoke_post.remove(owner=owner)

# Remove all handlers owned
bpy.ops.remove_handlers(owner=owner)

# calling the MESH_OT_primitive_cube_add operator should output
"""
[POST] invoke {'size': 2.0, 'calc_uvs': False, 'enter_editmode': True, 'align': 0, 'location': (0.0, 0.0, 0.0), 'rotation': (0.0, 0.0, 0.0), 'scale': (1.0, 1.0, 1.0)} returned {'FINISHED'}
[POST] invoke args {'size': 2.0, 'calc_uvs': False, 'enter_editmode': True, 'align': 0, 'location': (0.0, 0.0, 0.0), 'rotation': (0.0, 0.0, 0.0), 'scale': (1.0, 1.0, 1.0)} returned {'FINISHED'} args 1
"""
# calling the OBJECT_OT_simple_operator()
# bpy.ops.object.simple_operator()
"""
[PRE] invoke custom operator {}
[POST] invoke custom operator {'FINISHED'}
"""

bpy.ops.transform.translate.handlers.modal.append(cb = modal_callback_args, args = (1,))
bpy.ops.transform.translate.handlers.modal.append(cb= modal_callback, poll = handler_poll_false)
bpy.ops.transform.translate.handlers.modal_end.append(modal_end_callback)

# Moving an object should output
"""
<bpy_struct, Object("Cube.001") at 0x0000028E8F0D7E08>
246 572
modal 1
...
modal end {'FINISHED'}
"""

def selection_cb(context, event, params,ret):
    print("SELECT", params, ret)

bpy.ops.view3d.select.handlers.invoke_post.append(selection_cb)

# Click on 3D view should output
"""
SELECT {'extend': True, 'deselect': True, 'toggle': True, 'deselect_all': False, 'center': True, 'enumerate': True, 'object': True, 'location': (222, 123)} {'PASS_THROUGH', 'FINISHED'}
"""

Show custom splash

Addons can show a custom splash with some addon information.

Example file mb-0012-custom-splash.blend

import bpy

class WM_MT_splash_about_me(bpy.types.Menu):
    bl_label = 'About Me'

    def draw(self, context):
        self.layout.label(text='About Me')

def draw_menu(self, context):
    self.layout.operator("wm.splash_custom", text='About me').menutype='WM_MT_splash_about_me'

def register():
    bpy.utils.register_class(WM_MT_splash_about_me)
    bpy.types.TOPBAR_MT_blender.append(draw_menu)

def unregister():
    bpy.types.INFO_HT_header.remove(draw_menu)
    bpy.utils.unregister_class(WM_MT_splash_about_me)

if __name__ == "__main__":
    register()

# Selecting "About Me" on Blender Icon on top bar shows a simple splash

custom splash_example

bpy Images

From python images can be loaded, so could be used for any purpose, not related to blender data, eg showing it on ui.

Functions are available under bpy.utils.images Python module

import os
import bpy
import bpy.utils.images

img = None

def register(): 
    global img
    # Set path to an existing file        
    path = os.path.join(os.path.dirname(bpy.app.binary_path), 'image.png')
    img = bpy.utils.images.load('my_image', path)

def unregister():
    global img
    if img != None:
        bpy.utils.images.release(img['id'])   


if __name__ == "__main__":
    register()

A current list of loaded images is available on bpy.utils.images.list

>>> bpy.utils.images.list
[{
    'id': 1, 
    'name': 'my_image', 
    'path': 'D:\\WORK\\MBLEND\\blender-git\\build_windows_Lite_x64_vc16_Debug\\bin\\Debug\\image.png'
}]

Images on UI

The images loaded using bpy.utils.images can be shown on ui using the template_image_ui layout function.

import os
import bpy
import bpy.utils.images

img = None

class PreviewsExamplePanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Image Example Panel"
    bl_idname = "OBJECT_PT_previews"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        row = self.layout.row()
        row.template_image_ui(image_value = img['id'], scale= 1)

def register():
    global img

    # Set path to an existing file        
    path = os.path.join(os.path.dirname(bpy.app.binary_path), 'image.png')
    img = bpy.utils.images.load('my_image', path)

    bpy.utils.register_class(PreviewsExamplePanel)

def unregister():
    global img
    bpy.utils.unregister_class(PreviewsExamplePanel)
    bpy.utils.images.release(img['id'])   

if __name__ == "__main__":
    register()

Images on UI

Other Useful Projects

BlenderBIM

BlenderBIM it's an Addon for Blender. It's a Free, Opensource, and lets you analyse, create, and modify OpenBIM with Blender.

Sources

Repositories

On Blender

On blender.org projects they are available some pull requests used to try to push things on blender's upstream. Specially the ones that are generic and can benefit the community.

Full sources and development

The development is available here. Due to bots activity and limited resources, all projects hosted there have been set as private. You can request your credentials to developer@tmaq.es.

Patches

Al patches are named as "MB-ID Name". They are developed on a branch with his name, in lowercase and using - as space separator.

All patches will be stored separately from repository, available here. A new version will be created when

For changes including binary data, a .tar file is distributed applied, to be extracted on blender source root.

The patch available on the repository will always be updated when bf-blender sources are merged.

Categories

Build System

Blender Improvements

Branding

Blender API

UCS

Misc

Full List

MB-0001 Operator Repeat

Category: Blender Improvements

Requires:

Allows to execute the same operator, with user input.

History

MB-0002 Readme File

Category: Branding

Modifies README.md file so the content shows info about this project

Branch

History

MB-0005 Splash Changes

Category: Branding

Dependencies:

Adds a link to mechanicablender.org on Blender's splash. Adds "Mechanical Blender" string to window title.

History

MB-0006 Allow No Modal Transform

Category: Blender Improvements

Requires:

Allows to pause transform, move the scene and continue. Will possible be discontinued because this is already possible with Blender using Alt Key

History

MB-0007 Transform Flags

Category: Misc

Required by:

Transform flags added by the required by patches. It does not add any functionality applied alone.

History

MB-0008 Mblender-core

Category: Build System, Misc A Required by:

SAets up folders were specific to Tornavís files will be located.

Adds Tornavís' patches discover functionality.

AAdds Tornavis' command line options

History

MB-0009 Addon Menu References

Category: Blender API

Required by:

Allows to add a menu option referenced to current menu options.

History

MB-0010 URL Presets

Category: Blender API

Requires:

Required by:

Defines url presets related to Tornavís Project

History

MB-0011 Operator Handlers

Category: Blender API

Allow to execute custom functions over operators.

History

MB-0012 Custom Splash

Category: Blender API

Required by:

Allow to show a custom splash.

History

MB-0013 Blender Top Bar

Category: Branding

Requires:

Add add a menu option on help menu, and shows a custom splash on Blender menu.

History

MB-0014 bpy Images

Category: Blender api

Required by:

Allows storing images to be used only on python context.

History

MB-0015 Image UI

Category: Blender api

Requires:

Required by:

Allows to show an image loaded using bpy.utils.images on UI.

History

MB-0016 Create object with custom orientation

Category: Blender Improvements, UCS

Applies the current custom transform orientation to new objects.

History

MB-0017 Transform Orientation Origin

Category: Blender Improvements, UCS

Adds a origin to transform orientations.

History

MB-0018 UCS

Category: UCS

Allows to set UCS.

MB-0019 Object bound dimensions proportional scale.

Category: Blender Improvements

History

Abandoned

MB-0003 mblender Make Target Windows

Category: Build System

Adds Tornavis custom targets on make command for Windows Platform. This options applies all patches from the project over the current source, usually bf-Blender main branch.

Adds curl variable for curl executable. It comes with windows 10, so should be ok in most cases.

make.bat tornavis-apply
make.bat tornavis-lite
History
MB-0004 mblender Make Target Linux

Category: Build System

Adds Tornavis custom targets on make command for Linux Platform. This target applies all patches from the project over the current source, usually bf-Blender main branch.

Requires wget

make tornavis-apply
make tornavis-lite
History

Apply Over other sources

Patches can be applied over sources using git

git apply [file]

In case it does not apply you can search a version that fits your sources, you can check in the patch history if there is on applies.

Tornavis-apply make target

In case you want to apply all patches at once, you can use the tornavis-apply target. You need to apply first the MB-0003 mblender Make Target Windows or the MB-0004 mblender Make Target Linux depending on your platform

On windows

curl --ssl-no-revoke https://www.tornavis.org/mblender_patches/patches/mb-0003-mblender-make-target-windows.patch | git apply

On Linux

wget https://www.tornavis.org/mblender-patches/mb-0004-mblender-make-target-linux.patch -O - | git apply

You can then use the Tornavís cmake options.

make update
make tornavis-apply
make tornavis-lite

Development Notes

This part is technical info related to development.

Development Platforms

Main development is done on Windows because development is part-time, and the hardware used is needed to execute windows software that does not have a Linux version, or does allow to be run in a virtual OS, or has a bad performance on it. Linux builds and some tests are made on a virtual OS on Debian, but not tested due to performance on VirtualBox. This may change, and switch to Linux as main development environment.

Development Strategy

Tornavís is conceived as a fork of bf-Blender. Some changes are at low level, and it's not an add-on you could install on Blender.

Development is based in small focused patches, that can be applied independently if there are no dependencies between them. This way, conflicts due to changes on bf-Blender's code can be isolated, and better managed. In cases where changes includes binary data, this is excluded from patch, and added on a separate tar file.

Each patch will have it's own branch and will contain a mblender folder where there are all patches applied, excluding itself. This is specially useful in dependent patches, as the changes for specific patch can be isolating applying the reverse patch of the others.

Sync with bf-Blender is expected to be once per week. Development is based on Blender main branch, but patches can target specific versions tags.

Getting Blender fully patched can be done using a custom build target

Compile Blender

Official info is available here

Make Targets

Some custom targets are added for convenience

Recover past works

As this is not the first time working on this project, try to get things work again.

Synchronization with Bf-Blender

Blender changes really fast, keep the patches upgraded to last version is hard.

Merge from official Blender repository

Steps to keep Blender development in touch. Reference

if not added, add the remote

git remote add upstream https://projects.blender.org/blender/blender.git

First, update the bf-blender branch.

git checkout bf-blender

Store the ID previous to update, maybe needed later

git log -n1
commit fe526bc9a54e38c0f727f092afc7b924d72b1bda (HEAD -> bf-blender, origin/bf-blender)
Merge: c93c5ec9213 42ddc13033c
Author: Jaume Bellet
Date:   Sat Nov 25 12:43:23 2023 +0100

    Merge branch 'main' of https://projects.blender.org/blender/blender into bf-blender
git pull upstream main
git push origin bf-blender

Next, change main and merge with bf-blender

git checkout main
git merge bf-blender

If merge fails

CONFLICT (content): Merge conflict in source/blender/editors/object/CMakeLists.txt
Automatic merge failed; fix conflicts and then commit the result.

abort, identify the patch, grep over patches with the filename, and solve

git merge --abort
git checkout [branch]
git merge

solve the conflict, test, and store the patch file.

..\mblender_utils\unapply.py
..\mblender_utils\store.py
git commit

Checkout main, remove all changes, merge, and re-apply all mb-patches. We cannot use bf-blender branch because it has been updated.

git checkout main
del release\datafiles\tornavis\*
git diff [stored_commit] | git apply -R
git add  .
git commit -m "removing all changes"
git merge bf-blender
curl --ssl-no-revoke https://www.tornavis.org/mblender_patches/patches/mb-0003-mblender-make-target-windows.patch | git apply
make tornavis-apply

[ERROR] Something went wrong

If fails, goto to the patch branch, merge and publish a new version

git checkout -- .
git clean -fd
git checkout [branch]
git merge bf-blender
..\mblender_utils\unapply.sh
..\mblender_utils\store.py

try again

[OK] Now build blender as usually 

Test it builds, test it and commit.

make tornavis-lite debug
git commit -m "reaply patches"

In case of failing build considering building bf-blender branch maybe a problem due to recent changes in blender.

Update Tornavís main branch

Revert previous changes

git diff bf-blender | git apply -R

Apply the patch to download and apply all mblender packages. See apply-make-target

Check it builds and commit.

Create a Pull request

Pull requests are created with the prefix pr- with the same name as the mb-branch.

Procedure to create a pull request to bf-blender.

git branch [branch] upstream/main
git checkout [branch]
git pull [branch]
curl --ssl-no-revoke [patch] | git apply

remove anything related to tornavís, build, check and push to origin

git push origin [branch]

Proceed with the pull request on developer projects.blender.org

Code location in Blender sources

Tornavís patches Blender's sources, but it's also adding code that is new to Blender.

This code is set on

These folders are added by MB-0008 Mblender-core patch.

Known if a MB patch have been applied

CC Core

Implementation

To allow a patch to be listed, it must create a file on ./source/mblender/patches folder named "MB-ID.h".

The implementation is done in three parts:

When configure a defined const is set for each ./source/mblender/patches/MB_ID.h as MB_ID.

When bulding, for each possible MB_ID, if set it defines MB_ID_APPLIED as 1, if not as 0.

Only compiles code for MB_ID_APPLIED defined a 1

The compiled code fills up Patch info.

Usage

Functions are declared on MB_blender.h, and defined on MB_blender.cc

Currently user can list applied patch with --tornavis-info command line option.

Issues

Does not build with lite target

This is because of usage of Macro BOOST_PP_IF from boost library, which is added as Blender dependency buts need to be enable WITH_BOOST

Using the make target tornavis-lite adds the dependency.

will not build when patching a built source

Because project needs to be re-configured.

touch ./source/blender/mblender/CMakeLists.txt will force to reconfigure only the mblender part

See for windows

TODO

Python

Implementation

Adds on bpy_app_mblender.cc

Usage

Check the mb patches with the list returned by bpy.app.mblender.patches

Manual

TODO

Command line Options

It could be useful to get some command line options to obtain information about Tornavís.

Implementation

Todo

Branding

Introduction

We add some links and credits to Tornavís' Website. This is needed to allow user reach the official sources and also try to get some contributions to project.

Implementation

Splash Screen

Changes are made on Python and CC, adding a link to Tornavís' Website and a label.

User Coordinates System

Bf Blender Issues

For UCS we are based on TransformOrientations. Some issues I have found with them.

Implementation

Although the UCS is and enhancement over transform Orientations, i keep it separated on UI. So you can have a UCS selected, and working with another Custom Tranform Orientation.

Implementation is based changing the viewmatrix so when accessing the ortho views match the ucs. Also, applying the matrix on the grid so it placed accordingly.

Issues

On development, so issues should be solved shortly

TODO

Origin

A UCS must have an origin. It's stored next to the Transform Orientation Matrix. I could change the matrix to get it included (convert from 3x3 to 4x4) but then i should change lots of things.

Make Objects created using the current tranform Orientation

Introduction

With bf-blender they are created using global cordinatges.

Implementation

Improvements

Allow to move the scene on modal transforms

Introduction

On Bf-blender commit I discovered this is was possible using ALT key. So this is not more needed.

Implementation

Defines T_TRANSFORM_NO_MODAL as transform Flag. While enabled, disables modal events related to mouse, so they are not processed, and bypassed to transformEvent, where OPERATOR_PASS_THROUGH is returned if enabled.

The T_TRANSFORM_NO_MODAL flag is defined on MB-0007 Transform Flag due to collision with other patches.

Defines TFM_MODAL_NO_MODAL_TRANSFORM, allows to set a custom key to enter mode, on preferences, shown on Key-map, Transform Modal Map, named "Allow movements around the scene"

TODO

Operator Repeat

Introduction

Although there are procedures to repeat last operator in Blender, we find useful to repeat last operator with interaction, eg when drawing a set of edges, without the need of any other input.

Blender procedures to repeat last operator are Repeat Last(SHIFT+R), or Repeat History. Both options are available on edit menu.

Implementation

Changes are on core side of Blender (CC)

It defines a new operator return code: OPERATOR_REPEAT. If any operator returns this code, is finished and executed again.

It defines a new transform flag: T_TRANSFORM_MULTIPLE. The flag is set during transform on M Key Keypress, and if set changes the return code to OPERATOR_REPEAT.

The T_TRANSFORM_MULTIPLE flag is defined on MB-0007 Transform Flag due to collision with other patches.

Issues

Last created data not removed

When executing and operator that creates data and executes and inherited one, eg Clone, Extrude.. When cancelling the last operator to finish, last created data remains.

This behavior is used on bf-Blender in some procedures, for example to clone and object and not moving it.

Todo

Allow Addons to insert menu options in position

Introduction

With current Blender's API addons can add options to menu. But they can only be added at the end of menu. Some options should be added next to other options, to get it in context, and have a coherent UI.

Implementation

Changes are on core side of Blender (CC) and Python side, at low level.

The append and prepend functions of a Menu Type can get the reference as label_referenced parameter.

Also it adds an option to output the menu labels, useful on development, named reference_debug on menu type.

Current implementation adds the function to be executed to and array. When menu is is drawn, it search for matches. This could be more efficient.

Issues

crash when adding an option menu with same label as referenced

This is beucase it's added recursively

Todo

Allow custom Addon functions over operators

Introduction

With current Blender's API addons, addons cannot interact on operators, usually addon developers use workarounds to execute custom functions base on user's actions over UI.

Implementation

Handlers functions are added over operators, to execute custom functions. They can be inserted from python, over needed operator.

MB-0011 Workflow

Allow Custom Splash

Introduction

Blender shows some info about itself using an about splash, but this is functionality is not available to addons.

Implementation

Gets code and functionality of About blender splash

Issues

Closed
Closes over container element mouse out

This is does not happening on bf-blender splash about.

Was a memory issue. See Commit

Store Images from Python not on blender data

Introduction

Loading an image for use in python (not related to blender data) would be great for some cases, eg showing and image on the UI

Implementation

The implementation is initially based on bpy.utils.previews, so a bpy.utils.images module is created.

The bpy.utils.images exposes the functions to loads and release images. These functions are implemented using the Python C Api. The image is stored and handled on CC part of blender.

Each image is assigned a name by the user, and a incremental ID. The ID assigned should not be stored as may vary on each blender execution.

Release of the image should be done by the user using the unregister function, but they are also freed on program close, to avoid messages of unfreed memory.

Patch

Usage

To use the image loaded, the ImBuf can be retrieved using BPY_utils_images_get defined on BPY_extern.h.

Todo

Allow to use the dict data on functions, eg on release.

Show Image on UI

Introduction

Allow to draw an image on UI, in a easy way, using the layout.

Implementation

The implementation is based on uiTemplateIcon, adding uiTemplateImage

Use of Custom Transform Orientation when creating data

Introduction

When adding new objects, they are always set according global axis. Make more sense to be created using the current transform orientation. This way, created data is aligned to axis.

Implementation

Changes are on CC part of blender, on function ED_object_new_primitive_matrix

Todo

Expand enums from Python

Introduction

Should be great an addon could expand existing enums

See Old Mechanical Blender patch and it's discussion.

Planned - Future Things - Wishes

Units

By default Blender uses Meters as length Unit. Create a new Unit System, and set it's default to millimetres.

Dimensions

Dimensions are a numeric setting related to data, and it's something fundamental when working on things that will be (or aimed to be) real.

Types of Dimensions on Edit Mode

Linear Dimensions
Diameter and Radius Dimensions
Angular Dimensions

Types of Dimensions en Object Mode.

Linear Dimensions

Could be used to show the distance between two objects.

Mesh dimensions

Add-on or internally build

In the first approach, i added on mesh

Object Dimensions

IDEA: Set a link on tools pop-up.

Geometric Constraint Solver.

Existent or develop one

Existent -> dependency.

C++ / Python ?

Auxiliary Objects

Auxiliary objects are non-render objects.

Plane

Axis

Snapping

Some kind of snap could be added, like tangents and intersections.

Constraints

Geometry

Try to Identify geometry present on mesh.

Drawings

Drawings (Blueprint drawings), was usually a needed step for manufacturing, and also for manuals. But at this moment, this is not so important, as digital model can be processed for CNC (and is mandatory for 3D printing). Juniors also have no idea on how a part or assembly should be represented as views on a drawing, so other could found the information required on it.

So the drawings part of Tornavís will not be focused to Drawings for manufacturing, if developed, could be more oriented to documentation, although usually a 3D documentation is also emerging, a 2D (sheet format) documentation could be needed.

Requires a new editor type.

References

technical-drawing-best-practices

Materials

This refers to physical materials. Not visual Material.

Keep in mind the Scene settings related to Units.

Material Manager

Add Material to object properties

This is where a user could expect to found it.

Relationship with Blender Materials.

The materials should be linked to Blender material. And when applied to object also apply it on object.

BOM (Bill of Materials)

I/O export.

Step

Some work in past was done.

Mechanical Mode

New mode, building parts without being to handle vertices / edges / faces

Transform Orientations per Object

Transform orientations are 'global'. The idea is when a transform orientation is created on editmode, make it only available on object. Also, this allow to match object local cordinate system. So if you have a Face Transform orientation, and you move the object, when entering editmode, the transform orientation, will match the face.

Modifiers

Hole Modifier

Should include options of mechanical holes, eg length, threaded, etc.

Standard Procedures useful for cad

Solidify Modifier

Can be used to create sheet metal parts.

Snap base point

Added on blender 4.0, was a missing feature for CAD users.

BlenderNation - Snapping Base Point in Blender 4.0

Something similar was previously developed on Mechanical Blender, so will not be re-imported to current sources. See old reference - manual snap target

Code Snippets

Bf-Blender

Automatic switch of Transform Orientation

This comes from Auto switch transform orientation in edit mode

import bpy

def mode_callback(object, data):
    #data should be always "mode"
    if bpy.context.object.mode == 'OBJECT':
        # bpy.context.scene.transform_orientation_slots[0].type = 'Cube'
        bpy.context.scene.transform_orientation_slots[0].type = 'GLOBAL'

    if bpy.context.object.mode == 'EDIT':
        bpy.context.scene.transform_orientation_slots[0].type = 'LOCAL'

def subscribe_to(owner, object,data_path,callback):
    bpy.msgbus.subscribe_rna(
        key=object.path_resolve(data_path, False),
        owner=owner,
        args=(object,data_path,),
        notify=callback,
    )

bpy.msgbus.clear_by_owner(bpy.context.object)
subscribe_to(bpy.context.object, bpy.context.object,"mode", mode_callback)

Todo

This a list of things that should be done/solved. Individuals TODO's can be found also in subsections, usually for things that need more context / information.

Blender I would like improvements

Resize proportionally with numeric input.

When changing the size of the object (via prop panel) would be great to have a proportional option.

Search for modifiers

A request also found on Video Tutorial about modifiers.

Note that some kind of filters on UI is already implemented, eg on Object Data Properties -> Attributes list

Test Builds

Test Builds are build from bf-Blender main, with lite option enabled, using the mblender make target. All patches available being applied.

At the moment there is no test build available.

Issues

on Tornavís

Last created data not removed when extruding using Operator Repeat

See Last created data not removed on development issues.

Blender crashes when adding an option menu with same label as referenced

See crash on development notes

on bf-Blender

Patched

Move the scene while transform

When performing transforms, eg zoom, rotate, scale, the scene cannot be moved.
Scene can be moved, rotated, scaled using the ALT key.

See Allow to move the scene on modal transforms

Patch

Cannot place multiple vertices with mouse input while creating vertices

See Operator Repeat

Patch

Load and image as Addon, and show on UI

Should be something more accessible. See

Looking at sources a litle, a first idea is create a function based on uiTemplateIcon

Also loading the image on blender data (bpy.data.images), seems not a good idea. Although can be hidden to user, will be saved on blender file. Using the bpy.utils.previews is used for previews, and complicates the code, as is not a preview. So I consider adding a bpy.utils.images and load images there.

See Store images from Python not on blender data

Patch

Some useful shortcuts not working while transform

Tip set on presets is not shown on UI

WM_OT_url_open_preset sets a tip for each element, but on UI (splash Screen, Help Menu) the tooltip shows "Open a preset website in the web browser"

Check how the tooltip is set for recent file list on splash, as shows info about file.

Shortcut info not shown on tool bars

For move, rotate, scale, if action for space is "search" is not shown. If set for tools, it is shown

Subdivision operator on Viewport

It does not show the final mesh on viewport.

Issue here is with GPU subdivision setting on Preferences -> Viewport -> Subdivision. (disable)

Mode on Duplicate

What is this ?

Load Addon Dialog

Do not know if affected all dialogs, but the load Add-on Dialog, fails silently on "Install Add-on" button, when no file is selected. This may easily happen if using the search input-box, as clicking then to file list does not select the file.

The search does not work for non-default elements.

Preferences Search Input Box

When the Input-box has the focus, the mouse wheel event is not bypassed. You must click in the area, and then you can scroll. Maybe a general issue.

Tranform Orientation, issues

The Info panel, shows that the command to change a transform orientation name is

bpy.data.scenes["scene"].(null) = "Name"

See Development ucs issues

Screencast Keys

The Experimental Get Event Aggressively does not work

It should show key presses during a modal operation. Not working.

See video on operator repeat

User Proposals

Credits

To ALL people that have contributed to Blender and make it possible.

Blender website

Misc

md2html

Used on website, to get and HTML version of this document.

Using utility found on cgit Debian package

Requires the python3-markdown Debian package

usage:

cat file.md | /usr/lib/cgit/filters/html-converters/md2html > file.html

Using a customized file based on it's implementation. See for documentation.

Using a video extension available here.

using tilde extension from PyMdown

Screencast Keys

Used to show key presses on 3D Viewport.

Github page

See issues with Screencast Keys.

Thoughts

Bots

I usually get some issues related to bots on sites and services available online. But things are getting worst and worst.

There are lots of programs crawling the, and it's services and servers. There lots of bots related to AI, but also lots just getting data, trying to find exploits and so on. Were nice the times when only existed the search engine's crawlers and they were following the robots.txt file.

In some cases server's and system's are dedicating more power and resources to handle bots requests, vs legitimate ones. This may be an issue if bots are requesting real-time generated data that has not been cached. And this may affect performance to final users, and it's application feeling.

You must then restrict access and try to filter out all this traffic (which may not be trivial), or use an online service blocking all known and suspicious threats. I have write my opinion about 3rd-party services: You must assume they just only make the work they are suposed to do.

As a green society, we should also consider the environmental costs of all this bots. It's not only the power consumed by the bot itself (eg indexing and analyzing the crawled data), its all the power consumed due to it's activity, going from target servers and devices to infrastructure usage.

X as a Service

Most software is going to SaaS, and I'm completely disagree on it.

Recently I've seen that also machine are being part of an ecosystem that may be based on services provided by Tech Giants. This comes at the side of Iot, called in this case iiot, industrial internet of things.

iiot means that there is a device connected to the internet. For individuals, the easy way to get control over things, and get data, is relaying on a company as a intermediary, and usually this is a service, that may be free, or not. If not free we can assume they are getting benefits that can translate to money of giving you free access. Money is moving the world, without it lots of things will not be simply achieved. And nowadays we are completely dependent of money. We need because almost nothing can be done without it. Nothing, includes, really basic things, like have access to eat.

But what concerns me, it that companies are also relaying in this model. And may not be the final company, may be a manufacturer that relies on this for a machine that is sold to a final user.

They will show us the benefits of it. - Lowest resources needed - Easy implementation - Fast achievements

That is really true but in my point of view

Easy implementations means that you're restricted, doing something different will not be easy.

I usually make a comparison between a completely mechanical machine or device, and a electronically advanced one. In the first one, you see what is happening, so more people can solve any issues with the machine.

The seconds one rely on electrical communications, and usually the depends on software or a kind of logic, so if something is not working as expected you need the necessary devices and skills to solve or find the issue.

But in the new stage, you are sending and receiving data, you don't have access to what happens in the middle. Moreover if your machine or other parts of the company rely on it, they may be complete non-functional.

So, for me it's crucial for a company to get all the documentation and data related to a machine.

If a machine needs an internet connection, why not doing using the company infrastructure ? Related to it they will say

I'll say the same previously said, but in most cases the initial cost is not so large for a company.

With the proposed model You'll will always be paying a monthly/annually fee, and usually will not be easy to change the supplier, as you may be using it's API, or objects models, or whatever.

Security issues may also occur in the supplier part.

Usually the machine (and related) needs will not grow, and if it does, will be probably absorbed with the server.

About automatic upgrades, there are two kinds of it:

The first one are crucial. But issue here is that they come merged.

About functional upgrades, some parts or procedures can be removed, and returning to previous version is not possible.

About Open Source

There cannot be any dude that I love Open-source. I've learned a lot with it. But on Open-source projects, community managed ones, there must a be an entity that traces the roadmap for the project ensure code and product quality. This also means a coherence in procedures, on both sides, code and functionality. The Blender Foundation it's behind the reason on why Blender has achieved it's goals.

But in most cases, what is missing on projects is documentation, I think because developers find it tedious. This is relevant for collaborations, where a developer submits an awesome feature, gets accepted, but it's not documented as it should, because the only reward the developer has is the code being accepted.

About Data and information

You may heard that information is the new gold. but there are qualities of information, which includes misinformation. Currently:

There are also different types of information.

About quality, the information is more valuable if it is:

In some cases duplicated information means something existing twice, because millspelled or having diferent criteria.

When you have a database set, you must get the information automatically updated, and not rely on manual updates. Also you need to have it centralized (only one valid source) and make sure persons or workers are using it. Because if they rely on getting from where it should be, there will be only one register for it, and will be updated. if not, the information will be spread-out in tools and other places, which leads on duplicates, and also outdated information, and probably you even don't know were is stored the last and correct row.

Most of you known about Spreadsheets (MS Excel as a common and known software). They are a really powerful tool. But you should avoid it for data management, because usually it does not have real links over data and it's lack of rules allow to different users (or the same user, in different days / episodes):

We are in economy (money based) world. Being information gold, means It can be translated to money

There are different types of usages that leads to indirect incomes:

The first is usage should be the right one.

The two last means information is used for manipulation, individually or in a society group. And are weird usages.They will said that they need to know you to offer better products.
But.. what the hell they need totally unrelated information to the product, usually automatically recollected with and agreement signed by you?
And... what in most cases you cannot use or buy the product if you don't agree?
Simply: Information is giving incomes, the product price is not real, or just receiving extra incomes whit it.

Also you must consider that once the information is given / recollected you don't have any control over it. Conditions about it's usage may change, it might be sold or stolen. Some can say... I do not have anything to hide, don't matter to share it. The real fact is that it should matter because you can be assigned labels based on it, and that may have consequences in a future, and also be used to guide you on paths that only want increase incomes (or authority) for a company or statement.

Going out of cloud bases services, avoid other controlling or make money from your data, is also the goal of this project.

Website

The current website is based on a md file (Markdown file) converted to HTML. The md file is pre-procesed using a custom python script. The obtained html code is parsed adding id attr's on header tags using a custom python script.

A simple JavaScript available here adds some functionality:

In next steps may change to a site allowing user interaction.

Previous site is available here. It was using a custom framework Setrill

Privacy

The website does not store anything related to the user (cookies or equivalent). It does not share anything to 3rd parties directly and does not load any external file.

About

Jaume

Jaume has been working as Freelance, since 2010, and has been always related to industrial machinery development, since 2002. And things changed a lot! Also his position has changed in time. He started doing CAD drawings in Autocad (2D) that were stored in paper (pencil drawn), and making a DB parts in Excel. He had acknowledgements of 3D, because of it's interest and because of his project at the end of University which was on Inventor 6.0 (!) But we all now that in many times industries are moving some steps back related to new technologies.

Later He started to work on some designs, based on existing ones. He started going to trade fairs as visitor, travelling over Europe. Also travelled for working purposes.

From child he always liked computer related things, and has a really good programming skills. So he took interest on machine programming, and start making small moves from mechanical design to electro-mechanical designs, at the same change that mechanical assemblies were changing to electrical parts giving much more versatility.

TMAQ

TMAQ (Tecnologia Industrial i Fabricació de Maquinaria, SL) is a Spanish company, founded by Jaume. At the beginnings was manufacturing industrial Machinery, for companies, with a foreground on industrial serigraphy, and furnaces. It started to do custom automatizations, and nowadays mainly performs engineering works for industry 4.0 machinery.

Related

Activity

2024

AGO-2024

FEB-2024

JAN-2024

2023

DEC-2023

NOV-2023

OCT-2023

SEP-2023

History