How can I "slideshow" between image textures on a plane?

You name all the images you want as a sequence, for example: image0001.png, image0002.png and so on. You can do this by importing them in Blender VSE and exporting all of them as pngs or you can do this using imagemagick.

Then in the shader, you import the first image.

You change the value from single image to image sequence and set the number of frames to your total number of images.

Now the image sequencer will play all the frames from frame 1 automatically. If you want total control, set the start frame so that the last image of the sequence is the first image in the sequencer.

Now you can keyframe the offset value and change it however you want. You can hold on a frame or let it run as a sequence.


you can add custom properties to any object in your scene to store simple data types like an integer,string,boolean,float or a timer variable.

The property sensor allow you to test their values , and the property actuator to affect to them new values.
the controller can do logic operations to combine tests and trigger different actuators.

for complex data types , like arrays and structures, you have to use a python script.


Set Freestyle line thickness using python script

If you mouse over a field in blender it, amongst other things, gives you the script path

bpy.data.scenes["Scene"].render.line_thickness

For most scripts we use context.  If we are in scene "Scene" it is the context scene, rather than look it up from bpy.data.scenes

import bpy
from bpy import context # for testing
scene = context.scene
#set line thickness to 2.0
scene.render.line_thickness = 2.0

Or in the python console, where C = bpy.context for convenience.

>>> C.scene.render.line_thickness
1.0

>>> C.scene.render.line_thickness = 3.0


Permanently expanded submenu in pie menu

All the credit goes to iceythe
discussion thread
If you just want the menu items expanded, just like your manual column of operators:
col1 = pie.column()
col1.menu_contents("CUSTOM_MT_submenu")

Panels, like menus are just draw functions. You can funnel them through any layout.
You can use something like this to pass as override layout:
class Layout:
    def __init__(self, layout):
        self.layout = layout

then
col2 = pie.column()
override = Layout(col2)
bpy.types.OBJECT_PT_display.draw(override, context)

context.armature doesn’t exist outside of properties, so you must generate a new context and manually add armature to it.
Good news is, the procedure is same as with the layout override. Adding a check to emulate a poll is a good idea since drawing the panel yourself circumvents the original one. The bad news is, well, there are no bad news.
class Context(dict):
    def __init__(self, context=None, **kwargs):
        super().__init__()
        self.__dict__ = self

        if context is not None:
            self.update(context.copy())
        self.update(**kwargs)

Then draw the armature panel like this:
if context.object.type == 'ARMATURE':
    context_ = Context(context, armature=context.object.data)
    col3 = pie.column()
    override = Layout(col3)
    bpy.types.DATA_PT_display.draw(override, context_)

Custom operators no longer go into bpy.types. Instead you reference the class itself:
col4 = pie.column()
override = Layout(col4)
CUSTOM_OT_operator.draw(override, context)


Merge these two meshes and export as .obj

When joining [⎈ CtrlJ] objects, the new object will have the modifier stack of the active object.

If you (e.g.) select the mesh with the modifier and then the mesh without, the last selected becomes the active object (in this case the mesh without the modifier). When joining them, the new object will have no modifier and the mesh part which needs the modifier will be wrong.

The solution is to apply the modifier first by selecting the mesh and pressing apply on the modifier.

(legoparrot beat me, still going to leave the answer since there are some more details)


When I copy and paste the shader nodes and objects from a blender session to another one I lose some characteristcs

Go to the render context of the properties editor. Set render engine to cycles. Scroll down to Color Management panel and expand it. Were it says view transform change from filmic to RAW. Change look to none. Change exposure to 1. Change gamma to 1.1.


Array along a 3d curve with rotation lock on certain axis

To duplicate an object without deformation and with a constraint on its Z axis, use Dupliframe:

Build your bezier curve, and, in Edit mode, make sure that it goes in the right direction, if not: select all and W > Switch Direction
Put the origin of your bezier curve at it starting point
Put your object at the same point
In the Data menu of your bezier curve, click Path Animation, then in Frames choose the amount of duplications that will happen. Enable Follow.
In the Object menu of the object you want to duplicate, in Duplication, enable Frames and unclick Speed.
Parent your object to your curve with ctrl P > Object.
Keep your object selected and go to Constraints, choose Limit Rotation, and click X and Y, unclick Z.

It should work


Although there are other better ways to do this, but for your question:

I think you are asking how to separate part of a object as a new one. Basically, in Edit mode, select the part you want to peel off, hit P and choose Selection to separte the selected part as a new object.


Found it through the modal operator. There were other posts touching on this, but basically it will keep Blender's keymaps but still execute your custom code.

import bpy

class ModalOperator(bpy.types.Operator):
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

    def execute(self, context):
        print("This is the modal operator")
        return {'FINISHED'}

    def modal(self, context, event):
        if event.type == 'ESC':  # Confirm
            print("This is finished")
            return {'FINISHED'}
        elif event.alt:
            if event.type == 'M':  # Confirm
                print("This is a Blender Shortcut key")
            return {'PASS_THROUGH'}

        return {'PASS_THROUGH'}

    def invoke(self, context, event):
        print("This is the invoker")

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

bpy.utils.register_class(ModalOperator)

bpy.ops.object.modal_operator('INVOKE_DEFAULT')


Having made tests with SVG files produced by Freestyle, I found that:

Freestyle exports in pixels, and in Inkscape the default pixel density is 90 dots per inch. I don't know if this can be changed in Inkscape, and other vector drawing programs may use different pixel densities.

Therefore a rendered image whose pixel size is calculated in multiples of 90 will become an Inkscape sheet with dimensions in the corresponding number of inches. For example, a 900x900 px render will be 10 inches by 10 inches. 900x900 px is a practical size for a scaled Freestyle SVG export, because it gives you fast rendering and easy math.

The scaling of the camera affects the relative size of an object in the viewport, measured in pixels. When pixel densities in a piece of graphic work software are measured in imperial units and in a project you need to use exact scaling in metric units, you use the conversion factor 25.4 or its multiples in the scaling of Blender's camera. Multiply 25.4 by 2 to get scales of 1:20, 1:200 etc.; multiply 25.4 by 5 to get 1:50 etc.

This method will not support the entire range of architectural scales from 1:1 to 1:10 000, or the entire range of objects of drafting from doorknobs to urban planning proposals. In most cases you have to scale the SVG objects again on the Inscape sheet, but that's a piece of cake. This might not be the most popular use for Blender among its many uses, but I had a need for it and had fun figuring it out.

Afterword: after I posted this answer, Inkscape changed its default pixel resolution from 90 dpi to 96 dpi, to better suit web graphics. So every number 90 or its multiple in the text above should be replaced with 96, or a multiple of 96. If you open an old Inkscape file with the latest version of Inkscape, you get a notification about the change of pixel resolution.


Blender Game Engine: While mouse button is pressed

It is actually rather easy to do this.

First, you need a cool gun, You already have on of those, so then next step is to make it my favorite color blue - 1BC8F7.

You can skip that step if you want, but the gun looks so much nicer blue :-)

I assume you are giving the gun recoil with logic like this.

To make your gun be able to aim from the sights, parent the gun to an empty.

The empty should be parented to the camera.

Now, if we move the camera, everything should move with it.

This is good. Now, your recoil animation can play on the gun, but it will not move into place yet.

We can fix this by animating the empty to move into place when the mouse is clicked, and then move back out of place when the mouse is released.

Believe it or not, we can do this with one animation.  I am going to be using the right mouse button to aim the gun to the center, because it makes funner gameplay, however, it is just a simple to do it with the left mouse..

This is using the right mouse to aim the gun into place.

It works- Yay!

Now for the left mouse.

You only need to change a few things to your existing logic on the empty, to get this setup.

I added a simply ground plane to see the gun's movement better.

Now we need to add a Mouse Look actuator

Now, we can test it.

I'm not happy with that quite yet, so I'm going to add a slow parent to the empty.

Now we can test it.

That looks much better! You could, of course, tweak the settings to make it exactly how you want your gun. I think bullets and muzzle flashes would seriously help - but they have nothing to do with this answer :-(


Blender mesh ray_cast doesn't work, doesn't detect intersections

It turns out ray_cast takes start, direction, not start, end, as parameters.

Given a start and end, you can find the direction with something like:

direction = end - start;
direction.normalize()

Assuming that start and end are Vectors, as in start = Vector( ( 0, 10, 0 ) )

Don't trust any Google results about the Blender API docs, because the newest documentation doesn't appear in Google search results. Here's the correct documentation which won't show up when searching.


SSS - How to get a nice falloff between glowing translucent areas and dark spots?

Okay, I was finally able to replicate it!! I imported the same model to Blender to really compare. All I needed was to pump  up the transulcent BSDF amount and I just did it with an 'Add Shader' node. It looks great now and renders so fast with GPU enabled. I'm so impressed with Blender and I think I'll stick with this software for now. :-)


How to display number of users in object properties panel? 2.91

When duplicating with AltD the object data is linked.
So you can see it in the "object data properties" part:


How to change the font and size of text editor in Blender 2.8?

You can change it in the sidebar of the text editor, which you can open with CTRLT or View > Sidebar. The font size can also be adjusted without opening the sidebar by pressing CTRL and using the scroll wheel.


I can give better advice if you specify what you expect it to look like. It appears to me that you want to fix the smoothing groups. Depending on what you want, you can check out Auto Smoothing: and alternatively how to use the weighted normals modifier
Another thing I noticed is that you have auto keying on(blue dot on line editor) toggle this off so it isn't highlighted in blue and remove animation from all objects in the scene. If you forget this is on, objects can end up in unwanted locations and be confusing.


