Scripts

Blender 2.93 – Wireframe Color Tools

– Set wire color of multiple objects to specific color
– Set wire color of multiple objects to random color
– Set wire color of multiple objects to random color range
– Set wire color to material viewport display color

Wireframe Color Tools


You can download it from here.
Install it like any other addon.



Titel: Blender 2.93  (Should work with 2.80 and above) – Wireframe Color Tools
Sprache: Python

This script lets you change the color of the wireframe based on different kinds of rules.

Animation Nodes – Vertex Colors Node

AN_VertexColorsNode


You can download it from here.
In order to use it you have to put it in the nodes directory of your Animation Nodes Folder.
On Windows for example that would be in the following folder (replace USERNAME with your user name):
C:\Users\USERNAME\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\animation_nodes\nodes\mesh


Titel: Animation Nodes – Vertex Colors Node
Sprache: Python

The Vertex Colors Node is an extension for the Blender Addon Animation Nodes.

It allows the user to change the colors of each individual vertex color as opposed to the standard vertex color node which only allow the user to give all vertices the same color.

Animation Nodes is an Addon by Jacques Lucke. It can be found here:

 

Blembic

Die Scriptingseite befindet sich noch im Aufbau. Ich verlinke hier zu diversen Foren in welchen meine Scripte gepostet, erklärt und besprochen werden. In Zukunft werden Skripte hier samt Erklärung zu finden sein:

Link: Blembic



Titel: Blembic
Sprache: Exporter -> Maxscript, Importer -> Python

Blembic ist ein Austauschformat, welches ähnlich wie Alembic Mesh Caches mit variierender Vertexanzahl zulässt.

Im Moment ist Alembic leider noch nicht in Blender integriert. Da mit Blender aber sehr billig (nur minimal teurer als Stromkosten) auf einer selbst gebauten Amazon Renderfarm gerendert werden kann ist es zumindest bei Projekten mit nicht ganz so großem Budget sinnvoll dies zu nutzen.

Um bestimmte Animationselemente (etwa Partikelsysteme oder Fluid Simulationen) nach Blender zu importieren benötigt man eine Mesh Cache Format das variierende Vertexanzahlen zulässt für den Austausch zwischen, z.B. 3ds Max und Blender.

Da ein solcher Mesh Cache nicht existierte habe ich selbst einen geschrieben und stelle ihn zum Download zur Verfügung. Es handelt sich um zwei Skripte. Eines ist für den Export aus 3ds Max (MaxScript) und das andere für den Import nach Blender (Python).

Blembic ist ein binäres Format, was es sehr schnell macht. Es können Objekte mit mehreren Millionen Vertexen gestreamt werden

Im Moment unterstützt Blembic folgendes:

– Geometry mit variierendem Vertex Count
– Split Normals bzw Smoothing Groups
– Material IDs für Multimaterials
– UVW maps (nur 1 channel)

 

Blembic – Documentation for Developers

Link to Thread about Blembic on blenderartists.org:
Link: Blembic

What is it good for?
Blembic is a Mesh Cache system which makes it possible to exchange mesh geometry with varying vertex count from one 3D programm to another one. A Mesh Cache system creates one single mesh per frame, writes this to an individual file in one 3D program and streams these files into another 3D program. So whenever you change a frame the 3D program will load the relevant file and show it in the viewport. When you change the frame again it will remove this file and load the next file, so that you see a consistent stream of meshes.
This is usefull for the exchange of all kinds of animations, especially ones such as fluid or particle simulations where it is the norm that vertex count varies from frame to to frame. There are a lot of other mesh cache formats such as MDD or PC2 but they only work for meshes that have a consistent vertex count and order over the range of the whole animation.

Efficiency through binary files
Simulations such as fluids often involve very large meshes with very many vertices and polygons which means that the import and export has to be very efficient. As far as I can tell it is not possible to efficiently stream mesh caches with regular text based formats such as obj. The import simply takes too long. Therefore it is a lot better to use binary files.
Binary files might sound a bit daunting at first but actually they are very simple to understand. Creating a binary files actually only means that a script (in this case our exporter) translate numbers and letters which can be easily read by humans into letters and numbers which can be easily read by computers. Since the exporter does this translation for us the importer is able to read the incomming files a lot faster.

How it works
– The Blembic exporter moves to the first frame the user wants to export.
– It creates a file in a folder the user has declared.
– Blembic analyses the Mesh
– It reads parameters such as vertex count and material IDs and writes it in to the file
– Blembic closes the file and saves it.
– Blembic moves to the next frame and does the same until all frames are exported.

Blembic Structure
Since this whole format is still in development the structure might change in future releases breaking support for older exporters.

The structure is relatively simple. The exporter reads and writes in the following order:

1. Number of vertices (1 integer)
2. Vertex position (3 floats per vertex)
3. Number of vertices (1 integer)
4. Number of faces (1 integer)
5. Vertex index number of which each face is made up of (3 integers per face)
6. Number of (Split) Normals (1 integer)
7. Vector of each normal (3 floats per normal)
8. MatID per face (1 integer per face)
9. Number of MatIDs (1 integer)
10. Number of UV Maps (1 integer)
11. Number of Vertices in UV Map (1 integer)
12. UV vertex position (2 floats per vertex in UV Map)
13. Number of Faces in UV Map (1 integer)
14. UV vertex index number of which each UV face is made up of (3 integers per UV face)

Creating binary files with Python
Creating a binary file with Python is simple. You open a file (if it doesn´t exist Python will create it automatically)
If you want to be able to write in binary you have to add „wb“.

myFilePath = "C:\\myTestFolder\\myfile.BBCTEST"
myTestFile = open(myFilePath, "wb")

In order to write a number in binary you first have to pack it. This is done with the struct.pack function.
Inside the brackets you have to declare what kind of number you want to pack. In our case we will be packing an Integer so the first thing in the bracket is „i“.
The second thing in the brackets is „9“ which is the number that will be translated into binary:

myTestStruct = struct.pack("i",9)

myTestStruct = struct.pack("i",9)

And finally we close the file

myTestFile.close

For a more in depth explanation refer to struct page of the Python manual. It also explains how to open and unpack a binary file. Python Struct Reference

Writig an exporter in Python
So all we have to do now is collect the relevant data mentioned under Belmbic Structure and pack it into our binary file. How collecting this data works depends on the 3D program you are using and you have to look that up in the 3D programms reference manual. It is possible that the 3D program you want to write an exporter for doesn not support Python or has better access to other script languages. The exporter I wrote for 3ds Max for example uses MaxScript. The syntax is obviously different but the principle should be the same.
open file -> get data -> pack to binary -> write to file

If you have any questions feel free to contact me via email, the Blembic thread on blenderartists.org.

Titel: Blembic Documentation
Language: Exporter 3ds Max -> Maxscript, Exporter Houdini (in development) -> Python, Importer -> Python

 

Object Sequence to Fluid Sim Cache

Titel: Object Sequence to Fluid Sim
Sprache: Python

Dieses Script ermöglicht es Objekte aus Blender in einen FluidSim Cache umzuwandeln und so sehr komplexe Objekte sehr effizient zu streamen.

 

MaxScript – Objekt Sequenz Exporter


myname = "mytestname" -- Dateiname: Muss zwischen Anführungszeichen stehen
mypath = "C:/work/test/" -- Ausgabepfad: Muss zwischen Anführungszeichen stehen
myfiletype = ".obj" -- Exporttyp. z.B.: .obj .fbx oder .cda. Muss zwischen Anführungszeichen stehen
mystart = 1 -- Startframe: Keine Anführungszeichen
myend = 10 -- Endframe: Keine Anführungszeichen

--------------- UNTERHALB DIESER LINIE NICHTS ÄNDERN ------------------------------------

mycopy = #() -- leerer array für kopien der markierten objekte
myobjects = #() -- leerer array dem selektion zugewiesen wird
myobjects = selection as array -- selektion wird als array gespeichert
--frameanzahl = 4

for i = mystart to myend do
(

slidertime = i

for j in myobjects do -- loop kopiert objekte in selektion und fügt sie in copy array ein
(
a = copy j
append mycopy a
)

select mycopy
macros.run "Animation Tools" "DeleteSelectedAnimation" -- löscht sämtliche animation in kopierten objekten

for k in mycopy do -- wandelt alle kopierten objekte in ePoly um
(
convertTo k PolyMeshObject
-- maxops.CollapseNodeTo k 1 true
)

mynumber = formattedPrint i format:".6d" -- formatiert frame zahl so dass immer gleich viele ziffern enthalten sind. wandelt z.b. 6 in 000006 um
myexportname = mypath+myname+mynumber+myfiletype -- legt exportname aus variablen fest

--print myexportname

exportFile (myexportname) #noprompt selectedOnly:true --using:OpenCOLLADAExporter -- exportiert file
delete mycopy -- löscht das kopierte objekt
mycopy = #() -- setzt kopierten array leer.

)

Titel: Object Sequence Exporter
Sprache: Maxscript

Dieses Script ermöglicht es Objekte als obj, fbx oder Collada als Dateisequenz zu exportieren. Es können verschiedene Parameter vom User angegeben werden:

– Basisdateiname
– Ausgabepfad
– Typ (z.B. obj oder fbx)
– Start und Endzeit der Sequenz

 

Maxscript – Clone Modifier


-- Einfach als erstes das Objekt selektieren von welchem der Modifier instanziert werden soll und
-- anschließend alle objekte selektieren, auf welche der Modifier angewandt werden soll
-- dannach dieses skript ausführen

mycounter = 1
myselection = #()
myselection = selection as array

mymodifier = myselection[1].modifiers[1]

for i = 2 to myselection.count do
(
addmodifier myselection[i] (mymodifier)
)

Titel: Clone Modifier
Sprache: Maxscript

Diese kurze Script ermöglicht es Modifier schnell auf eine beliebige Anzahl ausgewählter Objekte zu instanzieren.