How to build an operator that corrects StringProperty("subtype = 'DIR_PATH') from relative path?

With a setter and getter.
Instead of writing an operator, here is a suggestion re using a boolean property to toggle between the two, and set the path accordingly.
IIRC, (and I didn't) had asked a similar question re globbing string properties with a file or folder subtype, in particular to glob a file.  Have asked a new question.
For the case shown in question, consider adding your own "use relative" property
Have set up a generic setter / getter on path property, and on boolean property the getter simply looks at if the path starts with "//" it is relative, and toggle using the setter.  Will also use the option available in filebrowser of setting relative_path of the invoked and active in the file browser,  operator bpy.ops.buttons.directory_browse()

Example, file saved in tmp folder, draw method added to text editor footer for testing
import bpy

def update(self, context):
    print("update")

def set(self, value):
    print("setter")
    self["foo"] = value

def get(self):
    return self.get("foo", "//")

bpy.types.Scene.foo = bpy.props.StringProperty(
    subtype='DIR_PATH',
    default="//",
    get=get,
    set=set,
    update=update,
    )

def get(self):
    return self.foo.startswith("//")

def set(self, value):
    print("set relative", value)
    if value:
        self["foo"] = bpy.path.relpath(self.foo)
    else:
        self["foo"] = bpy.path.abspath(self.foo)

bpy.types.Scene.foo_relative_path = bpy.props.BoolProperty(
    name="Use Relative",
    get=get,
    set=set,
    )

def draw(self, context):
    layout = self.layout
    row = layout.row(align=True)
    row.prop(context.scene, "foo")
    row.prop(context.scene, "foo_relative_path")

classes = []

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.TEXT_HT_footer.append(draw)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)
    bpy.types.TEXT_HT_footer.remove(draw)

if __name__ == "__main__":
    register()


How do I rotate to see my object from a different angle?

Welcome to Blender. In order to move around the platform full you can hold the middle mouse button down and move if you have a mouse or click and move the top right icon with the z, y, and x axis. The buttons on the number pad can bring you directly to different views such as front top and side views or you can use the ` key and it will give you options.
I highly recommend starting with blender gurus youtube course on making a donut from the beginning as he goes into detail on all of the essential you need to know. Hope this helped.


Not sure whether it's the best approach but here's how I would wing it:

Giving that result:

The gradient texture has its origin at the object origin and creates a virtual sphere that gets brighter and brighter which creates darker valleys and brighter mountains. Once upon a time it was called a blend texture.


Add integer property to the object running this script and keep incrementing this property :

cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()

def spawnObjects():

    scene.addObject(randomObject1, "empty1", 90)
    scene.addObject(randomObject2, "empty2", 90)

spawnObjects()
own['counter'] += 1 # this is the property that keeps count
print ("Spawned Objects %d are:"%own['counter'], randomObject1, randomObject2)

you can add a loop to spawn multiple objects at the same time,
you don't use a local variable ( defined inside the script )  because it get reset every execution of the script so you'll lose the count ,unless that is what you want.


Is it possible to print to the Report window in the Info view?

We can always use an operator's report method. Running the following operator:

class RENDER_OT_test(bpy.types.Operator):
    bl_idname = 'render.oha_test'
    bl_label = 'Test'
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        self.report({'INFO'}, 'Printing report to Info window.')
        return {'FINISHED'}

prints this in the Info window:

The color depends on the type enum: INFO gets green, WARNING light red, and ERROR dark red. I don't see reference to any direct output to Info window, other than this method.


What do these Animation objects in Outliner represent?

Blender records animation data into an action. Each object can have one active action which receives the keyframes when you use insert keyframe for a property or group of properties like LocRotScale when inserting keyframes in the 3DView.

When the dopesheet is in the Action Editor mode, the active action is visible and this action name is the first item visible under Animation in the outliner. You can change the active action and create more actions here.

While only one action can be active, which is the one being edited, we can create multiple actions for each object and use the NLA Editor to merge them into a larger animation. The tracks and actions added to the NLA Editor are then listed below the active action in the outliner. The combination of actions in the NLA is what you see in the 3D viewport. Note that actions can be muted in the NLA as well as individual channels in the dopesheet and graph editor, also the active action may not exist in the NLA but will be added to the animation in the viewport.

It's isn't too hard to get mixed up when using the NLA. Let's say you create an action that contains animation from frame 1 to 20. When you place the action in the NLA you can re-position it so that it plays from 50 to 70. If you then re-select the action so it is the active action again, as the active action it will play back from frames 1 to 20 and will not play from frame 50 as set in the NLA. This would be the cause of the out of sync animation while exporting. To fix this, select your mesh and remove the active action from the action editor.

With just a quick look at the export_x script, it changes the frame and exports the location/rotation as read from each object at that frame, this should match what you see in the 3D viewport when playing the animation.

I would expect the best results will be achieved if you remove the active action and only use NLA when exporting.


Give your material a small refraction depth.

From the manual

If Refraction Depth is not 0.0, all refraction BSDFs in the shader will act as if the object is a thin slab of the refraction material having this thickness. This will model a second refraction event that will double the absorption color and start the refraction ray after this second event.
This option greatly increases the quality of thin glass objects.


Parenting with automatic weights fails with an error?

It is the model's hair which leads to the error it isn't symmetrical.

If you separate the hair from the rest of the model it works fine:

In Edit Mode

Select one of the hair's faces
P shows the separate popup, Choose By Material

You can parent it later to the model.

In Object Mode

Select the mesh
Select the Armature
Ctrl-P With automatic weights

Note: When exporting from MakeHuman you can also export with a rig (personally I prefer the MHX rig because it doesn't pollute the outliner with all these WGT* objects)

Related:
What are the not so obvious features of Rigify?


Just click the drop-down menu to the right of the shading mode buttons in the top-right.

Then enable Scene Lights and Scene World this will override the HDRI to use your scene lighting instead of the look dev lighting setup.


On replacing Textures

You don't actually have to delete the texture. Instead you can "reassign" the slot by just opening a new one.

Assuming you have already a material with a texture

Go to Properties Window -> Texture Panel
Select the desired Texture slot
Scroll down to "Image"

Now here are two possibilities:

If you want to switch between two textures to chose which one looks better, hit the upper folder button and open a new image texture.

Notice how you now have two textures in your selection box?
If you want to switch between them, just click the selection box and change the texture.

If however you want to replace the texture with another one, hit the lower folder button (under Source:)

Notice how your original texture got replaced with the new one

]4

On replacing Materials

Go to Properties Window -> Material Panel
Hit the "+" Button on the right side of the Material Selector. This basically creates a new material slot.
Select the new slot and hit "New".
Make changes to your new Material (Textures, colors, whatever)
With that new material selected Tab into Edit mode and hit "Assign".

You still have both materials to chose from.


How to add raised text to an imported STL file for 3D printing

When importing STL change Scale to 0.001 to get proper size ... right now your Cattle has a dimension 73 x 99 m.

Now add a Text object ...

... that becomes big by default so scale S it down

WIth Tab switch to edit mode type your text. Add Solidify modifier to get thickness of letters.

Search for Convert to Mesh, hide this object in Outliner Editor. Select Cattle object add Boolean modifier kind Union and as Object select your Text object.

Before export use again Convert to Mesh (or apply modifier under arrow down icon) to make manifold object. ready for 3D printer.

I would suggest to you check some tutorial for beginners to get friendly with blenders UI first.


my python script says,"python script fail,look in console for now"

I don't see an error in your script. I expect you are trying to run the script from blender's text editor to get the error, which in the console will show the error as ImportError: No module named 'bge'

To use a script in the game engine you need to assign it to a python controller, the controller will run the script as needed during game play.


Unfortunately yes, that is the expected behavior (or call it a limitation, or a missing feature, or a bug...). Images used as part of the material currently refresh only on rendered view in Cycles.

If you switch back to Material Shading or any of the other OpenGL shading views int he viewport, the material will only show last image displayed in rendered view.

Editing the material will also force a refresh, but only for the current frame.

As an alternative (or to use as reference) you use an empty as image and use an image sequence, or video file, it will refresh correctly regardless of shading mode in the viewport. (see this link: https://blender.stackexchange.com/a/13897/1853)

Images used as background will also refresh fine.

Note that images used as background and empties used as images are meant for reference only, and will display in the 3D viewport but are not renderable.


how do I add missing section to a cylinder

Duplicate (ShiftD) a section of the label large enough to fill the gap, (don't move it,) and then rotate it around Z until it does.

Do the rotation in vertex select mode: select all the vertices in the new section, finishing with one of the vertices that's going to lie on the seam, to set it active. Set Snap On to 'Vertex' and 'Active'. The active vertex can the snap to its partner on the other side during a constrained rotation (RZ)

If the label is not conveniently centered on the world origin , choose 2 diametrically opposite vertices from it, and (ShiftS) send the 3D Cursor to Selection. Then use that as your rotation pivot.

Once the vertices on the seams are coincident, CtrlV bring up the vertex menu, and select 'Remove Doubles'.


Why can I see through the objects in Solid mode ?? isn't it what x-ray mode is for?

Looks like you have enabled Viewport Display > In Front in the Object Settings of the chair object.


Boolean Difference - What am I doing wrong?

First off, you can set the unit system to imperial instead of metric under Scene Properties > Units > Unit System > Imperial, and set the Length to Inches.

When you're using real system, do not change the scale value. Instead, press N and go into Dimensions. Here you can set the values. You can see the difference between scale and dimensions in this picture. You can also type in other Imperial units, such as ft. This will automatically put it into feet. Math operations such as *(
multiplication) or / (division). It's really handy.

Now add the cube. Again, use the dimensions panel to get the correct size of the door. Go into side view by pressing 3 on the numpad, press G, hold CTRL and bring it up to the floor. For the door zoom in so you can see the smaller squares and do the same. Make sure you're using the increment under snapping settings.

I tried exactly what you've done and ran into the same issue. Yet the solution is pretty simple! With the door selected, press TAB to go into edit mode, select the bottom face and drag it down by pressing G, then Z and dragging it down a little bit. Then press TAB again to leave the edit mode and press S and X to scale it on the sides.

... but that's just in case you come to something like this again. Otherwise the simplest solution would be to make it thicker and move the bottom a little bit right when you're scaling the door! :P

Then repeat what you did - add the Boolean modifier, select the door as the cutter, operation to Difference hit apply and you're done! You can now also delete the door if you want to.

If you also want to fix the topology after boolean operation (which I would highly recommend), select the corner of the door hole and the corner of the wall and press J. Repeat this on each side so you have quads all around the mesh. We don't want any ngons there!

Hopefully a bit longer and more detailed reply was worth it. Happy Blending! :)


What is the easiest way to create a planar grid of vertices?

Ok, as I expected, it is actually trivial. In blender >= 2.77:

Add > Grid

You can then specify the number of subdivisions and the radius of the grid as options.


How to put a model in a T-pose automatically?

If the armature was created (Edit Mode) in T-pose, you can easily get it back in armature tab by clicking Rest Position button and get your pose again with Pose Position button.

If you need the T-pose as a pose, select all bones (with A ) in Pose Mode and Alt + R , Alt + G, Alt + S to clear all transforms. You can then create a T-pose in the Pose Library to activate it easily.


How do I create a new object using Python in Blender 2.80?

In 2.8 Blender API, this is still not documented yet. After dir() inspection I've found a temporary solution, where you can replace the scene with the collection, as below:

bpy.context.collection.objects.link(theObj)


How to compare colour values in Blender using Python?

Basically it's only possible to compare equal data types. By using python's built-in type() method on Material.diffuse_color the console yields it's an instance of the class Color:

>>> type(bpy.data.materials.get("Red-Material").diffuse_color)
>>> <class 'Color'>

Probably the simplest way is to access its 'components' by class attribute Material.diffuse_color.r or index operator Material.diffuse_color[0] and compare the values:

# Check if the red component is 1.0 via equal operator
>>> bpy.data.materials.get("Red-Material").diffuse_color.r == 1
>>> True
>>> bpy.data.materials.get("Red-Material").diffuse_color[0] == 1
>>> True

However, you can also compare two class instances:

>>> mat1_diff = bpy.data.materials.get("Red-Material-I").diffuse_color
>>> mat2_diff = bpy.data.materials.get("Red-Material-II").diffuse_color
>>> mat1_diff == mat2_diff
>>> True

Means that you can create a custom color (class instance) via mathutils module to compare with:

>>> import mathutils
>>> my_red_color = mathutils.Color((1.0, 0.0, 0.0))
>>> type (my_red_color)
>>> <class 'Color'>
>>> isinstance(my_red_color, Color)
>>> True
# Compare color instance with diffuse color
>>> bpy.data.materials.get("Red-Material").diffuse_color == my_red_color
>>> True


BGE python: accessing Edge information in a mesh made of polylines (not polygons)

The BGE does not know edges. The BGE knows polygons (faces) which are defined by 3 or 4 vertices.

An edge in this context is a semantic interpretation of a line between two vertices. It does not exist as object nor is it used anywhere. The render engine simply does not need it.

You need to know in the BGE the faces do not necessarily share the same vertices even when in Blender it seams like that.

I can give you a general guideline:

Iterate over the polygons of the mesh.
A polygon has 3 or 4 vertices. An "virtual" edge are two consecutive vertices plus the edge between the last and the first vertex. You will get as many edges as the polygon has vertices
Now you should have all edges (with begin and end vertices) of all polygons.
You can match them to each other by comparing the vertex positions. Be aware edges have a direction. You need to consider the reverse of an edge when comparing.


Two years late, but for reference :)

If you want to have backface culling in cycles you can use a material setup like this:

Which basically uses two materials, a diffuse one (or whichever one you want) and a transparent material (to cull backfacing surfaces). You just mix them using the backfacing output of the geometry node so that backfacing surfaces use the transparent material.


Export objects rotation animation to textfile

Using the example in the page you mentioned, it would be something like:

# import the necessary modules we need
# in our case, blender's python API and python's os module
import bpy, os
from math import degrees

# get the current selection
selection = bpy.context.selected_objects
scene = bpy.context.scene
startFrame = scene.frame_start
endFrame = scene.frame_end
currentFrame = scene.frame_current

# get path to render output (usually /tmp\)
tempFolder = os.path.abspath (bpy.context.scene.render.filepath)
# make a filename
filename = os.path.join (tempFolder, "newfile.txt")
# open a file to write to
file = open(filename, "w")

# iterate through the selected objects
for sel in selection:
    #cycle trough all the animated frames
    for i in range(endFrame-startFrame+1):
        #get true frame number
        frame = i + startFrame
        #set frame and get the object's rotation
        scene.frame_set(frame)
        rot = sel.rotation_euler
        file.write("%s - frame %d - X:%f Y:%f Z:%f \n" % (sel.name, frame, degrees(rot.x), degrees(rot.y), degrees(rot.z)))

# close the file
file.close()

#restore original frame (not necessary)
scene.frame_set(currentFrame)

NOTE: there are more reliable ways to do it (like using fcurve data, etc...), but for simple uses this method is perfect.

NOTE 2: if you want to write this data to a .txt you probably want to read it too, so I would advise you to plan how to write your variables, based on the language you want to use to read it (if you need to read it in python I would write them with file.write("%s;%d;%f;%f;%f; \n" % (sel.name, frame, degrees(rot.x), degrees(rot.y), degrees(rot.z))) so that you can use the split(";") function).
Also, it would be a good idea to write the object name only once before the first frame to save space


How to make an object point in its movement direction? (BGE)

I made it diferent as you was doing it but i think its more easy this way.

Instead using animation i add 8 cubes rounding the cube player and make them vertex parented with no collition physics and add 8 edit object actuator set to track to for each cube.

Abd here the blend.


How to make a transparent reflective surface with transparent film

In the end, I went with compositing an opaque background image underneath the transparent layer and that worked alright, but before that I used this node setup to set the alpha value based on the value of each pixel.

The Subtract node is used as a minimum threshhold. You might have to tweak that depending on your setup.

The first Multiply is just a messy way to get a definite 1 or 0 on whether or not the pixel should be visible or not.

The second Multiply is used to set the final alpha value for the partially transparent pixels.

The Add node at the end is just to make sure that no previously-opaque pixels become transparent.

In my case it ended up looking like this:


How to display the normal values of a face?

You can toggle the on in the Mesh Display panel:


How to toggle/highlight interactable items?

Duplicate Mesh Outline

Have a mesh to be outlined:

shift+d to get a copy of the object and the mesh (give it
appropriate names)
ut: Make Single User "Materials + Tex", to get
separate materials (give them appropriate names)
tab enter edit mode
select all vertices
alt+s fatten the mesh e.g by 0.1. The resulting mesh should be larger than the original.

w + flip normals to make the faces show inside
tab to leave edit mode

As the outline should have an "aura" effect, I suggest to chose a shadeless material with "Add" Alpha. The color should be pretty dark. Otherwise it will hide the background too much.

This results in a semi-transparent "glowing" effect.

While it looks strange in the preview the game engine will show you a nice outline.

PS: Thanks to Satish Goda (youtube) I know now how to enable backface culling. Therfore I suggest following additional settings:

parent the hover to the original object
make the hover unselectable
 in Properties enable Shading/Backface Culling

This is the effect. Now you can think about logic that switches it on and off.

Hint: you can even fade it by playing material actions.

I hope it helps


You have 3 options essentially.

Two of which are cosmetic, and involve changing the grid size - but will not affect actual scale or unit measurements of your file for 3D printing or other CAM methods.

By default, 1 blender unit (and 1 grid unit) equals 1 meter. If you want to 1 blender unit to equal 1mm, you can either:
Option 1 - scale the grid via the Properties Panel (N) --> Display --> Grid Floor Scale.

Option 2 - In the Properties Window --> Scene settings --> Units, 1st set to Metric, then set the scale to 0.001.

However, if you export or save your file, 1 blender unit will still equal 1mm for most external programs.

If you want to print your model, your safest bet will be to scale your model and regard your model's dimensions as if they are in millimeters. For instance, 155 blender units = 15.5cm.

Of course you can scale your model AND change the grid settings to make the grid nicer, no contradiction there.


It looks like the normals are not consistent.

Those dark spots on the mesh are caused by flipped normals. By enabling face normals display in 3D view > Properties region > Mesh display > Normals, you will notice that they are pointing the wrong direction:

To fix this, select everything in edit mode (A) and press CtrlN.

Now all the normals should be facing outwards:


How to export an animated texture from Blender to WebGL?

I have an animated fire "burning" on a round plane by using the fire and smoke features on Blender. It's very similar to the one found in this link.

First of all Blend4Web engine doesn't export all from Blender - it works mostly with Blender Internal Render, so only Blender Internal Render nodes, particles and Physics can be exported to the engine. Cycles will not work and you can't export smoke simulation directly from blender to the engine.

  I want to render the model on three.js.

Blend4web and three.js cant be connected between them because it's different WebGl engines, so using Blend4Web addon for Blender you can export only to Blend4Web engine.

You can find a good way to make flime using only Blender Internal Render and Blend4Web possibilities in this video from our conference.


Trapezopid shaped face to square UV coordinates has unfavourable skewing

If you have a seam down one side and around the circumferences top and bottom, then you can:

Align the approximately cylindrical region in an orthographic view (minus the caps)
U unwrap the tube with 'Cylinder Projection'


Due to API changes all Add-ons need to be updated for 2.8x:

  Blender 2.80 is an API breaking release. Addons and scripts will need to be updated to run on 2.80, both to handle the new features and adapt to changes to make the API more consistent and reliable


If I buy a rigged object, will the bones import if they weren't made in blender?

You can't import .3ds files into Blender.

.obj files don't include bones or joints.

It is close to impossible to import complex rigs from different 3D applications.

.fbx files can contain bones/joints and animation.


How to re-link files which have paths that have become invalid (can't be found)?

To re-link missing files, open file menu, then choose External Data -> Find Missing Files, and select the folder where the image textures are located. File names have to be the same as they are in the blend file.

The files are found based on matching names, the folder is searched recursively, so you can for example point it at the base of your project path, to perform a more extensive search.


Your Master bone influences your whole mesh, so it conflicts with the influence of all the other bones. You can either:

Select the whole mesh and in the Properties panel > Object Data > Vertex Groups, unlock the Master group and click on the Remove button.

Or select the Master bone, go in the Properties panel > Bone > disable the Deform option.


How to make this dress animatable with White on top and Green on the bottom?

In Cycles materials you can use the Backfacing output of the Geometry node to mix different shaders on the inside and outside of a surface. See https://blender.stackexchange.com/a/39601/29586


Apply physics to multiple objects using script

Setup one object as template then the following code will set the template object as active object and select all objects. Finally bpy.ops.rigidbody.object_settings_copy() copies all attributes as the 'Copy from Active' button would do.

import bpy

scene = bpy.context.scene
scene.objects.active = bpy.data.objects["template"]
for obj in scene.objects:
    if obj.type == 'MESH':
        obj.select = True

#bpy.ops.object.constraints_copy()
bpy.ops.rigidbody.object_settings_copy()


Go to the Material Properties panel and set Blend Mode to Alpha Hashed under Viewport Display -> Settings.
Alternatively, you can switch render engine to Cycles under the Render Properties panel.


While extruding my whole mesh vertices doesn't remain connected creating a separate prt

As John wrote correctly, you have already done an extrusion and now you have doubled your vertices in place.
So what you can do is just box select your whole object (by this you just select the upper vertices), then press X -> Vertices. Which deletes the upper vertices.
Then press A to select All and extrude as you want.


You can use a combination of seven non mutually-exclusive techniques to control bevel radius and sizes either globally or on a per-point basis.

For simple tubular bevels with a circular section, not using any Bevel Objects, you can directly use the global Bevel Depth radius property, from the Curve tab in the Properties Window to control uniform bevel depth cross all splines.

For curves using Bevel Objects:

Scale a Bevel Object in Object Mode for uniform scaling across the whole curve. If scaled in Object Mode you can share the same bevel geometry across multiple curves, but each at independent sizes. You can scale independently for each axis.

Scale the Bevel Object in Edit Mode to affect all curves using a bevel objects sharing that Object Data geometry. It also remains with applied and uniform scale in Object Mode. You can scale independently for each axis.

Control the Curve Weight on a per vertex basis for precise size control over each point in the curve. In Edit Mode press Alt+S to adjust radius of selected vertex or use the Radius tool. This acts as a percentage factor over all above scaling methods, multiplying its value over the result of Bevel Depth, Bevel Object scale and Taper Object.

See Radius on beveled curve incorrect for more details.

Turn on Proportional Editing by pressing O key while in EditMode to control the vertex weight smoothly along the spline length.

Use Taper Objects to have another curve object parametrically and non destructively define the radius of the bevel object along the curve. The Taper Object is mapped lengthwise along the X axis of the "tappared curve", using the $Y$ axis coordinates of each vertex on Local Space as multiplication factor for bevel radius.

Adjust bevel easing progression along vertex from the Radius Interpolation property on a per spline basis. You can choose from several fallof types to affect smoothing, like Linear, Cardinal, BSpline or Ease.

All above methods are multiplied to calculate a final combined scaling factor.
You cannot however control different scales independently on each axis on a per vertex basis. Non uniform bevels scales are only possible by scaling a whole Bevel Object so they are by definition always consistent across the whole curve.
If you require varying non uniform scale you may have to convert (a copy of) your curve object into a mesh and do that destructively afterwards.
Alternatively if you only require a simple tube with circular section, you may also use a mesh object with a Skin Modifier which allows different factors for each axis.


Mapping out sculpted details from a high-poly

I dare to post this answer, because the following tool is free and in my opinion everyone should know this great piece of software. Please forgive me! :-)

After some testing the best working solution I found so far can be archived by creating a heightmap in XNormals. Therefore I hope that you are on a windows system, because XNormals is a pure windows tool.

Export your highpoly and your lowpoly  and a cage as seperate Fbx scenes.

Import them to XNormal (just drag the highpoly and the lowpoly into the list).

for the cage, a checkbox in the lowpoly object has to be enabled and you have to select it by clicking with RMB in the sceen and select "Browse external cage file"

In the baking option select your texture size you want to export, your export location, and check heightmap as renderer.

To render, press the Generate Maps button and after some calculating something like this should appear:

After adjusting your heightmap, close the window  and it will export it to your predefined export location.


As @Xylvier pointed out in the comments, I should have done CTRL+J to join the strokes.


How to bake normal map identical to one from cycles?

To align normal maps to match GLSL I use Photoshop.  By using the Channel Mixer tool you can swap axis.  Swapping Green and Blue is the same as swapping the Y-Axis and the Z-Axis.  Then you can also use the Curves tool to change the direction of an axis which is the same as multiplying the value by -1.0.
I've attached a picture that shows a PS Action.
For your situation specifically, I'm not sure which combination of operations that you require but you can grab yourself a copy of xNormal to help with this.  In the Normal Baking window there is the option to perform all this swapping with a simple GUI.  You can try what you think will work and then bake the normal map to see if it looks the same as what you need.  Once you know this, you can use either GIMP or PS to do the conversion after you've baked a map in Blender.


I think that what you are looking for is the bezier geometry menu:

After you create the curve which you want to make into a pipe, you can change the depth and resolution to edit the thickness and amount of faces here. Also, to make the bezier curve look like a pipe you will need to set the shape to 3D and the fill to full. This is an example:

If you are confused about creating the bezier curve in the first place, you would add a bezier curve (shift+a, bezier curve), and then enter edit mode (tab). Here you can select the control line things, and move/rotate/scale using the usual blender controls. To add another control line you would use "e".

Hope this helped

If you need more clarification check out this video specifically about creating pipes using beziers: https://www.youtube.com/watch?v=AMXcQ2V-VGA


Cycles render appears not to render on GPU

You may want to check settings: Edit->Preferences->System->CyclesRenderDevice
Since I run on NVIDIA mine are different but you graphic card needs to be check marked in one of the tabs.

Furthermore, check out recent guides for speed improvement. Most important tip is the tiling. For GPUs it should be larger than for CPU.


Join multiple objects into 1 object without combining the vertices?

Try using lattice modifier.

To get the modifier to all objects select them with box selection and after this click in any of them, add the lattice modifier and press ctrl-l>modifiers to give all of them the lattice modifier.

here's an example of this:


Trying to texture a landscape with color ramp, but it won't work

I figured out what was wrong. So I did ctrl shift T to view the the color ramp, and I must have clicked it twice because it was on alpha instead of color. Once I did ctrl shift T again to get it back on color it work like normal. Thanks for your help


Characters Move Independently In Single Text Object

Image above showing extents of individual characters in a single Blender Text Object.

Some miscellaneous points.

For ease of expressiveness, in the not quite so long run, I suggest you animate either single letter text objects or the mesh converted objects.
You may want to search for a script which already does what you want.
Text can follow path as a whole quite easily.  Having each character follow a different path requires more work.  Link for various approaches ...How-To: Text Sliding out of a Circle 2D
Your statements lead me to believe you want characters following individual paths.

In the image above we see the Blender Python Console window.  We have probed the location and dimension of a text object.  You see the X-axis value increase as I add letters.  Subtraction required for individual character location perhaps other considerations.  I have not found a more abstract probe for individual substrings of a larger string.

In the image above is a text editor window with an executed script.  The blue balls have been placed at right side x axis of each letter.  Thus the script has some reasonable knowledge of extents in the x direction.  You can store the measurements in a Python list if that suits you.
Inspect, Verify and Improve the script.
Know that text character placement may not be as easy as placing a cube.  Text characters have their own sense of orientation and aesthetics.  Baseline for example.  If you separate characters of a text object take care to notice any adjustments to the individual origins.
If you have final placement of the single objects whether text or mesh you can keyframe those positions as final positions.  Then your animation can occur close enough to those final positions.  For example a path which gets close enough to your final position can ease out its influence.
There is more left for you to discover.


Blender Edge Flow/UV Mapping help needed

I don't know anything about Adaptive Subdivision, maybe create a new question for this. About your first question: Your stretched texture is created by the ngons, You need to use quads instead, so just correct this and it should work.


If you add a Value Node to your graph, you can type #frame in the value field which will make the value correspond with the current frame as the frame changes. You could combine this with math nodes to set the timing and the direction (toward beginning or toward end) of the fade that you want. This example fades the background from bright white (At frame 0) to full black (at frame 250):


How to make a button link to a DataLibrary using python?

i took the liberty to make an addon out of it.
It's a bit convoluted, so i made the simple version and EXTRA with file picker, it's mostly from
https://www.youtube.com/watch?v=9fuFDHR-UkE&list=PLa1F2ddGya_8acrgoQr1fTeIuQtkSd6BW&index=6
it adds a panel default 'N' key
the panel can be merged with existing panels by modifying bl_category
just create a file in your blender instal folder /Version Nr/Scripts/Addons/
name it anything.py
then in blender after a restart go to preference/addons search for "Link data" and enable it.
hope that saves you a headache. hehe

bl_info = {
    "name" : "Link to Data Library",
    "author" : "Daniel",
    "description" : "Add description Here",
    "blender" : (2, 80, 0),
    "version" : (0, 0, 1),
    "location" : "",
    "warning" : "",
    "category" : "Generic"
}

import bpy

class OBJECT_OT_link_data(bpy.types.Operator):
    """Tool tip thingy"""
    bl_label = "Link Data"
    bl_idname = "object.link_data"
    bl_options = {"REGISTER", "UNDO"}
    bl_context = "objectmode"

    def execute(self, context):

        filepath = r"C:\\path\example.blend"

        coll_name = "collection name"

        link = False

        with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
            data_to.collections = [c for c in data_from.collections if c.startswith(coll_name)]

        for coll in data_to.collections:
            if coll is not None:
               bpy.context.scene.collection.children.link(coll)

        return {"FINISHED"}

class VIEW3D_PT_Link_Data(bpy.types.Panel):
    """Tool tip thingy"""
    bl_label = "Link To Data"
    bl_category = "Link Data"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_context = "objectmode"

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

        col = layout.column()

        col.operator("OBJECT_OT_link_data",
            text="link data",
            icon="PACKAGE"
        )

def register():
    bpy.utils.register_class(OBJECT_OT_link_data)
    bpy.utils.register_class(VIEW3D_PT_Link_Data)

def unregister():
    bpy.utils.unregister_class(OBJECT_OT_link_data)
    bpy.utils.unregister_class(VIEW3D_PT_Link_Data)

if __name__ == "__main__":
    register()

Modified version with EXTRA bits
bl_info = {
    "name" : "Link to Data Library",
    "author" : "Daniel",
    "description" : "Add description Here",
    "blender" : (2, 80, 0),
    "version" : (0, 0, 1),
    "location" : "",
    "warning" : "",
    "category" : "Generic"
}

import bpy

class OBJECT_OT_link_data(bpy.types.Operator):
    """Tool tip thingy"""
    bl_label = "Link Data"
    bl_idname = "object.link_data"
    bl_options = {"REGISTER", "UNDO"}
    bl_context = "objectmode"

    def execute(self, context):

        filepath = bpy.path.abspath(context.scene.DanielLinkFile)

        coll_name = context.scene.DanielLinkCollection

        link = context.scene.DanielLink

        with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
            data_to.collections = [c for c in data_from.collections if c.startswith(coll_name)]

        for coll in data_to.collections:
            if coll is not None:
               bpy.context.scene.collection.children.link(coll)

        return {"FINISHED"}

class VIEW3D_PT_Link_Data(bpy.types.Panel):
    """Tool tip thingy"""
    bl_label = "Link To Data"
    bl_category = "Link Data"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_context = "objectmode"

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

        col = layout.column()

        col.prop(context.scene, "DanielLinkFile")
        col.prop(context.scene, "DanielLinkCollection")
        col.prop(context.scene, "DanielLink")

        col.operator("OBJECT_OT_link_data",
            text="link data",
            icon="PACKAGE"
        )

def register():
    bpy.types.Scene.DanielLinkFile = bpy.props.StringProperty(name="Link File",subtype="FILE_PATH", default=r"C:\\path\example.blend")
    bpy.types.Scene.DanielLinkCollection = bpy.props.StringProperty(name="Link Collection",default="collection name")
    bpy.types.Scene.DanielLink = bpy.props.BoolProperty(name="Link",default=False)

    bpy.utils.register_class(OBJECT_OT_link_data)
    bpy.utils.register_class(VIEW3D_PT_Link_Data)

def unregister():
    del bpy.types.Scene.DanielLinkFile
    del bpy.types.Scene.DanielLinkCollection
    del bpy.types.Scene.DanielLink
    bpy.utils.unregister_class(OBJECT_OT_link_data)
    bpy.utils.unregister_class(VIEW3D_PT_Link_Data)

if __name__ == "__main__":
    register()

```


Find out perpendicular vectors of a normal

I've figured it out using bm.face[#].calc_tangent_edge(). Although I can't figure out why it goes to X axis then to Y axis when selecting faces in other parts of the mesh. I also need a 90° equivalent of this tangent to able to use this on a gridify script.
import bpy
import bmesh

obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
f = bm.select_history.active
n = f.calc_tangent_edge()
vec = 0.1 * n

for v in f.verts:
    v.co += vec

bmesh.update_edit_mesh(me, True)

Moving across a plane, horizontally
import bpy
import bmesh

threshold = 0.0001

obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
f = bm.select_history.active
normal = f.normal
tangent1 = f.calc_tangent_edge()
tangent2 = normal.cross(tangent1)
if abs(tangent1.z) < threshold:
    vec = tangent1  # this tangent already is horizontal
elif abs(tangent2.z) < threshold:
    vec = tangent2
else:
    ratio = tangent1.z / tangent2.z
    vec = tangent1 - tangent2*ratio

vec.z = 0  # it's close to 0 but let's just round it exactly to 0
vec.normalize()
vec *= .1

for v in f.verts:
    v.co += vec

bmesh.update_edit_mesh(me, True)


Just add a subdivision modifier to the sphere and the problem will be solved.It's caused due to low geometry.


Nurbs Curve with hooks not updating properly during render

There is a circular dependency. The curve is parent of the armature, and the armature deforms the curve. Since Blender walks through the hierachy only once per frame update, the deformation lags behind. Clicking the frame twice leads to Blender walking the hierachy twice. The bones of the armature are already in place and the deformation happens. A solution is to avoid direct parent child relationships between those two and use a parent for both (e.g. an Empty) instead or to swap the relationship, so the armature is the parent of curve.

Here is Blenders terminal/console output:

Dependency cycle detected:
  Hosearm depends on hose through Curve Parent.
  hose depends on Hosearm through Hook Modifier.


Blender not saving changes to object's origin point

It sounds like you accidentally added a keyframe to your object. So even if you move it, it will snap back to the keyframe position. You can fix this by opening the NLA editor and deleting all animation on your cube, or opening the Dope Sheet and deleting the keyframe you don't want. A common way to add keyframes by accident is by pressing the Auto Keyframe button (at  the bottom of the timeline), this causes any rotation, scale, or movement to your object to be keyframed.

You can acsess the Dope Sheet through this menu:

Once in the Dope Sheet, select the keyframes you don't want and press delete.


How to display my rendered scene on a new monitor while i am still working on solid mode in my laptop?

Yes it is.

Click on View in the bottom menu of your 3D window and choose Duplicate Area into New Window. Simply drag the new window onto the other screen and switch to rendered view.


Why do my objects have white dots on them?

Those little white dots are called fireflies.
They are an annoying side effect of rendering. The easiest way to remove them is to just increase the sample count.

Blender Guru also has an article about how to get rid of them. https://www.blenderguru.com/articles/7-ways-get-rid-fireflies


That exports and imports perfectly for me, Blender 2.77. However, it's as I suspected, there are a bunch of duplicate vertices which are no doubt causing the error on your end.

To fix, box select B your entire model, join it into one mesh with CtrlJ, select all with CtrlA, open special menu W and select Remove Doubles. Finally, select everything again in edit mode and use P > Separate by loose parts. You will have to reassign any materials, fix origins and groups after but that should fix the problem and give you a clean obj.


How to apply a real time constraint on a moving gear

Not sure if you're interested in this solution, as it does not deal with physics simulation but using traditional constraints instead. As mentioned in a few comments already, this is recommended for various reasons, like easier handling and setup, better stability, etc. For what you're really trying to achieve, this will work.

Here is the file rigged based on your provided Blend:

I'm using an Armature, parenting a few bones in there in a hierachy like this:

Main Bone and Lever Bone are purely for better flexibility later on when animating. Using the Main Bone you can relocate the whole rig, the gear bone allows additional offset. Both bones are optional, but recommended. The lever bone is a child of the Gear Bone, so it follows the movement of that, and the sprocket bone a child of the lever bone.

The rig itself looks like this:

I turned on Axis Display for each bone, so you can see the local bone axis and better understand why I set certain values later on in the Constraint. Speaking of the Constraint, I used a Transformation constraint to achieve the desired effect:

The logic is: If you rotate the lever bone by 8 degrees along the Z axis, the sprocket bone has to spin 36 degrees along the Y axis, but in the opposite direction, hence the -36 degrees. Where I got these values from? Simply count the number of teeth of gear and sprocket. The Extrapolate option makes sure that this math relationship is kept even if you exceed the values.

Now, if you rotate the red lever bone, the sprocket spins around the gear.


Two Problems with a Nixie Tube: Glass and Glow

Eevee can handle all this quite well with basic materials.

Glass BSDF (or Principled BSDF) for glass
Emission shader for the light
Check ✓ Bloom to simulate the neon gas volumetrics


2.81 - Any way to have the grid show through objects?

There is no configuration option for this, but it's possible to patch the shader source code within the Blender binary, if you're brave enough.  The following works for 2.80, 2.81, and 2.82.  It doesn't work for 2.79, though.  Also I found that after applying this patch, there was a delay of several seconds the first time I ran the new binary, presumably as Blender recompiled all the shaders.  After that first delay, it should launch quickly again, but if you keep both binaries around and switch between them, there'll be a delay whenever you switch.

The shader source code lines you're looking for in the Blender binary are:

fade *= (scene_depth == 1.0) ? 1.0 : 0.0;

and:

fade *= 1.0 - clamp((grid_depth - scene_depth) * test_hardness, 0.0, 1.0);

The first makes the grid invisible behind objects in orthographic view.  The second does it in perspective view.  Both should be commented out.

If you have a hex/binary editor, you can do it manually.  The usual caveats for binary patching apply -- make a backup copy of your executable first, and change the lines to:

//de *= (scene_depth == 1.0) ? 1.0 : 0.0;
...
//de *= 1.0 - clamp((grid_depth - scene_depth) * test_hardness, 0.0, 1.0);

being exceedingly careful to keep the patch the same length as the original.

Alternatively, you can run the following Python script.  Note:  If you run this script from within Blender itself, it works fine, but it does nothing to the grid in the running copy of Blender.  It only patches and writes a new binary to implement the change.

Anyway, update the file paths to point to the input binary and an appropriate output file location.  If the patch is successful, you may be able to run the new binary directly, or you may find you need to move it into the same directory as the old binary (or even move the old binary out of the way and give the new binary exactly the same name as the old one), depending on how Blender is installed.

import os
import stat

# File names of input and output Blender executables
INFILE = "/scratch/buhr/blender/official_versions/blender-2.80-linux-glibc217-x86_64/blender"
OUTFILE = "/var/tmp/blender_gridinfront"

# Comment out these two shader lines
LINE1 = b"fade *= (scene_depth"
LINE2 = b"fade *= 1.0 - clamp((grid_depth"

def patch(data, line):
    i = data.index(line)
    data[i:(i+2)] = b"//"
    return data

with open(INFILE, "rb") as r, \
     open(OUTFILE, "wb") as w:
    data = bytearray(r.read())
    try:
        newdata = patch(data, LINE1)
        newdata = patch(newdata, LINE2)
        w.write(newdata)
        os.chmod(OUTFILE, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
    except:
        print("Patch failed")
        raise


Activating 2 or more bone layers at the same time with one button

Operator property

Here is a "dodgy" little operator that instead of passing a list of booleans, eg bone.layers = [True] * 32 (which would set all bone layers to True), uses a comma separated string of layer numbers, as the indices to toggle.

Test script for bone layers based on active pose bone.

import bpy
from bpy.props import StringProperty

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    layers : StringProperty()

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

    def execute(self, context):
        pb = context.active_pose_bone
        bone = pb.bone
        layers = [int(l) for l in self.layers.split(",")]
        for l in layers:
            bone.layers[l] = not bone.layers[l]

        return {'FINISHED'}

def register():
    bpy.utils.register_class(SimpleOperator)

def unregister():
    bpy.utils.unregister_class(SimpleOperator)

Obviously change the class names etc to better suit (from simple operator template)

Now in the layout can

layout = self.layout
op = self.layout.operator("object.simple_operator", text="18, 19")
op.layers = "18, 19"

to toggle layers 18 and 19.

Notes

Cannot turn off all layers, at least one has to be True.

Could extend above to include select, deselect as well as toggle (which it does now)


From blender to unreal smoothgroup and shading

You can uneversaly try to export a .obj if you only whant a mesh. In the settings you will find a addon tab that have a unreal import-export feture disable in 2.79 (.psk/.psa)

The problem is usaly that the export are missing information or is procesed diffrent and you will need to deal with it in the other program


Delete hidden object from commandline pythonscript

You can use the command line to run blender and pass the below python script to it which will delete all unhidden objects:

import bpy
bpy.ops.object.select_all(action='DESELECT')
for obj in bpy.data.objects:
    if obj.hide == True:
        obj.hide = False
        obj.select = True
bpy.ops.object.delete()


Reset vector where objects are added to origin (0, 0, 0)

You can change coordinates in the Location field in the Last Operator panel for Add primitive menu and set there 0,0,0 (use an old trick for entering all 3 values quickly - set the mouse in the top-most field and drag it all the way through to the bottom-most field, then type a value).

However there doesn't appear to be any default way to save this into user preferences to use later. It's possible to edit the location of the object afterwards by placing 3D cursor to scene origin though (Shift++S > Cursor To Center) and then aligning object to the cursor (Shift++S > Selection To Cursor). See Precisely move the 3D cursor and The easiest way to move an object to 3D cursor for more info.


The maybe easiest way in this situation is manual stitching:

Just select a single vert from the inside of the circles.

Then hit GG. That way you enter vertex slide mode. Move the vert towards the outside and put it where both circles intersect. That way you keep angles roughly consistent. The more you zoom in, the more precise it gets.

The rest is stitching stuff together with ALTM. I usually prefer to use merge 'At Last'. Just put the rest of the verts on the newly placed verts.

You could extrude the circles into cylinders and use booleans but it's not worth the hassle, especially since they're already in a single mesh.

If you lose one of the faces, simply clear the selection, select all the verts that belong to it, for example with Circle Select C and then hit F to create the face.

If the holes are easy enough for Blender to understand, selecting everything and hitting F  will work, too.

https://docs.blender.org/manual/en/dev/modeling/meshes/editing/vertices.html


Your question and your issues have no real relation to each other. Therefore I split them into separate sections.

KeyError

Traceback (most recent call last): File "test.py", line 14, in File "test.py", line 10, in functions File

"\Functions.py", line 23, in main KeyError: 'requested item "Scene" does not exist'

Analysis

There is an error in file test.py. As the error says you try to find an item with key "Scene". But there is no such item. I guess the code is supposed to find a scene. But there is no scene "Scene" loaded.

Suggestion

Check the scene names and what scenes are loaded at the moment of execution of this code. Ensure the scene is loaded and has the name "Scene".

ValueError

Traceback (most recent call last): File

"Main.py",line 18, in map File

"Map.py",line 27, in init File

"Map.py",line 36, in oooopenmap File

"Functions.py",line 22, in init File

"Functions.py",line 26, in pausee ValueError: Pause not in this python controllers actuator list

Analysis

I did not had that error in the past. I guess it is pretty much the same as the KeyError. You try to get an actuator called "Pause", which is not connected to the current actuator.

Suggestion

Ensure the currently running controller is connected to an actuator called "Pause".

How to combine modules?

This is a plain Python question.All you need is "import" as you already do.

You can import any module into any script/module. The imported module can be in

a text block
a file that resides in the python search path
a package that resides in the python search path.

Caching context

I strongly suggest to avoid storing context data (current controller, current scene) when it is supposed to be used as context. You can't be sure this is still valid within any subsequent uses of the class.

To be more specific: you store a reference of the current controller inside of the object "module". But when you call any function of that object from another controller, this class still refers to the original controller.

This can be the reason why you get the ValueError (see the section above).

Example: your controller "Python" executes Python code that creates a new object of class "module".

myModuleObject = Map.module()

A controller "Python.001" executes Python code that uses with this object:

myModuleObject.oooopenmap()

This can fail as the current controller (Python.001) is not the stored controller (Python). You can only activate actuators that are connected to the current controller regardless what controller you store in your object.

Recommendation

Always read the current controller from context. Store it in a local variable, but not in a class or module variable. Do not store it in a game object property.

You can store the current object and the current scene when it is not meant to be used as "current". E.g. you want to store the current object as target.

I hope this helps a bit


To make it sit on the ground plane you need to move it in the Z axis. If your cube is 1m in height then setting 0.5 in Z will make it sit on the ground plane.


Lazy tutorial ...

download (export) terrain high-map from here https://tangrams.github.io

Link is set directly to your Barringer crater. Exported image seems like just a screenshot saved in 8-bit, that makes it lately a bit blocky for displacement (16 or 32-bit would be better for smooth result), but since your goal is low-poly, it's more than enough.

subdivide plane few times to make topology more dense, plus add Subdivide modifier to get grid even more dense to catch details

add Displacement modifier, assign downloaded high-map (greyscale image) as Texture, Strenght = 0.1

add Decimate modifier, Ratio = 0.01

Landing on Surface

add Cylinder and Boolean-Intersect it from crater to get circular shape

go to Weight Paint mode and click in center from top view to get gradient

search for "Invert" to get red color of gradient from center on edge

add any "land" object (surface you want to follow)
use snap tool to bring center of crater object to surface (with "Align Rotation to Target")

add to the crater object Shrinkwrap modifier and choose a Vertex Group (in this case called "Group" generated by Weight Paint mode automatically)

Works for concave and convex shapes as well ...

In this particular case (crater) probably could be enough to duplicate and rotate / scale object, that will brings illusion of crater variations without needs to make them unique, but you can sculpt a bit each of them to make more variations.


When dragging to re-parent in the Outliner, I'm not getting any visual feedback. How do I fix this?

The problem is caused by the Window Draw Method in the User Preferences > System menu. When this is set to "Full", the overlay isn't drawn. Changing it for example to "Overlap" fixes the issue. (however, there are other problems that arise in other parts of Blender when Window Draw Method is not set to "Full")


How to make brush size lock in texture paint

With Blender 2.79.

By default, with a 'tiled' brush mapping, not only the brush texture size is changed with zooming, but the brush texture is also offset when changing the angle of view.

However, the brush mapping can be changed to '3D' to prevent resulting in texture painting interference by view resize/change.

From Blender 2.79 documentation:

  The 3D option allows the brush to take full advantage of procedural
  textures. This mode uses vertex coordinates rather than the brush
  location to determine what area of the texture to use.

Note that it works perfectly with image texture as well.


Texture painting, zoom pan causes texture to get an offset

You can use stencil for the brush mapping. This gives you a semi-transparent overlay of the texture that you can position before painting.

You can use  RMB to move the texture ⎈ Ctrl  RMB to rotate it and ⇧ Shift  RMB to scale it


In edit mode, select the joint (not the bone), SHIFT+S > cursor to selected, then in Object mode, go to the object menu Object > Set Origin > Origin to 3D cursor.

Just note, the ctrl+shift+alt+c hotkey has been changed in blender version 2.8


Mesh faces that are behind other faces appearing in front in game engine

It sounds like you enabled semi-transparency (alpha-blend/alpha-sort) at your meshes. This usually happens when you import the mesh from another format.

Switching off the transparency in you materials should fix the problem.


If the walk cycle is the only thing you want in your animation, you could just make the timeline the same length as the walk cycle. It'll loop automatically.

Otherwise, if the walk cycle is in your timeline, you can go to the NLA editor with the rig selected (in object mode), and click on the double-down-arrow icon, which will save the walk cycle as an action.

Then you can use the N key properties window to change the amount of times the action is repeated.

This is, IMHO, the best solution as it gives you more flexibility to work with animations.


how to pin two soft body objects together?

If this  is what you want, read the following:

The goal property tells your softbody where (location) it should be and how it should look (shape resulting out of shapekeys or other modifiers). So, a good option is to just keyframe your inner mesh to be inside your outer mesh at every frame, after the outer mesh has an already baked softbody-simulation. Then, because of the keyframed locations and the goal property of your inner softbody, it should look like it tries to stay inside the outer softbody. However, because we value our sanity, we don't want to do this by hand. Blender has the option to automatically calculate a new point of origin (that small orange dot inside of every mesh) of an object based on its current shape or other properties (Object -> Set Origin), for instance trying to put it into the average middle-point of your object. So, for good results we can just have blender calculate a new point of origin for each frame based on the outer mesh's current shape and then keyframe the inner mesh to be at the location of that new point of origin. Because you can't keyframe the point of origin itself however (and because the calculation doesn't take the softbody-modifier into account), I had to create a script which does what we want:

#hello user
#please specify the desired framerange of your animation
first_frame = 1
last_frame = 250
#to run this script, have both the outer and inner mesh selected, with the outer mesh being the active object. (=> Select it last, it should have an yellow-orange outline instead of orange-red)
#then just press the "Run Script" Button in the top right corner of this text-editor.

import bpy

outer_mesh = bpy.context.object
outer_mesh.select_set(False)
inner_mesh = bpy.context.selected_objects[0]

for x in range(first_frame,last_frame+1):
    bpy.context.scene.frame_set(x)
    bpy.ops.object.select_all(action='DESELECT')
    outer_mesh.select_set(True)
    bpy.context.view_layer.objects.active = outer_mesh
    bpy.ops.object.object_duplicate_flatten_modifiers()
    t_m = bpy.context.object #(temporary_mesh)
    t_m.location        = outer_mesh.location
    t_m.rotation_euler  = outer_mesh.rotation_euler
    t_m.scale           = outer_mesh.scale
    bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME')
    inner_mesh.location         = t_m.location
    inner_mesh.keyframe_insert(data_path = "location")
    bpy.ops.object.delete(use_global=False)

How to use:

First, you need to have an addon enabled - "Corrective Shape Keys".
To do so, go into your blender preferences, and under the tab
"Add-ons" search for its name, then just check the box left to it.

Second, get the script into your blend-file. Get to the text-editor
(one is in the "Scripting" workspace by default), click on "New" to
create an empty script and just copy-paste my script in
there.

After that is done:

Bake the softbody-simulation of your outer mesh
If not done yet, create your inner mesh. The location of it doesn't really matter here
Select your inner mesh and then your outer mesh as well (outer mesh last so it's the active object, shown by a yellow outline instead of red)
In the first lines of the script, specify the frame-range of your softbody-animation and then press the fat "Run Script" button in the top right corner. Wait for the script to finish. Now your inner mesh has the individualy calculated point-of-origin-locations of your outer softbody keyframed.

(The script uses the "Origin to Center of Mass (volume)" option, but you should be able to edit it to use the other ones; in the script change 'ORIGIN_CENTER_OF_VOLUME' to one of the following: 'ORIGIN_CENTER_OF_MASS', 'ORIGIN_CURSOR','ORIGIN_GEOMETRY', 'GEOMETRY_ORIGIN'. I didn't test this myself though.)

If not done already, give your inner mesh a softbody-modifier and bake it with your desired properties.

Obviously, in its properties check the "Goal" box to enable it, if it isn't already. You don't need to use a vertex group as a goal since that just changes how much certain vertices are affected by it.
You probably want to experiment with mass and gravity values of your mesh. Know that you can for instance set its mass to 0kg to not have it be influenced by gravity and show almost no inertia, or that you can set the gravity to 0 in the Field-Weights section, then however being able to keep the mass of your object above 0 to see effects of inertia without it falling down.
You can significantly increase the object Friction (found above its Mass) to make it look like it's in jelly instead of thin air.

Optional addition: Preventing the inner mesh to clip outside of your outer mesh. Done by using the outer mesh as a collision object:

Select your outer mesh and go into edit mode
In the Viewport Overlays dropdown menu enable "Face Orientation" (in the geometry tab). Now your meshes look all blue on the outside, and red on the inside.
Select all faces of your mesh, and then flip their normals (Mesh ->Normals ->Flip). Now the mesh should be red on the outside and blue on the inside.
Go back to object mode and give your outer mesh a collision modifier.
Bake the softbody-simulation of your inner mesh again. It should now not clip through your outer mesh in most cases. Also experiment with the "Thickness Outer" property of your collision-outer-mesh. A value of 0.1 is equal to 0.1 meters. A small value means your Softbody can in some cases actually look like it touches the surface of your outer mesh, which you probably don't want.
Once satisfied with the result, flip the normals of your outer mesh again to prevent shading- and other issues.


The graph editor won't filter based on the selected shapekey. The Show Only Selected option shows all animation related to the selected objects.

There is a filter option that can help you find an fcurve in large animations. Click the magnifying glass in the header and you get a text entry to use for filtering. You can also use ⎈ CtrlF.


Replace objects with a group of objects using Python

If you create an empty, and set it to represent an instance of the brokenCube group (Properties panel -> Object -> Duplication -> Group), you can then simply add that empty, to add all the objects in the group.

Demo: break_demo.blend

PS: Cell fracture seems to create areas with a very large number of very small parts. I would recommend that you remove most of them (as I did in the demo), if you want to have good performance.


Subdivision-surface giving strange geometry with tris

Tris and subsurf don't blend well. I would suggest reworking that mesh, try using quads wherever possible. For a hard surface object, tris are ok to a point but once you start to subdivide and smooth it, it quickly gets out of hand. The 'strange geometry' is more than likely caused by the tris pinching together at one point. If you go into edit mode, use wireframes and look at what the modifier is doing. It is mutilating your mesh trying to subdivide those triangular faces.
An alternative
The way I normally go about this and one way to do it is to add the circle and a plane to the scene, delete an edge of the plane so the face goes away and then add it back. You should now have something like this below. (This is the wireframe)

This next step will be unique to every case as it depends how many vertices the circle has. You generally want to estimate at this point and select an even or so amount of vertices and subdivide one side of the plane and join these together. You can manually do this for the entire plane side by side or automate it with the mirror modifier or duplicating and rotating and removing doubles etc.. depends what works best for you.
At this point, it will be easy to see if you are off as the mesh will look odd. You generally want to aim for something that gets nice even spaces and looks symmetrical to the other sides to a point.

You now have a mesh with a circle in it with nice clean faces so you can easily add more geometry as needed and subdivide as much as you want.

For more tips see: How to fill a hole in face?
Edit:
As Aldrik mentions in the comments below, another option is to subdivide the surface to get some geometry and use the To Sphere function with Shift + Alt + S. This isn't always perfect in my experience but can work at times.


Thats because you are already controlling the value with keyframes. Drivers and keyframes do not mix.

Select Clear Keyframes from the menu and then add driver.


How to apply the bending effect to objects that are already beveled

Edit: Ok so I screwed my answer because I've imported your object as an .obj into 2.79, so it has applied the modifier, but my answer will help to fix the problem with the face.

You've made a mistake with your object. Actually you have a series of parallel edges made of a series of vertices and that are not filled with faces, and on the bottom you have a big face.

As I suppose it's not what you want, select this face and delete it (X (Delete) > Only Faces). You now have your edges.

Make sure you have your LoopTools addon activated, select all and RMB (in 2.8) or W (in 2.7) > LoopTools > Loft, it will fill the whole thing with faces.

Now you have a shape that is already bent, so I'm not sure what you're trying to do. Also I think you might get rid of some edge loops but again, it depends on your final purpose...


How can I import an addon into a Blender script?

There are addon utilities available in 2.77/scripts/modules/addon_utils.py which you can import into your script.

Here is an overkill example, lists all addons and then tries to enable addons named ['mesh_looptools','mocap_madness','goose']

import bpy
from addon_utils import check, paths, enable

def get_all_addons(display=False):
    """
    Prints the addon state based on the user preferences.
    """
    import sys
    paths_list = paths()
    addon_list = []
    for path in paths_list:
        bpy.utils._sys_path_ensure(path)
        for mod_name, mod_path in bpy.path.module_names(path):
            is_enabled, is_loaded = check(mod_name)
            addon_list.append(mod_name)
            if display:  #for example
                print("%s default:%s loaded:%s " % (mod_name, is_enabled, is_loaded))
    return(addon_list)
#print all the addons and show if enabled and default
addons = get_all_addons(True)
#enable dependencies
addon_dependencies = ['mesh_looptools','MocapMadness','goose']
for addon in addon_dependencies:
    if addon in addons:
        is_enabled, is_loaded = check(addon)
        if not is_enabled:
            print("%s enabled" % addon)
            enable(addon)
    else:
        print("Error Dependency %s missing" % addon)

Answer from https://blenderartists.org/forum/showthread.php?234219-Check-if-Add-On-is-enabled-using-Python&p=1970462&viewfull=1#post1970462

Mainly only need

    is_enabled, is_loaded = check(addon)
    if not is_enabled:
        print("%s enabled" % addon)
        enable(addon)


Using a background image in UV editor? To trace tattoos with paint mode

All steps will be done in UV Image Editor (Paint Mode).

Create New Texture Mask, name it as you want.
Choose Mask Mapping > Stencil.
Go to Properties Panel > Texture.
Select Brush Mask - "Your texture name".
Load your tattoo image.

If you have it white on black color you can skip those steps.
Under Image Sampling Tab select Calculate.
Under Colors Tab check Ramp and switch color handles and adjust if needed.
Go back to UV Image Editor and trace your mask.

  Note: Manipulating Stencil in Mask mode is a bit different.

  Alt+RightClick - Move
  Shift+Alt+RightClick - Scale
  Ctrl+Alt+RightClick - Rotate


Rendering Freestyle strokes behind objects using alpha transparency

This is not possible in the current implementation of Freestyle.

Blender 2.79, Freestyle Known Limitations

  Transparent faces are treated as opaque faces.

@gandalf3 / Blender 2.6


Python API: bpy.context.selected_nodes gone?

You might be able to filter on node.select for your application:

mat = bpy.data.materials['checker']
nodes = [ n for n in mat.node_tree.nodes if n.select ]

Although, I'm not entirely sure how that works with node groups (where you have a compound node selected and tab into it and select other nodes).


The type of topology you are trying to create isn't supported by Blender.  BMesh stores faces as a continuous loop of edges - branches and multiple loops aren't supported (yet).

If you try and create it by merging vertices you will find Blender ejects the edge from the face, creating a wire edge.


To exaggerate motion blur use a larger value for the shutter. The slider is limited to 1, but  click on the shutter value and manually type a larger number.

Also, don't use rolling shutter, set it to none.


Can't pack blender file for rendering on a render farm

Unfortunately, Blender does not quite pack all external files. According to the manual here:

  Not all external files can be packed

  Some typically heavy external files, like video ones from the Sequence
  Editor or Movie Clips, cannot be packed in a blend-file.

I would look into the render farm that you are using. Some of them may have a workaround for this issue. Looking at those video sizes though, even just uploading 1+ GB of video would take quite a while.


Blender 2.8 manual vertex coordinate editing

feel quite dumb with this one, the Sidebar is less visible and toggled off by default (for my install at least). The data can be found by toggling it on (pressing N).


Why is my armature not showing in animation layout, but it shows in the default layout?

It looks like you are using Rigify and haven't created the actual rig yet. Your Blender also looks strange as there are not Layers on the header for the 3d View. With your mouse cursor over the 3d view press the ` key (above Tab) to hide/show all layers. As this may also be the case.

Go to your user settings (ctrl+alt+u) and select the File tab. Then make sure Auto Run Python Scripts is check marked.


Camera perspective in viewport is different to in render

It's because you're zoomed in on the viewport, and can't see the edge of your camera.

In the viewport, use the mousewheel to zoom out until the edge of the camera shows up. Select the camera, and move the camera forward with G MMB


I added the "Cross" Effect strip to two text strips and it's making the background image transparent

The scene you have as the background clip is set to have a transparent background and in the sequencer preview you have enabled the alpha view.

You can turn off the scene background transparency in the render settings under Shading.

To not see the background transparency in the preview you can change to colour only display in the header.

Another option is to add another strip to use as the background, this can be a simple colour effect strip to have a solid colour behind everything.


Converting program specific functions to Blender in python

I'm not sure why your bytes code became split into lines. I think this is stackexchange, but if this is done by bs.readBytes(0x40) you need to concatenate all lines before you will be able to decode them into floats. Decoding can be done with built-in memoryview() method or with built-in struct module, like  struct.unpack('f', bs.readBytes(0x40)). After that you can arrange floats into tuples. For example like this (consider bs.readBytes(0x40) doesn't split result into lines):
# readBytes_result = bs.readBytes(0x40)
def readBytes_to_vector(readBytes_result):
    bytes_to_floats = memoryview(readBytes_result).cast('f')
    counter = 0
    axis = []
    my_floats = []
    for fl in bytes_to_floats:
        axis.append(fl)
        counter+=1
        if counter == 4:
            counter=0
            my_floats.append(tuple(axis))
            axis = []
    return tuple(my_floats)

I prefer to use memoryview instead of struct because though it returns its own "memoryview object" instead of sequence of values (which is not always very handy) it is faster, especially when you need to handle large bytes arrays, like pixel data for example.


You can assign a Viewport color to your material.
That way, all objects with the same material will have one distinct color in Solid view.


Dynamic Paint with object material in cycles

You should be able to use an attribute node with the value of dp_paintmap(if you are using the default) and connect that to the factor input of a mix node.

  Your painted material will be on the bottom while the other material will be on the top.  Be sure that you hit the plus next to Paintmap under Dynamic Paint Output in the Physics tab.


Constant error message in console - reinstall and factory settings doesn't fix

The problem is due to Render Street trying to read a configuration file. To remove the add-on completely (despite not showing up in User Preferences) remove the Render Street folder from within the (c:\program files\)Blender Foundation\Blender\(version)\scripts\startup directory.


How do I make 'Selection only' off by default when exporting?

That's actually pretty possible and only becomes a problem when you install a new Blender version.

In your installation directory, you have the path:
scripts\addons\io_mesh_stl\

In that folder, there should be the .py files concerning stl import/export.

__init__.py

is the one to open and mutilate.

In line 166, I find:

use_selection = BoolProperty(
        name="Selection Only",
        description="Export selected objects only",
        default=False,
        )

The only thing you need to do is to turn 'False' into 'True' and you should have your checkbox filled by default. The same way you can adjust any default setting. Endless possibilities.


Pinning vertex on soft body to mesh not working

You can add a hook modifier to your rope (use CTRL-H from edit mode, having selected your pinning vertex, to hook this up to an empty), and parent the resulting empty to your javelin.


Getting mouse position relative to movie clip

If you run this script in Blender's text editor, you can press L with your mouse in the preview window to get the position of the mouse in pixels relative to the bottom left corner of the video clip.

import bpy

bl_info = {"name": "Mouse Pos", "category": "Sequencer"}

class GetMousePos(bpy.types.Operator):
    bl_idname = "mouse_pos.get_mouse_pos"
    bl_label = "Get Mouse Pos"

    def invoke(self, context, event):
        # Size of the preview region
        width = context.region.width
        height = context.region.height

        fac = 1.0

        prs = bpy.context.space_data.proxy_render_size
        res_perc = bpy.context.scene.render.resolution_percentage

        if prs == 'SCENE':
            fac = res_perc / 100

        rv1 = context.region.view2d.region_to_view(0, 0)
        rv2 = context.region.view2d.region_to_view(width, height)

        preview_zoom = (width / (rv2[0] - rv1[0]))

        # Resolution of the scene
        res_x = context.scene.render.resolution_x
        res_y = context.scene.render.resolution_y

        # Distance of video preview from bottom left corner
        offset_x = -int((rv1[0] + ((res_x * fac) / 2)) * preview_zoom)
        offset_y = -int((rv1[1] + ((res_y * fac) / 2)) * preview_zoom)

        print(event.mouse_region_x - offset_x, event.mouse_region_y - offset_y)

        return {'FINISHED'}

def register():
    bpy.utils.register_class(GetMousePos)

    keyconfig = bpy.context.window_manager.keyconfigs['Blender Addon']
    km = keyconfig.keymaps["SequencerPreview"]

    kmi = km.keymap_items.new("mouse_pos.get_mouse_pos", 'L', 'PRESS')

def unregister():
    bpy.utils.unregister_class(GetMousePos)

    keyconfig = bpy.context.window_manager.keyconfigs['Blender Addon']
    km = keyconfig.keymaps["SequencerPreview"]
    for kmi in km.keymap_items:
        if kmi.idname == "mouse_pos.get_mouse_pos":
            km.keymap_items.remove(kmi)

    bpy.utils.unregister_module(__name__)

register()


In this case Ctrl + Uparrow is what you need. Or the "return to previous" button up the top.
You've entered the 'maximized' view mode which makes one panel (in this case the 3D view) occupy the whole screen.

Another very useful trick is to create a new file (File -> New) and then open your file with out loading the UI. To open a file without loading the UI, go File -> Open and then select your file, and uncheck the 'Load UI' button on the lower left before opening it,


A lot of objects are disabled for rendering:

see: Object not visible in render


Is there a fast way to make lamp brighter?

As suggested by @JachymMichal, Just keep the lamp section open on the properties window.
There is a good reason to keep intensity of the light as a completely separate control.
Intensity and lamp size are two very different qualities.
Scaling the light it will just change the quality of the shadow. A very smalll light source will give a very defined sharp shadow. A large source will yield softer less defined shadows.


How can I display what happens in the system console inside blender's console?

First redirect output from Python's stdout into your own buffer,see: How to redirect output from 'bpy.ops.*'?
Then run bpy.ops.console.scrollback_append with the console space set using an override, see: https://blender.stackexchange.com/a/31398/55

Hello world example that prints text into the first console found.

import bpy

def console_get():
    for area in bpy.context.screen.areas:
        if area.type == 'CONSOLE':
            for space in area.spaces:
                if space.type == 'CONSOLE':
                    return area, space
    return None, None

def console_write(text):
    area, space = console_get()
    if space is None:
        return

    context = bpy.context.copy()
    context.update(dict(
        space=space,
        area=area,
    ))
    for line in text.split("\n"):
        bpy.ops.console.scrollback_append(context, text=line, type='OUTPUT')

console_write("Hello World")


Custom NodeTree and NodeCustomGroup and bpy.ops.node.tree_path_parent()

I'm not sure how useful this is to people (see a sverchok branch which implements this). I'll provide this as answer to my question, because that's what it does -- whether or not this allows for a functional custom node_tree group implementation is still up in the air.

It seems the way to get the node.tree_path_parent to poll True is to repopulate the context.space_data.path with the parent tree at index 0 and the new group node (a tree under the hood) at index 1.

def group_make(self, new_group_name):
    self.node_tree = bpy.data.node_groups.new(new_group_name, 'SverchCustomTreeType')
    self.group_name = self.node_tree.name

    nodes = self.node_tree.nodes
    inputnode = nodes.new('SvGroupInputsNode')
    outputnode = nodes.new('SvGroupOutputsNode')
    inputnode.location = (-300, 0)
    outputnode.location = (300, 0)
    return self.node_tree

class SvGroupEdit(bpy.types.Operator):
    bl_idname = "node.sv_group_edit"
    bl_label = "edits an sv group"

    group_name = StringProperty()

    def execute(self, context):
        node = context.node
        ng = bpy.data.node_groups

        group_node = ng.get(self.group_name)
        if not group_node:
            group_node = group_make(node, new_group_name=self.group_name)

        bpy.ops.node.sv_switch_layout(layout_name=self.group_name)
        # context.space_data.node_tree = ng[self.group_name]  # does the same

        # by switching, space_data is now different
        parent_tree_name = node.id_data.name
        path = context.space_data.path
        path.clear()
        path.append(ng[parent_tree_name]) # below the green opacity layer
        path.append(ng[self.group_name])  # top level

        return {"FINISHED"}

However, when hitting the back button (tree_path_parent) the active node_tree isn't set. Why? I suspect it's due to using .clear() instead of .pop() and some loss of information. This means we need to roll our own version of tree_path_parent, to switch the node_tree and then set the context.space_data.node_tree to the desired parent tree.

Something like:

class SvTreePathParent(bpy.types.Operator):
    '''Go to parent node tree'''
    bl_idname = "node.sv_tree_path_parent"
    bl_label = "Parent Sv Node Tree"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR' and len(space.path) > 1

    def execute(self, context):
        space = context.space_data
        space.path.pop()
        context.space_data.node_tree = space.path[0].node_tree
        return {'FINISHED'}

Bottom left in the screenshot i prepended the operator button for node.sv_tree_path_parent.


Play around with the radius settings for denoise.

On the other hand you can get a very clean render disabling denoise all together and using clamp indirect.

Here's your scene with no denoise and Clamp indirect 10.0


What would be the easiest way to do or simulate color cycling for a face?

One way would be to animate the texture mapping.

Create an image with the colour gradient you want to use.
UV unwrap your object
Apply the image in the texture panel
Add keyframes for the mapping offset (RMB / insert keyframe).

For cycles the same thing applies - the keyframes can be added in the Mapping node.


To get the driver

Py console code. Look at the drivers collection in the animation data. (animation data can be None need to test)

Default file with cube selected and active. Cube has a deform modifier mod  name "SimpleDeform".  The "angle" property of the modifier has driver.  One component of the cubes location has a driver.

>>> ob = C.object
>>> for fcurve in ob.animation_data.drivers:
...     fcurve.data_path
...
'location'
'modifiers["SimpleDeform"].angle'

Just as we added the driver to the modifier, we can get the path from the ID object (in this case bpy.types.Object type context object)

>>> mod =  C.object.modifiers['SimpleDeform']

>>> mod.id_data
bpy.data.objects['Cube']

>>> mod.id_data is C.object
True

>>> mod.path_from_id("angle")
'modifiers["SimpleDeform"].angle'

This is our "key" to finding driver

>>> key = 'modifiers["SimpleDeform"].angle'
>>> fcurve = C.object.animation_data.drivers.find(key)
>>> fcurve
bpy.data.objects['Cube']...FCurve

>>> fcurve.driver.expression
'var + 0.785'

>>> key = "badkey"
>>> C.object.animation_data.drivers.find(key) is None
True

Here is a helper method, pass an object which returns the angle property driver of a deform modifier named modname or None

def get_deform_angle_driver(ob, modname):
    # does ob have modifiers
    if not hasattr(ob, "modifiers"):
        return None
    # does ob have animation data
    ad = ob.animation_data
    if not ad:
        return None
    # does ob have a modifier of that name
    bend = ob.modifiers.get(modname)
    if not bend:
        return None
    # make the key
    key = bend.path_from_id("angle")
    #key = 'modifiers["%s"].angle' % modname
    fcurve = ad.drivers.find(key)
    # is there a driver fcurve?
    if not fcurve:
        return None
    # woo hoo.. return the drive fcurve
    driver = fcurve.driver

    #driver.expression = "sin(frame/20)"

    return fcurve

# test code
import bpy
ob = bpy.context.object
fcurve = get_deform_angle_driver(ob, "bend")
print(fcurve)


Is there a way to limit max RAM usage by Blender?

You cannot do inside blender, but if you are on windows you can check if these software can help you:

Process Tamer :
https://www.donationcoder.com/Software/Mouser/proctamer/
Process Lasso : https://bitsum.com/