How to move selected UV Island? I want to move the island in UV Editor, but it moves the faces in the 3D View

bpy.ops.transform.translate(value=(0.0192062, 0.49296, 0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

in Blender 2.71 with python

You need to set the context's area type first, run the folowing script from the text editor not from the console:

import bpy
area = bpy.context.area.type
bpy.context.area.type = 'IMAGE_EDITOR'
bpy.ops.transform.translate(value=(-0.209548, 0.232831, 0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
bpy.context.area.type = area

Related

Python - move UV for selected items


Can I make a custom node from a group and have that available in other projects? I've found some neat combinations of nodes to create certain effects, so I'd like to make them a group and then have that node available on my list of available nodes, even when I reload the startup file. How would I do that?

You can save the startup .blend by clicking File > Defaults > Save Startup File. This will save everything (except for user preferences) to be loaded as the default state when Blender starts up. That includes all geometry, textures, brushes, node groups, UI layouts, the 3D view orientation, etc.
I like to save my node groups in a separate "library" file and link/append them in, that way I don't accidentally lose them if I overwrite my startup file on accident (I've done that before..)
How to embed a node group in the startup file

If you haven't already, make a node group by selecting the nodes and pressing CtrlG (AltG to ungroup).

Save it (CtrlS)

Open your startup file (CtrlN)

Press File > Link or File > Append. In the file manager which appears, navigate inside the file with the node group, select NodeTree and then select the node group.

Linking means the node group is only stored in the "library file" and if you make any changes to it, those changes will carry over to your startup file (also, if the library file is deleted or moved, the node group will be missing in the startup file).

Appending copies the node group so it will always work.

In the node editor, add the node group (ShiftA> Groups > group name) and press the F icon (F for Fake User) on the node to save the data block even if it has no users. This will ensure the node group is saved even if it is not used in any materials/node trees in that file.

Delete the group node (Del). Provided you enabled Fake User by clicking the F icon, it will still be in the add menu even after reloading the file. Rearrange the UI how you want it to appear when you start blender.

Save the startup .blend (File > Defaults > Save Startup File).

This procedure should be the same for all types of nodes (Composite, shader, etc.)


How to tile the Gradient Texture node with the spherical gradient type? How do I make it repeat itself along the X-axis?

This is a little more complex than the linked question due to the spherical gradient texture needing a range of [-1,1] to generate a full circle.

The modulo(1) function will generate a repeating pattern by mapping positive values to a new value in [0,1] and negative values to a value in [-1,0]. This means that half the circle will be repeated in either direction from 0, not what we want.

Instead we can generate two versions of our repeating pattern that each work for just one side of the zero point, and then combine them by masking out values we don't want and using a maximum:

Modulo(x,2) - 1 generates a repeating [-1,1] range for x > 0 and [-3,-1] otherwise
Modulo(x,2) + 1 generates a repeating [-1,1] range for x < 0 and [1,3] otherwise. This [1,3] range will present problems when combining each side with maximum so we need to set it to something less than or equal to 0
By exploiting the fact that the spherical gradient is symmetrical around x=0, we can invert the part from (2) to avoid the issues with maximum.


Random Index from List(Subprogram) Animation nodesV2/Blender 2.79

Trying to get a Random Index  as a part of a Subprogram.

Attempt 1 -  GetRandomListElement not updating in viewport
GetRandomListElement is not updating in the viewport (eventhough the colors change in viewer on update).Tried using ViewportMaterial & SetVertexColor Nodes.

Attempt 2 -  IterationCount not connecting to RandomNumber Node
While trying to extract a random index from a Color List for animation ,their doesn't seem to be any node which calculates the total iterations in the list.

On connecting the IterationsCount(Invoke subprogram) to the random number node ,all nodes get red.

How to extract a random index from a list (as a part of a Subprogram)?

I don't think you need to get this kind of convoluted node tree if you just want a random color.

The "Get Random Elements" node has a "Single" mode which will output a single randomly chosen value.

The setup :

Result :

If you just want a random index, you can use the "random" node with a floor math node.


preventing hands going through floor I'm really hoping someone can help - been stuck for months now. I'm completely new to blender and animation in general. I've managed to find a pre-rigged model online - I want to create an exercise animation using the model - while the feet dont go through the floor when animating; the hands do for example when trying to create a push up animation. Is there anyway to get round this? I am completely new to all of this so any help with simple instructions would be much appreciated. I would have attached the blender file - but dont think you can on here.

Blend file below...

A lot may depend on how your rig is set up but placing Empties as 'ik targets', (not pole targets) at limb extremities does lend itself to this sort of thing quite well. By that I mean hand and foot targets as against lower arm and leg.  The hand targets are simply placed on the floor, the feet versions placed where they're needed.

For push-ups, some upper-arm Quatemion adjustments (pose mode) will likely be necessary due to extreme bending at the joints.
The character's origin point needs to be set at the feet so the armature can be rotated from there -
Once the first push-up is done, it's a simple matter of either duplication in the Dopesheet or cycling the action.
A "Nav"(igation) handle, an Empty would also be placed at the OP and the armature and targets parented to that.  This would hold it all together and provide a 'handle' with which to drag the whole thing about -


What is the best way to make sure a clothing piece will animate with a body mesh and not clip? I am trying to create clothing for a body mesh of mine. I want the clothing piece to be able to animate along with the skeleton without experiencing clipping with the body mesh. What is the best way to go about this? I've tried applying automatic weight paint which was a mess trying to fix (so much clipping). I also tried data transfer on vertex groups which gave me no success. Any ideas? Thanks.

One popular way is to hide body mesh parts under cloth using mask modifier. Other is to use Lattice modifier to deform cloth. Here is a tutorial on this topic


Blender 2.49b opens with all tools and menus super small - how to fix? I am using version 2.49b because my work requires it. I changed the font using "User Preferences" but that only changed the top menu. Any help is appreciated! I am new to Blender.

Go to "Panels - View all" or press the Home key on your keyboard. This  should align the panels according to the size of your Buttons window.

If you want to resize the panels manually, you can do this by pressing Ctrl and use your Mouse Wheel to adjust the size.


Object -> Edit / Change of position I've modeled an object, rigged the body and was going to rig the face when I noticed that when i change between "Object mode", "Edit mode" and "Pose mode", it changes position.In "Object mode" and "Pose mode" it is on 0,0,0 but when I change to "Edit mode" it suddenly moves out of location in all three axis.Attaching an image for better clarification.

Moving the object in "Object mode" to the position it is in "Edit mode" also changes it in that tab, and vice versa.How can I reset it so it stays on the supposed main location as it is in "Object mode"?

Thanks in advance

Thank you for your help, I did that and although it all stays in the
  same position which was what I was looking for, they stay on the
  position it was in "Edit mode". I would like to have my character
  aligned with all the axis. How can I do that?

You have to align it in Edit Mode.

Edit mode is like if it was more important than the other modes, it goes something like Edit Mode > Object Mode > Pose Mode. This is like this because in edit mode you have the information of the mesh, in object mode the information of where is the mesh (and it's rotation) and in pose mode you have the information about how is the mesh deformed.

So use blender with this hierarchy in mind and you will ready to go.


How to add hotkey for mouse 4th button to delete in edit mode I can get my mouse 4th button to map to delete in object mode but not in edit mode. I also don't see an edit mode keyboard configuration section in Blender preferences menu.

Open up the User Preferences, and head to the Input tab. Open the 3D View section, and inside of that the Mesh section. Now scroll to the bottom of the Mesh section and you will find an Add New button.

Now what to put in the Identifier field?

If you want the 4th mouse button to simply bring up the menu (like pressing X or Delete) then use wm.call_menu as the Identifier (top field) and put VIEW3D_MT_edit_mesh_delete in the name filed that will appear at the bottom. Yes it will be grayed out, but you can still click in it and add the text.

Or if you want to be able to directly delete, say vertices, by pressing the 4th button, then set up a shortcut like this:

Now the shortcut is calling mesh.delete directly instead of calling for the menu. Then just pick which Type you want to delete. You'll notice that I have "Ctrl" checked there. This way I can press the 4th button to open up the delete menu. Yet I still can directly delete vertices, edges, and faces by holding CtrlAltShift respectively.
You have to add more shortcut entries for each "type" you want to delete.


Modify a single plane mesh to match image based on alphas, create shape keys My goal is to create the shapes of continents as they drifted from Gondwana to the present day.

My proposed approach follows, but I would welcome alternate approaches or comments on this approach.

I would like to start with a plane, subdivided. I would like to be able to modify the outside shape of the plane to match an alpha: The plane would shape to fit the alpha without eliminating any verts. I'd then create a shape key for the plane in its new shape.

I'd then like to create a new shape for that plane, based on a new alpha. I'd create a new shape key for this new shape.

The goal is to be able to create a series of shape keys on a single mesh, and be able to move between the shapes... like a tweening process between shapes.

EDIT:
The requirement is for continents which both move and change shape.

I have experimented with shape keys quite a bit, but as noted in the comments and answers suggested thus far, it's pretty nightmarish.

I have also tried to use shrinkwrap modifiers to create shapekeys, but the shrinkwrap encloses the shape without fully conforming to it:

I don't actually need Texas as a shape, but it shows the problem with (my understanding and use of) the shrinkwrap modifier.

I have these planes on a sphere. All origins are at 0 0 0 and moving and rotating across the globe is easy... but finding a way to accurately change shapes is hard.  I understand and have used textures with alphas and displacements, but the requirement is for a level of positional accuracy and fidelity to particular dates that is ill suited to textures...  I need more constant shape modification to the continents...

If the animation will be planar (2D) I suggest you to subdivide the continents in a 2D software (Gimp, Krita, Photoshop), make a transparent PNG for each and import every continent as "Image as planes" (it's an addon), without caring the shape of the mesh; then you can set one location "jointed" and - some frames away - the location "drifted".

If it will be 3D, all PNG planes should be subdivided, shrinkwrapped to a sphere and moved with a rotation with pivot point centered in the center of the sphere.


Project 3D Object on a plane I have 3D Objects I want to convert to 2D Geometries by projecting onto a plane. Is that possible with Blender? If possible in an automatic way. An export to a Shapefile would be fine too.

For instance, I have a 3D building and I would like to get the 2D Geometry as if the Object were parallel projected on the ground plane (for instance the x-z-plane).

A box/cube would either become a rectangle or an hexagon depending on the rotation.

Place a plane on the axis you want (for instance x, z).

Add a shrinkwrap modifier to your mesh and set this plane as target object (mode = 'nearest surface point').

Of course you can also scale to zero along an axis... but the shrinkwrap allows to do it in a none destructive way and to project to any plane.


How to import many images so assign to texture_node and duplicate "n" times objects and materials? I am searching a way to:

duplicate a selected object and It's material 244 times..
import 244 photos (image_000, image_001, ...) in the scene
assign these images to an image_texture node (included in the material previously duplicated)
every material should have a name that follows the object's one: object.000 > material.000 ...

any way to do this? maybe by script.. I tried some but cannot find a way to duplicate last operation for more than one time

bpy.ops.object.duplicate()

My actual node setup is this:

I need to replace the actual image texture with another one that follows the same rule of images and materials: 000, 001, ... (or not.. I think this way It should be simpler and clear).

EDIT 01
in response to Parkuhr's answer:

something went wrong at line 29.. what am I missing? materials has successfully been created..is maybe because objects are missing? I started a new scene without objects/orphan data

EDIT 02 - ANIMATION NODES way

I currently figured out how to duplicate objects and it's materials by animation node

but not how to

make an independent material for each of these objects
linking the images to the texture node of every single material with the same end-name %0Nd

You could use the import images as planes add-on from preferences->add-ons to quickly import your 244 photos as a plane with matching dimensions. The add-on lets you set basic material options for cycles and bi on import.
The created planes and materials get the same name as the image. After import, you would just need to place the planes on the correct locations in your scene.


Scaling according to selected face a complete newbie at blender would very much appreciate some help.

I did something, and now every time I scale a number of faces, they are scaled according to the main selected face, rather than according to the imaginary middle point between all faces.

I need to get it back to normal, and I have no idea how.
Please help!

Active element is set as pivot point:

Set it back to "median point".


Blender 2.79, how to install Khronos Group gltf exporter? I downloaded the KhronosGroup addon from https://github.com/KhronosGroup/glTF-Blender-Exporter
I read install instructions, but those were for Windows.
I tried copying the addon under ~/.blender/2.79/scripts/addons/io_scene_gltf2 but Blender shows nothing
I tried to install via "install from file" and selecting the exporter .py file directly but nothing happens.
I checked version, I am sitting in 2.79 Blender and the script is for 2.78. I tried to fool Blender by changing the scripts version in to 2.79 but no luck.

Any way to get this thing to work on Linux and on this Blender version?

Thank you gandalf3. My mistake was the path.
I tried ~/.blender folder when in fact I had to copy the addon under ~/.config/blender/..

Works now, thank you again!


How would I import/export Blender's preferences? I constantly stay up to date with each new release of Blender, but this means my preferences are wiped clean each time. How do I export/import these preferences to avoid loosing my carefully crafted set up each time?

Depending which OS you're on, navigate to:
Linux
~/.config/blender

Mac
/Users/username/Library/Application Support/Blender/
Windows
%APPDATA%\Blender Foundation\Blender

Once there you should see folder(s) corresponding to the version(s) you currently have.

In my case here I have 2.66 and 2.67, just open the previous folder (2.66) since I had saved my settings there earlier and copy the config folder to the new one (2.67). What you really want however is the startup.blend and userpref.blend inside.


Rough and odd edges on mesh objects I am a beginner with Blender. I only need to create a 10-block 3d object (pic 1). I created this object by having 10 meshes and 10 wires of the same size on top of the same mesh. The rendered image has very rough and irregular edges. I don't know whether I have done something wrong in the Material section or the wireframe modifier (pic 2).

Thank you very much in advance.

For what it looks like you're trying to do, it would probably be best to use Freestyle, which detects edges in your scene and outlines them. That way you can forget about the wireframe and let Freestyle handle that.

You turn on Freestyle from the Render settings, the leftmost tab of the Properties panel.

It has one option in the Render tab, whether line thickness is absolute (pixels) or relative to image size, and all the  rest  are in the  Render Layers tab, one to the right. Here you can tweak everything about Freestyle—the color and thickness of the lines, which edges are drawn over, and a whole lot more.


Matcaps not showing up I was working on sculpting and wanted to apply a matcap, however when I go and turn on matcaps nothing shows up.
I am in blender render and just updated, is there any setting that could be causing this? I'm fairly new to sculpting and materials, but not very new to Blender in general.
Here's a screenshot of what's going on.

it's not a problem of configuration, surely something will be damaged in your folder in .appdata where it hosts temporary blender configuration, I do not know if you use linux or windows, but I'll give you an example in windows that is the most common
you would have to delete that folder inside .appdata and restart blender, if the problem is solved it would be everything, but if the problem you got, it means that your blender is damaged, and it would be more difficult than you think to be doing a debug, my choice would be to reinstall blender cleanly, deleting all traces of the previous installation, that means using blichbit or ccelaner and eliminate what you find from blender in .appdata

NOTE: it is important that before doing all this, make a backup of all your addons that you have added, because when you delete this folder you will lose all
or you can make a list of the ones you have and download them once more


Blender Equivalent to Padding? Does Blender have any function to create a sort of padding/margin in Edit Mode? Let's say I have a plane and I'd like to have a smaller plane inside of this first one with even distance towards all the edges.

Please take a look at the image to see what I'm talking about:

You can use Inset Faces. It doesn't do it exactly like in your image. Instead it looks like this.

Select the faces you want to inset and press I and drag the mouse. It works with  multiple faces as well.

And if you do II when you have multiple faces selected, it will inset them individually.

Instead of dragging the mouse, you can type the inset distance immediately after I or II.

This doesn't pad the plane outwards, increasing its size, but rather insets within the current size. This can, of course, be remedied by scaling it up before insetting. Also, as you can see, the corners are handled differently.


Baking textures: Circular Reference in texture stack error I'm getting this error when I try to bake textures on my model. It says "Circular reference in texture stack". I found some info on the net. It says I should disable a texture in the texture stack so Blender won't write the texture on itself. But I don't have any textures in the texture stack. I only have simple materials, no image textures. I'm using Blender Internal, 2.75a. So what should I do to bake the materials into textures? I'm attaching 2 screenshots. The texture is rendered partially, I don't know why. There should be more green and also white (there are two materials on the object, green and white), but it stopped halfway. Also note: I did make an empty image for each UV I unwrapped, before baking.

Screenshot 1:

Screenshot 2:

One example when this occurs is when the receiving image is used as a texture e.g. (has been unchecked) the issue can be reproduced by checking the enable/disable checkbox.

Either way baking worked


Customizing Move Hotkey I'm new to Blender and I'd love for Move to be M not G. I've done edit> preferences > Input > Transform Modal Map > Mode > changed the input to M instead of G. And it has had no effect. I even made sure to turn off the M input for "move active object to collection". What am I missing?

i think you have to remove every other keybinding to "M" so there are no conflicts.

For me,

3dview -> object mode-> move to collection is blocking

but I would advise you to use "G" for G.rab as it is, because it's not Move - it is grab. You grab stuff in all Editor windows and then you move it around… Keyframes in DopeSheet, or things in the Viewport and I belive in you, you will adjust your Habits and you will handle that.
In a few weeks you will not go back.
You will G -> X ->5 and R -> Y ->90 and G-> Z -> 4 like a Pro!


Selectively mix shaders based on color input This might be a bit confusing, so my apologies before hand.
I'm making a shader/nodegroup that emulates colors under a blacklight. For most colors (greens, reds, blues), it works just fine and looks perfect, but for others (whites and yellows) the result isn't what's expected.

What I'd like to do, is be able to have the shader recognize that the color input is white, yellow or any of the other colors that don't work right, and be able to isolate them so I can correct them with the proper nodes. But I'd also like to have it know when I'm using the colors that do work, and not apply the corrections.
So basically, selectively apply corrections based on the input color.

I imagine the solution is probably some logic type stuff using math nodes and maybe the separate RGB nodes and such, but honestly that is beyond me. It's obviously possible to just use 2 separate groups or inputs for them, but I'd ideally like to be able to plug in image textures and such and have it "just work".

Any help would be much appreciated.

To pick out similar colors in a spectrum, there has to be a notion of a distance between colors, which more or less makes sense to the eye. One (perhaps naive) way to do it would be just to take the 3D distance between colors in whichever space you are using for comparison. If that's RGB, that would be sqrt(dR*dR + dG*dG + dB*dB). You could put this in a node group:

Starting with the colors in the top left, supposing for the black light effect we generally just saturate the colors a bit. (top right).

Then we can use the RGB-Distance node group to pick out colors similar to examples we've picked.

The bottom left square above shows the output of the top Color Ramp node in the tree below. It's a mask of colors which are quite-like-white in the original (top left) square.

Masks like that can be used as factors to mix between the saturated tiles and the ones we've picked out for special treatment. The top branch picks out whites, and replaces them with a darker blue, and the bottom branch replaces yellowish squares with magenta.

This might do it for you on its own.. but it could be tweaked to place more emphasis on hue, brightness, etc., by changing the definition of distance between colors.

I should point out that to keep things linear, and let me E use an eyedropper to pick colors from the  screen, I've set the color-management in the .blend to Raw, with no sRGB in the display. You will probably want to change that.


How do I enable motion blur for Mantaflow fluids? How do I enable motion blur for Mantaflow fluids? I'm using 2.82

When you bake the mesh for your liquid on the domain, make sure "use speed vectors" is checked in the mesh tab.  If it wasn't then you will have to bake the mesh again.  After that, it will automatically render motion blur if you are using Cycles.


Export animation from blender to a threes.js program I am trying to export an animation from Blender to a program using Three.js. The animation is  a boolean modifier. I don't know how export it from Blender correctly and after how to insert it in my three js program. I want to export it using the collada format because the .json three js export, doesn't work well, in my program.

There are two things here:

you need help with three.js exporter addon and
the thing you are trying to export isn't supported.

The current Three.js exporter will export certain types of animation, but  an animation where the Boolean modifier is of prime importance (modifying the mesh every frame) isn't going to work as you hoped. For that to work Three.js would need to have a way to deal with the boolean operation, and it would need to be analogous to Blender's Boolean modifier. To my knowledge Three.js has no such feature.

The exporter by MrDoob and associates strips out modifiers by applying them if possible. The boolean modifier can't really be applied per frame unless you export the mesh (per frame) to a format that Three.js knows how to handle (per frame). But that turns into a different question, that you might want to ask on github issue tracker of Three.js


How do I list all the files used in a .blend file? I need to cleanup my rushes/footages directories, so I'd like to be able to list, in command line, all the files referenced in a .blend file. I need to be able to, for every file found in a given directory, check if it is used in a particular .blend file.

You could use http://web.purplefrog.com/~thoth/blender/python-cookbook/list-referenced-files.html as a starting point:

import bpy
import os

def debug_print(msg):
    print(msg)

def list_referenced_images():
    rval = set()
    for img in bpy.data.images:
        if img.filepath is not None:
            debug_print ("IMAGE %s"%img.filepath)
            rval.add(bpy.path.abspath(img.filepath))
    return rval

def paths_for_vse_strip(strip):
    if hasattr(strip, "filepath"):
        return [ strip.filepath ]
    if hasattr(strip, "directory"):
        return [ strip.directory+elt.filename for elt in strip.elements ]
    return []

def list_vse_references():
    rval = set()
    for scn in bpy.data.scenes:
        if scn.sequence_editor is not None:
            for strip in scn.sequence_editor.sequences_all:
                for path in paths_for_vse_strip(strip):
                    debug_print("VSE %s"%path)
                    rval.add(bpy.path.abspath(path))
    return rval

def file_is_used(f, used):
    if f in used:
        return True

    # OMG, windows.  WTF?
    for f2 in used:
        if os.path.samefile(f2, f):
            return True

    return False

def mission1():
    used  = set()
    used.update( list_referenced_images() )
    used.update( list_vse_references() )

    dir = "/var/tmp/blender"
    for f in sorted(os.listdir(dir)):
        f2 = os.path.join(dir, f)
        if file_is_used(f2, used):
            print("USED\t%s"%f2)
        else:
            print("UNUSED\t%s"%f2)

mission1()

There is a good chance there are other external references somewhere in the data model, but those were the two that popped into my head (images and VSE).


How to Check How Many Frames You Have Left to Render I've been rendering an intro for a tediously long time, and I'm wondering how many frames I have left to render. How do I check how many frames I have left to render in my intro?
Does anything from the image below indicate the number of frames I have left to render in my intro?

It looks like it is on frame 11, subtract that from the total number of frames (Check your timeline, Blender usually starts with 250 frames in the timeline), If you don't need that many frames, lower that number and it should finish quicker.


What can a custom cycles shader do? It is my understanding that Cycles is a ray/path tracing render engine, and that it works by firing out "sightlines" into the scene to render, which interact with materials they hit in a defined manner to produce the color of a given pixel.

I know there are materials such as glass, which refract the ray so it travels at a slightly different angle, mirrors, which reflect the ray into another part of the scene, and diffusive materials which scatter several rays in different directions.  Additionally, there are "special" materials like the holdout which simply force the given pixel to be transparent.

Given this information, I would assume that it is possible for there to be materials or shaders which instruct an incoming ray to behave in specially defined ways, such as reflecting directly back at the camera, or translating a set distance through the scene.

This got me wondering if it is possible for a custom shader to define such actions?  I have seen OSL shaders which give materials a "toony" look, and other such styles that would not be possible using the standard nodes, but I haven't been able to find any information regarding what a custom shader can and can't do, and how it would be done.

Is OSL the only way to define custom shaders?  Can a plugin be written such that it responds when any given ray hits it, or are there only ways to specify general rules for handling a ray?

Using an OSL script is the closest you can come to modifying cycles without modifying the cycles source code and building your own version. Using an OSL script we can create nodes that perform any calculations we may want to do. These nodes can be incorporated into a node tree the same as any built-in node that exists in blender. You can look at how existing nodes are implemented using OSL. The main consideration with OSL scripts is that there is no GPU rendering support.

An OSL script can be as simple as a math node with a numeric input that does a calculation and outputs a numeric value, or at the extreme an OSL script can be used to create a ray tracing engine that runs within cycles. François Gastaldo created an OSL script that re-creates the old 1986 juggler animation on the surface of an object, he later also created a full path tracing engine - these were made for educational purposes as François is a teacher but serve as good examples of not being limited by how complex an OSL script can be.

If you look at tables 6.1 and 6.2 on page 39 of the OSL specification you will see the data available from the render engine that can be used within an OSL script. Most of the data is read only, we can only alter data such as the location of the point that the ray has hit, the surface normal and the closure that describes the colour used to get the final image. This means we can't directly alter the ray as it passes through the scene or how it interacts with other objects but we can use an OSL script to distort the surface of an object, that should make it possible to connect the camera vector from a Texture Coordinates node to a vector input for your OSL script and use that to distort the surface normal so that it faces the camera.


How to batch convert between file formats? I have about thousands of files I need to convert into from one format to another. Both formats are handled by existing add-ons..

I assume the script process would go something like this:

Select every source file in a directory and it's sub-directories
Store the path and filename of the source format.
Delete everything in scene and import the file
Export the file to the destination format with the same path and the same filename as the original file, with a different extension.
move on to the next item

The problem is that I have very little experience with Blender, and Python is not my area. The manual solution of importing and exporting works perfectly fine, as there is no need for anything to be modified.

Set the path variable and change the import line to whatever importer you are using :

import bpy
import os

path = 'C:/path/to/files/'  # set this path

for root, dirs, files in os.walk(path):
    for f in files:
        if f.endswith('.meshdata') :
            mesh_file = os.path.join(path, f)
            obj_file = os.path.splitext(mesh_file)[0] + ".obj"

            bpy.ops.object.select_all(action='SELECT')
            bpy.ops.object.delete()

            bpy.ops.import_scene.obj(filepath=mesh_file) # change this line

            bpy.ops.object.select_all(action='SELECT')

            bpy.ops.export_scene.obj(filepath=obj_file)


How to render as only wireframe in Cycles? I need to know how to render a object on Blender Cycles but only as a wireframe, for example, like this:

Also, it is possible to vary between the smooth wireframe object and the polygonal wireframe object?

Thanks in regard.

Add the Wireframe modifier and adjust the Thickness value.

Now set up the World's color to black and make the wire look brighter (replace Diffuse with an Emission shader). You may also increase its Strenght value to 2.000 or 3.000 if it isn't bright enough.

To vary between the smooth wireframe object and the polygonal wireframe object place the Subdivision Surface modifier above the Wireframe modifier and set up the desired amount of subdivisions. Now changing the type from Catmull-Clark to Simple will result in making the wire look more polygonal.

Here's the rendered result.


Using Smart Booleans with Subsurface modifier to get smooth edges I have a mesh which has the subsurface modifier applied to it. And I have made an indentation of a hole within the mesh, and the edges are catching the reflections. I also did a smart Boolean operation, but the edges are too sharp and look fake. I rearranged the modifier stack and put the Bevel above the Boolean operation, but its making it look incorrect. is there a way I can use the Smart Booleans to get reflections on the edges? I also tried the decimate modifier in case it cleans it up, also the weighted normal modifier in case it could help, but it only became worse.

Usually hard surface modeling workflow avoids to make holes in a sphere exactly due to those problems. Also you should never add subdivision before a bevel. Bevel only works well when the vertices of the sphere are not caught inside the bevel.

When they get to close you see artifacts.

The denser the topology the harder it is to keep vertices away.

That's why I suggest not to use subdivision surface.
As a pro tip you can also keep bevel segments low when you use weighted normals modifier after the bevel.
This is single segment bevel without weighted normals.

The setup I usually use:

And this is after weighted normals modifier was added.

Looks just like a bevel with many segments, but it has much smaller chance of generating artifacts.
Only other solution is to apply the modifiers and perform manual cleanup. Several commercial add-ons (I think it was BoxCutter or HardOps) ships with a script to clear the topology to fix exactly this problem.


How can I make a surface look wet in cycles? I am trying to recreate a wet road with lights reflecting off of it.
I started by making the object glossy but this did not give a very realistic look

I think I need to increase the specularity of the reflection to make it look more real but I can't find this option anywhere in cycles. Also what other techniques can I use to make a surface look wet in blender? I can link directly due to licening but this is what I am trying to recreate.

You need larger bumps. Using only the roughness from the glossy shader gives too smooth a result.

With a very quick setup:

The diffuse node represents the asphalt/road underneath the water. By mixing this with a glossy node based on the IOR of water (~1.33), it appears as if there is a thin film of specularly reflecting material (water) on top of a very bumpy diffuse material (road).

This could use a bit more large variation (cracks and large features, etc.), so you may want to use an image texture instead.


Importing video to sequencer I read somewhere a time ago that in order to do serious work on videos in the sequencer, the video file should be converted to a sequence of raw images. The procedure was briefly explained in that post, but unfortunately I can't find that post these days.

Could anybody please explain how to do that. Thanks in advance.

PS: since there were comments about specifics, my video is from Panasonic GH3 cam, .mov files h.264 format.

It ultimately depends on what format and / or where your images originate.

If they originate in a render, the best advice is to store your intermediates as EXR. Even half EXRs are tremendously more useful than many other options.

If your images originate in a camera, you'd be wise to take them to a reasonable high fidelity format such as EXR. This can be tricky depending on your needs and experience and the format of your camera.

If your images originate from a consumer grade camera and the encoded format is H264 or another codec, you can extract the raw frames using various tools such as FFMPEG or its ilk, to varying degrees of quality depending on the tool and options chosen. With proper care, even an H264 encoded file can be properly decoded to either display linear or scene linear EXRs depending on need.

Getting to a high fidelity still image format however, is only a portion of the puzzle. Coming up with a reasonable offline to online path is another challenge entirely, and critical to optimize the quality of your work if you choose to avoid the "good enough" path.


Problem with Subdivision Surface after Bevel Creating a very simple figure out of plane with Bevel modifier following by Subdivision Surface resulted in weird geometry.
Steps how to reproduce the problem:

I've used a mesh plane,
squished z-axis and applied scale,
then added 4 loop cuts,
then moved middle part with G or move tool,
afterwards added modifiers
and used shade smooth.

Normals weren't changed, all geometry is same as before, no n-gons were created. Why this might happen?
Simple plane with 4 loop cuts

Bevel settings

Subdiv settings

normals

It looks like you've only applied SubSurf to one set of faces. Try applying the solidify modifier, if you can, then bevel your edges and apply the SubSurf.


VSE: How to set as start frame where the cursor is in Blender 2.80 Blender 2.80 seems such an awesome improvement that I have immediately switched to it. However, I can't find how to do something that was easy and useful in past versions. Namely, you would press S or E while hovering with the mouse over the timeline, and the current frame would become the start or end frame respectively. How can I do that now in Blender 2.80? The S key does not do that anymore. Is there maybe an icon, or menu option somewhere?

Specifically, How to make the current frame in the vse the start frame?

In the Timeline, Playback menu, Set Start frame and Set End frame buttons. If you Right-click them and assign them a shortcut, the shortcuts will also work in the VSE.


How to create spherical textures? I'm trying to create a texture for a sphere right now. With different Blender tutorials I get a texture on the sphere, but always with distortion at the north and south pole. I use Paint.net to create my textures, but I can't create spherical textures with it. Does anyone have a tool that converts a normal texture into a spherical texture?

Since normal UV mapping creates distortions (from the vertex linear interpolation) the Generated UV coordinates usually gives better result.

Give the texture node the Generated UV coordinates and set the method to project to Sphere.

Here is a full tutorial: https://www.blenderguru.com/tutorials/earth-cycles


Problem with selecting faces vertices edges and texturing I am having trouble selecting faces vertices edges , sometimes i just cannot select at all, other times if i go through all objects in the hierarchy i stumble upon one face which gets selected. Select all sometimes works other times it doesn't, sometimes it's as if simply switching from Edit to Object mode affects the objects and i suddenly can select stuff. Not to mention that select all almost never works. I tried convert To mesh, Split by edge and then Separate by Loose Parts but there is nothing consistent sometimes i even have trouble deleting an object which is even more frustrating. Any ideas what is wrong with the geometry or maybe i am doing something wrong?
Oh and the texturing is a massive issue, i need to add a texture per face or at least 3 or 4 different materials but when i finally succed in adding a material or two like all sorts of faces start changing material and i cant find a way of removing a material from a face other than deleting the material from each individual face. ugh

Like right now i want to select all the walls and add to them a material but i can't even select the faces. Vast majority of vertices are missing.

PIcture of selected faces intended to have material and result with almost all faces getting the material -
Material gets attached to all faces which i don't want to have the Material on.

Ok. I think I fixed it. What I did was delete the light (so I could select all and only get mesh parts). In object mode, I selected all, and right click > join to make it all one piece (one mesh). I tried the CTRL+J method a couple of times first, so you might have to fiddle with it -  I don't know why it didn't work until I used the right click method. Anyway, once it was all joined into a mesh, I went to edit mode, then select all > mesh > clean up > merge by distance - because there are "seams" between the edge pieces. I counted 1160 vertices removed. After that, I had to UV unwrap again because there were overlaps, but I think it's good to go. If, in the future, you need it to be more pieces, you can always separate it later.
I'll upload a copy of the file I modified for reference.
Here it is -
Hope this helps.
EDIT - Here is your file "cleaned up" it still is not perfect - I did a quick and messy job on the UV unwrap just so I could get the textures to look decent - you may have to redo them. Also, many of the floors are still n-gons, this might not matter, but if you want to triangulate for a game engine later, you might want to make sure it's all quads first to be sure there a re no issues. I separated what "chunks" of floor looked appropriate, but obviousely, you will want to divide some of them on your own for texturing reasons - i'll leave that to you. I also have to remove your texture in order to pack the ones I used, you'll have to replace it.
Here is the (cleaned up) file.  Hope this finally works for you.


How would I procedurally texture a marble tile floor without the texture spreading across every tile? Basically I have a tile which I duplicated using an array modifier to make the floor:

Then in the node editor I created a procedural marble texture using nodes and got this:

The problem with this image is that it looks like the texture is spread across every tile, making it look unnatural. Is there a way to make the marble texture random for each tile?

Here is the blend file:

One way of doing this would be:

Separate all your tiles as a single object so you can use the Object info node random output in order the create a tile black and white mask:

You can then create another wave texture and combine it with the one you already have using the tile mask as factor:

You obviously need to change the texture coordinate of the second wave to create variation. Put a color ramp node and play with its value to have stronger difference:

http://pasteall.org/blend/index.php?id=50740

As @robin betts points out in the comments, if you need to keep the array modifier you can duplicate the object, do the same process, and bake the mask into a file image. Or if you want to keep a "semi" procedural creation use dupliface instead of the array.


Geometry Corner Mesh I'm practising with a mesh object typical cube. Added a whole bunch of cuts in the mesh. I believed the mesh is clean with no problems, until I added the subdivision surface, and down the corner of IMG 03, suddenly it's creating a triangle and also some weird unclean artefact on the surface. That I sort of cleaned adding more loop cuts, but it didnt clean 100%. But that corner triangle I cant figure out what it can cause it.

Your mesh has some n-gons and the Subdivision Modifier doesn't like it. :)
Make your mesh only from quads and it will subdivide properly.

Other little issues:

Messed up scale - Solve through Object > Apply > Scale (and check normals afterwards)
Non-manifold faces - some faces are going through another. This has to be repaired manually. Either merge the vertices, or move the faces farther away.

Quads vs. N-gons with Subdivision Modifier

Apply your object's scale to avoid problems in the future.

Here is your .blend back, repaired so you can compare :).


How to achieve Incandescence with Cycles materials Okay so heres the description of what i want i have created a logo in gimp exported its as scalable vector (svg) imported it to blender increaed the extrusion and bevel, and want it to have that look when metal is near ponit of melting but at the other end it shall already be cooleddown. heres a link to what Incandescence is from wikipedia http://en.wikipedia.org/wiki/Incandescence

You coud mix a diffuse shader with an emission shader using a gradient ramp.


After Boolean union operation - correcting imperfections in joined mesh? I have joined this hand with the main body with a Boolean Union modifier.  However, the union has produced some mesh imperfection along the joined lines as you can see in the second photo.

The joined line in between the mesh seems to be quite fuzzy and the only way I can find to partially correct it is with a creese and smooth brush in sculpting mode.   The result is never totally smooth.

Is there a better way to do it?

Here is a pics of the mesh as requested.

Shading artifacts is a common problem using the Boolean workflow. Using the bevel modifier with a very small width can help mitigate the problem. After that, consider marking any edges surrounding flat surfaces as sharp.

Finally, tab into Edit Mode and look for any double vertices or incorrectly shaded n-gons and fix these issues manually. Double vertices can be merged together (try selecting one, then pressing G twice to slide it along the edge into another vertex and Merge by Distance AltM).

Incorrectly shaded n-gons can be broken up, and you can add supporting edges for the merge point in the local geometry.


TOPBAR_HT_upper_bar.append add menus in two places? I try to add custom menus to the menus at the top bar in 2.80. The old INFO_HT_HEADER.append() doesn't work any more. I found TOPBAR_HT_upper_bar.append() to kind of do the trick but I get two menus, one after the workspace tabs (would preferably have it before but I guess that is a feature request separate from this) and one after the view layer menu. Am I using the wrong thing or is this a bug? Here's a super simple menu from an example which gives me the problem.

import bpy

class customMenu(bpy.types.Menu):
    bl_label = "Custom Menu"
    bl_idname = "view3D.custom_menu"

def draw(self, context):
    layout = self.layout
    layout.operator("mesh.primitive_cube_add")

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

bpy.utils.register_class(customMenu)
bpy.types.TOPBAR_HT_upper_bar.append(draw_item)

If you want additional menus in the top bar you can add them to TOPBAR_MT_editor_menus. The following code adds a menu called Custom Menu with a sub menu that contains an operator. The draw() function of TOPBAR_MT_custom_menu is for drawing the sub menu, while menu_draw() is appended to the TOPBAR_MT_editor_menus in order to draw the menu itself.

import bpy

class TOPBAR_MT_custom_sub_menu(bpy.types.Menu):
    bl_label = "Sub Menu"

    def draw(self, context):
        layout = self.layout
        layout.operator("mesh.primitive_cube_add")

class TOPBAR_MT_custom_menu(bpy.types.Menu):
    bl_label = "Custom Menu"

    def draw(self, context):
        layout = self.layout
        layout.menu("TOPBAR_MT_custom_sub_menu")

    def menu_draw(self, context):
        self.layout.menu("TOPBAR_MT_custom_menu")

classes = (TOPBAR_MT_custom_sub_menu, TOPBAR_MT_custom_menu)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.TOPBAR_MT_editor_menus.append(TOPBAR_MT_custom_menu.menu_draw)

def unregister():
    bpy.types.TOPBAR_MT_editor_menus.remove(TOPBAR_MT_custom_menu.menu_draw)
    for cls in classes:
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()


Does the blender Eevee rendering engine really have indirect lighting? I heard that it does, and there is also a panel in the render settings that says "Indirect Lighting" but I never see any indirect lighting while I'm using Eevee, that's for sure.

Eevee uses irradiance probes to calculate indirect lighting, it's not as accurate as pathtraced indirect lighting, but often is enough for realtime preview.

No indirect:

With irradiance volume:


How to combine multiple objects so adding material affects all objects? I have 5 objects, one parent and 4 children. I used Cube Projection to unwrap and made sure to unwrap all objects at the same time. However when I apply a material from UV Map it only applies the material to one object at a time.

I cannot find a way to apply the UV Map material to all objects all at once.

What is the most effective way to combine objects to do this?

(Sorry if the answer is obvious, I am an absolute beginner to the software.)

Figured it out - needed to 'Join' all my objects rather than just have them in a family tree.


How do I add Add Modifier to the UI In the online manual it shows a panel with a drop-down for selecting modifiers to add. I can't find that anywhere and no one seems to know anything about it? Is the manual wrong? Does that not exist? Is there a way to make Add Modifiers available via the UI?

https://www.blender.org/manual/modifiers/introduction.html#interface

In the properties panel you have the tab for the modifiers. If you click on add modifiers you can choose different modifiers


How to convert UV to square shape? Here, I have tank track model. I'll use this model in the Game, so I will just translate texture to x axis.

Top and Bottom uv are well mapped, when moving texture to x axis, it's moving circular.

But the side parts, it's just have same shape, UV doesn't laid out as square like top and bottom faces.

I tried to make those UV to square just like top and bottom parts, but everything was failed.

How to convert UV of those side faces to square laid out just like top and bototm faces?

Here is the model:
https://drive.google.com/open?id=1y9HfS_kLRFU52F4GAAysc_km_fSStU0o

Method from here: How to Straighten Curved UVs into Straight Belt is working just fine, but you have some errors in your model (Interior Faces).

In Edit Mode:

Select > All by Trait > Interior Faces.
X > Only Faces.

This is how to repair your mesh. Now you can use linked method to UV Unwrap it without problem.


Manually make it look like an object is going through the floor (of a real life photograph) I have a picture of a room including the floor and I want it to look like there is, for example, a cube going through the floor. Is there a way to do this, maybe by making it go through a plane that is transparent to the photograph but not to the cube?

If anyone knows how to do this, as I'm not very good at doing things from text, would you be able to explain with pictures or something? Is there is a tutorial for this sort of thing?

Update for posterity: An archive of this answer can be found at https://bvisness.me/2017/04/25/blender-masking-layers.html.

Blender has a feature called Masking Layers, which nicely accomplish exactly what you're trying to do. Put your content cube on one layer and your masking plane on another, then set the Masking Layer for the plane's layer. I got my result to look like this:

Here's how to accomplish that effect:

1. Set up your layers

Start by turning on transparent film. This makes your Cycles render layers use transparency instead of a background color. Go to the Render panel in the Properties window, scroll down to Film, and check Transparent.

Put your cube (or other content) on one layer and your masking plane on another. I had my cube on layer  and my plane on layer

Make sure that both your cube and your plane are visible, then go over to the Render Layers tab and set the mask layer to the layer with your plane.

To overlay the render on your image, you can use a compositing setup like this:

Give it a render, and you'll get something like this:

This technically answers your question, but it looks really bad, so I'm gonna keep going.

2. Add shadows and AO

You can use your masking plane to capture shadows and AO as well. First add another render layer for just your masking plane. Go down into the "Passes" tab and make sure that Shadows and AO are checked.

Then, use a composite setup like this to mix the shadows and apply them to the original image:

This will result in a render like this:

Just one more step, if you want the lighting to be more accurate:

3. Make the floor material match the picture

You can improve the lighting accuracy if you make the floor material match the picture. This will change the color of the light bounces, even though the plane itself is not actually visible.

Create a material with a node setup like this and assign it to the floor:

This material will use the coordinates of the window to apply the picture to the floor. This means that there will be no distortion of the texture when it is rendered. This change will result in a subtly improved render:

This technique works for other objects too. Just replace the cube with whatever object you actually want in your scene.

Anyway, I hope that helps. Let me know if you want me to clarify anything.


Shadows and lights appear in Viewport but not in Render Thanks in advance.
Missing some shadows cast by a spot outside a window in the render.
Shows in the viewport but missing in the render. 2.82.
Have tried a lot of things. Please help! Thanks! UPDATED: https://www.dropbox.com/s/1b4tkrldl1tufdx/Bosco_Prison_Cell_CHECKING.blend?dl=0

I found the problem with the sun's clipping, this might help you and others who have the same issue.
what I did:

Check scale
Check sun's shadow distance.
Look out for troublesome geometries this might have overscaled objects, micro objects, particles systems, hair, emitters, empty meshes, etcetera. normally you import objects from other softwares, in my case as an example I was using trees from forest pack, entities were there but empty, that caused my issue, I deleted them and it fixed the problem.

I hope this works.
now here is your problem:  you have this huge mesh outside the room :)
also you had a hidden geometry (the door's window), you have to delete it or desable it on render.


Can't see through BSDF principled/glass 2.8 High risk this question was asked a billion times and I am just too stupid to find the correct answer, so apologiez.
I am trying to create a drinking glass, the inside faces are colored red to simulate a sort of fluid, now how come that I cannot see it through the glass. Not in cycles, nor eevee in dev, or rendered view. Not by using principled, nor glass BSDF and I made sure that Screen Space Refraction is enabled. Any further suggestions are more than welcome.

The image you see is made in dev view and colored faces behind the glass do color the glass itself, but not what happens to be inside of it.

You can't see through any shader that was opaque.

The BSDF shader work on Surface Only, as Blender is a surface mesh 3D tool.

If you assign a opaque color to inner surface, the glass BSDF will become useless since you are literally painting the inner glass with that color.

A better approach will be adding a surface on the liquid surface, and change that surface color. Also blend shader with Glass or other transparent shader to make better.


Panning with Shift + middle mouse button stopped working When I pan with the Shift + MMB, it doesn't work. I think I might have accidentally pressed some sort of key-shortcut. It works for other views, so it's not my mouse. What sort of shortcut could I have pressed?

I've had this happen a few times to me, and not pressed anything I shouldn't.

I found going to object mode and pressing the home key fixes it. (View All).

I seem to get this problem when I've zoomed in too close, or am using the UV view.


How can I add more than one animation to the same model? I am making a computer game character and have successfully added the first idle animation. When i add a keyframe after the idle animation to begin the run animation, Blender is causing unwanted bone movement in the first frames (it makes the legs move in the idle animation). How do i tell Blender that i do not want changes in following animations to be applied to the first?

Just adding this as an alternative approach for future. Blender has this thing called Actions that are essentially separated animation timelines. You can have any number of actions in your blend file for every animation you want to create (idle, idle2, walk, walk2...) and you can add, copy and delete them whichever way you like without them interfering with each other in any way.

You can then mix actions into longer animations (walk+hand wave) using the NLA editor, line them up as one long, continuous animation like you're doing now, or if you're targeting Unity or somesuch, FBX export can save all the actions along with the file. No need to manually set the frame ranges later.

You can get it done the way you're doing, sure. And actions are a bit confusing to work with first. But I think it's the easier route in the long run.


Fire is bleeding/rendered in front of all objects in Eevee I'm playing with fire simulation (added it to an object via object-quick effects menu). I use couple of faces on my torch model as an emitter. I encountered a problem when the fire is rendered in front of all objects, but only in eevee. In cycles fire is rendered as I'd expect it to i.e. it doesn't overlap my torch. What should I do to fix it? I have already tried playing with parameters in physics settings and volumetric shader settings but results stay the same: good in cycles, bad in eevee. Here are 2 renders to show what I mean. First is eevee, second is cycles.

I've tried setting up fire simulation in both latest blender 2.81 and recent 2.82b

This might be a little late but I figured it out. I had the same problem so after an hour of playing around with settings I figured out it's a setting under the volumetrics tab in the Scene options. Increase the start value until it doesn't go through your object.


Extruded edge problem I am an absolute beginner with Blender. I have a question about extruding meshes.
I have done a simple extrusion on a subdivided plane. However opposing corners of the model have different shaped corners. I want understand the logic behind this result.

I am using Blender 2.79

I created a plane mesh.

Subdivided the plane a few times.

Highlighted the faces I wanted to extrude.

Extruded to create a pyramid (or dish when inverted).

Result - two diagonally opposite corners have sharp edges.
The opposing diagonal corners have chamfered edges.
I don’t necessarily prefer either edge type. I just want to understand why Blender has produced two different results on what I feel is a uniform mesh.

You didn't extrude, you probably pressed g and moved it along the z axis.

Your mesh should look like this:


Follow objects as if there was a magnetic field using animation Nodes Using animation nodes how can I make an object keep following and other object with some delay, a behavior very similar to the one you can see in most paint tools for stabilizing strokes, here is an example:
https://www.youtube.com/watch?v=ah13EISw7nc
The only difference is that at the end of the transform both objects should have same location.
EDIT
here a perfect example of what I'm trying to reproduce, but without "actions"
enter link description here

Method 1 (Recommended)
You can evaluate Fcurves to get trailing or attractive effect. You need a source object with location keyframes. Then follow node tree given below.

Method 2
We can also do this without keyframed source object by storing positions of object.

For storing object transformation as Matrixlist:
setattr(AN, "store", Matrix4x4List()) if frame == 1 else AN.store.append(x)
Get stored Matrixlist:
AN.store[-amount:]


Why are the textures on imported objects not displaying correctly in my scene? I have a small scene with an imported CAD model in Blender 2.9. I have textured a vastly similar model before and imported the textures from the old project (Blender Version 2.82) into the new one.
The preview in the material tab displays the texture correctly (A).
When I apply the material to any imported object in my scene, I only get a solid color material without texture. This applies to the viewport as well as a rendered image (1).
When I copy the object the material was originally applied to from the old project file, it is displaying correctly in my current scene (2).
When I create a new mesh and apply the texture on it, it is also displaying correctly (3).

What could be the reason for the tiled texture is not displaying on the imported objects?
You can download the full project file and take a look yourself.
https://filebin.net/1jzdwh6t52jtfioi/Texture_issue_scene.blend?t=pm3p6t1q

Object 1 doesn't have an UV map, object 2 have.
When I Unwrap object one, like Cube projection or if you go to top view and Unwrap from View, it works for me.


Rendering World Position Pass I need to render a world position pass in Blender to check if my idea is correct. I found solution that uses an emissive material and geometry node to render position as colors: How to render world position pass

When I render the scene presented below:

I get this result:

The image seems to look fine, but when I check the values with the image view something's wrong.Each cube is size of 2 and spacing is equal 1. Cubes are translated in x direction and the first-left one is placed in origin.
I assume then that the first-right cube should have values of R component within the range 12-14. Intead of that values are around 2.7.  What do I do wrong?

---EDIT---

I did everything as Martin recommended. Anyway I still have same problem:

I attach the .blend file where the problem occurs. I will be very grateful if you find the problem:
https://drive.google.com/file/d/1bMnmEB9-j2OQllZKqfwwWkgx2ZlvTFx3/view?usp=sharing

Try setting Display Device to 'None'(because you do not want it to be an image viewd on any display device, but only pure unchanged values) in the scene's color management settings:

Seems to work:

Obviously the output needs to be a 32bit full float EXR image in this case as well if you want to save it.


How can I automatically extend edge loop selection? I have a cylinder that I erased some faces near the middle of it on the side like this.

However I when I Alt click the edge of it, it doesn't go completely around the new edge like this:

What I automatically want it to do is this (I just custom selected all the edges to show you what I mean):

So is there anyway to add edges to the edge loop without clicking every single one?

Since the target edges are all boundaries, there are multiple ways to do this:

AltRMB twice on a boundary extends the selection to all boundary edges.For single boundary loop as shown in the example

Other ways to select boundaries.

In Vertex Select or Edge Select mode: 3D View menu > Select -> Non Manifold (or press ShiftCtrlAltM).
Or you can first select all elements, then go to 3D View menu > Select > Select Boundary Loop.


Change preview menu directory according to the category A time ago I asked about how to create a custom preview menu, but now I want to change the directory of the previews according to the id of the category selected. Below there is the code of the script and a screenshot of the script in Blender

import bpy
from bpy.types import Panel, EnumProperty, WindowManager
from bpy.props import *
import bpy.utils.previews

import os
import json

# UI
class evp_ui(bpy.types.Panel):
bl_label = "Everyday Stuff Pack"
bl_category = "Everyday Stuff Pack"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'

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

    row = layout.row()
    row.prop(context.scene, 'MyEnum')

    row = layout.row()
    # This tells Blender to draw the my_previews window manager object
    # (Which is our preview)
    row.template_icon_view(context.scene, "my_thumbnails", show_labels=True)

    # Just a way to access which one is selected
    row = layout.row()
    row.label(text="You selected: " + bpy.context.scene.MyEnum)

    row = layout.row()
    row.operator(
        evp_op.bl_idname,
        text = "Import",
        icon='APPEND_BLEND')

preview_collections = {}

class evp_op(bpy.types.Operator):
    bl_idname = "object.evp_x"
    bl_label = "Import"
    bl_options = {'REGISTER', 'UNDO'}

def execute(self, context):

    dirpath = os.path.join(os.path.dirname(__file__),    "blends/retro.blend/Object/")

    bpy.ops.wm.append(filename="Stop", directory=dirpath)

    return {'FINISHED'}

def generate_previews():
# We are accessing all of the information that we generated in the register    function below
   pcoll = preview_collections["thumbnail_previews"]
   image_location = pcoll.images_location
   VALID_EXTENSIONS = ('.png', '.jpg', '.jpeg')

enum_items = []

# Generate the thumbnails
for i, image in enumerate(os.listdir(image_location)):
    if image.endswith(VALID_EXTENSIONS):
        filepath = os.path.join(image_location, image)
        thumb = pcoll.load(filepath, filepath, 'IMAGE')
        enum_items.append((image, image, "", thumb.icon_id, i))

return enum_items

def register():
    from bpy.types import Scene
    from bpy.props import StringProperty, EnumProperty

# Create a new preview collection (only upon register)
pcoll = bpy.utils.previews.new()

# This line needs to be uncommented if you install as an addon
pcoll.images_location = os.path.join(os.path.dirname(__file__), "images")

# Enable access to our preview collection outside of this function
preview_collections["thumbnail_previews"] = pcoll

# This is an EnumProperty to hold all of the images
# You really can save it anywhere in bpy.types.*  Just make sure the location makes sense
bpy.types.Scene.my_thumbnails = EnumProperty(
    items=generate_previews(),
    )
bpy.types.Scene.MyEnum = EnumProperty(
    items = [('cat1', 'Category 1', ''),
             ('cat2', 'Category 2', ''),
             ('cat3', 'Category 3', ''),
             ('cat4', 'Category 4', ''),
             ('cat5', 'Category 5', ''),
             ('cat6', 'Category 6', '')],
    name = "Category")

def unregister():
    from bpy.types import WindowManager
    for pcoll in preview_collections.values():
        bpy.utils.previews.remove(pcoll)
    preview_collections.clear()

del bpy.types.Scene.my_thumbnails
del bpy.types.Scene.MyEnum

if __name__ == "__main__":
    register()

I already solved, if someone has the same question I leave the answer below.
Create an update function
This will execute a function everytime the category is changed
def update_func(self, context):

    for pcoll in preview_collections.values():
        bpy.utils.previews.remove(pcoll)
    preview_collections.clear()

    pcoll = bpy.utils.previews.new()
    pcoll.images_location = os.path.join(os.path.dirname(__file__), "images/" + bpy.context.scene.MyEnum)
    preview_collections["thumbnail_previews"] = pcoll

    bpy.types.Scene.my_thumbnails = EnumProperty(
        items=generate_previews(),
        )

    return None

In this code the value changed is the pcoll.image_location, where the previews folder is changed based on the category id
Set the update
Then we have to set the update function in the category menu
bpy.types.Scene.MyEnum = EnumProperty(
    items = [('cat1', 'Category 1', ''),
             ('cat2', 'Category 2', ''),
             ('cat3', 'Category 3', ''),
             ('cat4', 'Category 4', ''),
             ('cat5', 'Category 5', ''),
             ('cat6', 'Category 6', '')],
    name = "Category",
    update=update_func)


Is it possible to find the nodes connected to a node in python? Is it possible to find nodes connected to a node?

For example, could you trace your way back through a node tree from the material output node by finding the node connected to the material output node, then finding the node(s) connected to that node, then the nodes connected to those nodes, etc.?

How is this possible?

The python path to the links between each node is

bpy.data.materials[].node_tree.nodes[].inputs[].links[].from_node

So for each material we want to start at the Material Output node then loop through each array of inputs[] and links[] to move through the connections. Going this way (using from_node) there should only be one link for each input, but if you want to reverse the order (by using to_node) you can have multiple links for each output.

import bpy

def followLinks(node_in):
    for n_inputs in node_in.inputs:
        for node_links in n_inputs.links:
            print("going to " + node_links.from_node.name)
            followLinks(node_links.from_node)

for mat in bpy.data.materials:
    print("Traversing " + mat.name)
    for mat_node in mat.node_tree.nodes:
        if mat_node.type == 'OUTPUT_MATERIAL':
            # we start at the material output node
            print("Starting at " + mat_node.name)
            followLinks(mat_node)


I can't paint anymore! Beginner here I am desperate for help :pensive: I am new with blender and atm working with 2.8.
I have a problem while painting. I already know about UVs, unwrapping, saving the image and adding it through the image texture so I can paint on the UV.
I don't know what I did (I probably did something, for the error to occur) but suddenly I can't paint anymore... Nothing works and I can't even paint on the object itself, all I get is some weird colors. Please help me, I am trying google for an hour, nothing helped:cry:

I made an edit to show you how it looks when I try to paint, maybe it will make it clearer.

Unfortunately it's not possible to determine what's happening just from those screenshots, hence moonboots's comment requesting that you upload the broken file which demonstrates the strange behavior.
I've not seen a texture paint problem quite like this before. It may be caused by an unreported bug, perhaps due to some combination of your hardware and a new part of Blender's 2.80's viewport.

As it's unknown territory, the only advice available here will be either A) trying to diagnose what's really going on (i.e. asking many clarification questions); B) suggestions for working around it (eg as Craig D Jones suggests); or, C) if it's happening too consistently to ignore, you might consider submitting a bug report.

Before any of that: experimental builds of Blender are available to download, which are effectively daily updated '2.80+' with additional fixes and some newer features. You might want to try downloading the bleeding edge latest version, and see if the same problem still occurs in that.

Finally, if the problem is still happening, please consider using the Help > Report a Bug option. This option uploads operating system and graphics cards details which help pinpoint things with much less guesswork.
If you can find and describe the fewest steps to reproduce the error from a blank starting state, consistently (i.e. more than once) then that's invaluable for the devs to pinpoint it quickly if it is a new bug.
I know this doesn't help you immediately fix your problem today, but if this is something unreported, reporting it is the best way to get it resolved and then gone from the newest version.


Shading artifacts in cycles displacement I'm trying to make stylized topographic maps in cycles using displacement with 10m resolution hight maps. An early issue I have is getting clean edges. Adding more geometry to the plane does not seem to help. I suspect my image may be too low resolution, but that's the best I can find. Does anyone have a workaround suggestion to clean this up a bit? Many thanks.

A couple of things come to my mind:

If it's really the image that's the problem, upscale and blur it beforehand. This will smooth any compression/resolution artifacts and could work in your case.
Are you using Adaptive Subdivision? If not, you might want to do
that. Go to Render Properties > Feature Set > Experimental. Then add
a Subdivision Surface modifier set to Simple and check Adaptive
Subdivision. In viewport you won't see the full resolution though. Also, make sure to use Displacement Only. Material Settings > Settings > Surface > Displacement >Displacement Only.
Try different interpolations in the Image Texture node.


Mesh's Smooth Shade Problem i used smooth shade in a mesh and it responde me with a
strange behavior. Some parts of my mesh has smooth shade but for other parts it doesn't have. I tried recalculate inside/outside normals. And a few other things i have read but none of them has worked so far. And one more importing thing is that when i try scultping mode it starts working but as i went back to object mode and render it doesn't work.

This is object mode. As you can see above some parts of it has smooth shade other parts doesn't.

And in this sculpt mode. Which works fine.

And last this one above is different mesh. The look i want in the first mesh should be like this. But can't find a way to fix it.

Yeah, i found out a solution. If someone has a problem like this, what it i did is; I joined smooth shade problem mesh to non smooth shade mesh(This mesh has smooth shade working). And as i joined it fixed ! Then i separate the mesh i joined. That's all i hope this might help someone.


Interface problem (Sticky windows) The following interface problem occurs,
The UV Image window is attached to the Properties window, if I make the Properties or the UV Image window larger or smaller, the UV Image or Properties window will go along (see photos).
Blender interface-01.jpg - Blender interface-02.jpg
How can I solve this ?

Yes if the windows are at the exact same level they will stick to each other, I don't know if there's any other way to solve it than to create a new window and collapse it, like that:

You could join the areas but I doubt it makes it faster as you'll need to create a new window:


How to use the outset option from the inset command? Inset, with the outset option : nothing is moving...

How to use it ? Or what is it supposed to do ?

The Outset option is when you want a new region of faces to appear outside the selection instead of inside. At first I start doing a normal inset on the face and then press O to toggle Outset:

You can see at first new faces are appearing inside until I press O and then new faces appear outside the selection.

Presumably, this simply doesn't work at the minute when there is no geometry outside the selection to outset into.


How to set an image strip (ImageSequence) length via python? I have this piece of code which creates an image strip but I can't find the way how to set the length of that:
img_strip = bpy.context.scene.sequence_editor.sequences.new_image(
name = img_name,
filepath = img_filepath,
channel = 5,
frame_start = 1500)

You can use frame_offset_start to change length from left side and frame_offset_left to change length from right side. Building on your code
img_strip = bpy.context.scene.sequence_editor.sequences.new_image(
name = img_name,
filepath = img_filepath,
channel = 5,
frame_start = 1500)

img_strip.frame_offset_start = 10
img_strip.frame_offset_end = -20 # Not sure why but blender needs this value negative.
#If you put positive value strip will end up in negative side of frames.

#img_strip.frame_start = 20

There is also frame_start setting it does not change the length of the strip but put it at given frame


Particle system from selected object How do I create a particle system from an imported stl model and use that to fill the shell of another model? As you can see below, I want to fill the model to the right. There are two issues I am having. 1) The body is currently emitting the mini figurines rather that the internally contained collisions I was expecting. 2) A displaced modifier was applied to prevent the particles from moving beyond the skin, but if I could just set the collision boundary to the skin itself, that would be best. I read that applied modifiers are permanent, so I may need to redo this particle system on the original stl. Thank you!

(11/9/20) Tried Vertex paint mode and selecting the body under the Vertex Group --> Desnity, but it still had the same effect. I think the problem also is that internal face or area is not the source of the emitter. However, I found a tutorial here that shows how to fill a container by funneling the smaller objects via implemented physics engine. Will see if that works!

I believe what you're looking for is the 'hair' particles system, if you want another object to cover the main object. When you add a particle system to an object, one of the first options should be to choose from Emission and Hair, switch it to hair. I'd recommend watching some tutorials for the same. If this is not what you were looking for, please reply.


how to flatten out the middle part of landscape I made a landscape using ANT landscape add-on. Here's what I have:

What I want to do is to flatten out the middle part, to render sth like a valley. Specifically, the area that I circled below:

How do I go about doing this? (btw I don't necessarily have to use ANT landscape).

EDIT:
If I use S+Z+0, I get this:
where vertices are not at z=0, instead just levels the vertices I've selected. How can I set vertices to 0?

EDIT2: I tried setting the z values to 0 for the selected vertices. As yo can see they are stretched equally but are not at z=0. In fact, the top right panel seems to set the 'median' of the vertices, not individual vertices... How do I set them to 0 using to transform tool?

Select the vertices you want to be leveled, set 3D cursor to world origin, change pivot point to 3D cursor, S+Z+0. Don't forget to reset pivot point, or other things could go wrong. Hope this helps :)


How to place a flat object orthogonal to camera, but not center of camera view I am looking for a way to accurately place a flat object, in my case a watch, into the lower right corner of my camera view so it is exactly orthogonal to the camera.
The camera is looking at the default cube from above at an angle. If I use the camera position and angle to position the watch, it is accurately orthogonal as long as it is placed in the center of the camera view. But I need it to sit in one of the corners.
How can I make orthogonal to the camera?
Thank you!

You could give your watch a Track to Object Constraint that tracks the Camera.
Now the watch always looks at the camera no matter where you move it.


"Default displacement = 0, consider adjusting" Error when applying materials I'm using blender 2.82a

I've been sculpting in VR programs such as Oculus Medium and importing to blender to add lighting and material shading.  Its's been working great, I've been using materials from Poliigon.com. However, after importing some background elements I created in Gravity Sketch, I cannot seem to get materials to apply properly to those meshes.

I imported from Gravity Sketch into blender (saved as .obj) and then separated the objects, since they came in all as one group (edit mode, select all, Select mesh menu->Vertices->Separate->by loose parts).  When I apply a material to one of those meshes, I get a yellow error message at the bottom of the screen saying "Default displacement = 0, consider adjusting" and I don't know how to proceed.

Any advice on what I'm missing here would help.  I tried unwrapping the meshes and that did not work. Here is the file if that helps. The objects in question are the slide, sandbox bricks and the swing set.

Thanks very much!
-Brock

blender file with the issue

I'm new at this too, I had the same issue today and I spent 30 minutes figuring out what's going on. I see you're using the Poliigon nodes too.

No matter how much I tweaked the actual Displacement node, nothing was displaced.
I only saw the sliders under 2 after half an hour, displacement was visible after moving the Displacement Strength to something else than 0, see my rendered view in the screenshot.

However, I see you don't actually have those sliders in your material custom block. Does your texture have a displacement map in it's folder? Maybe you didn't include it in your download?


Rendering animation not working I have made a simple fluid simulation in Blender 2.8 and whenever I render it it doesn't work.
First I tried rendering it as a png but that just produced 4 images and no video or animation. Then I tried rendering it as a FFmpeg video and when I try to play it all I see is a black screen. Can anyone help me?

You have to render it as a .png image sequence in your preferred file, and then go to the video editing section of Blender, browse for the frames, select them then add them, and then sequence the pictures into a video.


Lo-Res texture blurring in blender Is there a way to tell blender to blur textures if they're too lo-Res or pixelated, so as to not increase file size yet still get a finished result?

If I got an answer, I could spend less time making unimportant textures-- and even save packing space!

Yes and no. Yes, because this is called "texture filtering" or "texture interpolation." No, because Blender is already doing this.

Your question is basically the opposite of this one, and that answer will be very helpful to you.

Suffice to say, you can change the interpolation mode on the texture node in Cycles, or in the Image Sampling section of Blender Internal. Cubic typically gives the result you want. It's a sharpened version that doesn't look pixelated. "Closest" is pixelated, it doesn't do any blurring at all. "Linear" is a little more blurry than cubic, but that's as blurry as it gets without doing some other image processing, which you can't do within Blender. There's currently no way to blur an image texture before using it in a material.

Lastly, it wouldn't help. If you're blurring the image, you're losing information. If you want to NOT lose that information, you have to have a higher-resolution... which isn't a smaller file.

The unfortunate reality of computing is that computers are terrible at guessing. If the dataset is incomplete, the computer cannot fill in that data intelligently (unless you're Adobe and have made unholy pacts in order to perform the dark magics known as "content aware fill"). If the incomplete dataset is insufficient, you must add more data which comes at a cost. In the case of Adobe, that cost is unholy liaisons. For the rest of us, that cost is file size.

Hope that helps!


What is slot in shader editor When I try to change material using that button I doesn't change sometime. Doing the changes in slot it works. Can you explain me what is slot and what relation it has with changing materials?
I have tried to read with documentation but as beginner I find it difficult to understand

The slots are for giving different faces different material, all in the same object. If you have only one slot, you can use the button you marked to give your object material.

In Edit Mode you can select faces and assing them to certain slots. Lets say you want two slots. You press the little down arrow next to Slot 1 and press + to add a new slot. Select a face, select slot 2 and press assign. Now you can give the selected face different material by pressing the button you marked.


rigid body simulation - unwated spaces between objects I've been trying to play with a rigid body simulations.

I prepared a project of a building made of domino tails. I've placed all objects very tight, but as soon as I start animation it looks like there was some tiny gap between objects, so they all fall down a little bit. For a high building it leads to a construction disaster as the whole building colapses.

Here is an example: https://www.youtube.com/watch?v=4seYWa1g53s (I'd suggest to use 0.25x speed).

How can I fix it?

Firstly, check your scale. A stack of 5m tall blocks of wood will behave vastly different to a stack of 5cm tall blocks of wood - with forces that are orders of magnitude more powerful, causing more ‘bounce’ and inaccuracies in the simulation.

Secondly, expect some gaps and a certain amount of ‘settling’ at the start of the animation. It is very difficult to avoid all gaps without causing overlapping surfaces which can generate huge repulsive forces at the start of your animation. I suspect the scale of your model is simply resulting in the forces being so large as to cause collapse.

Thirdly, tune the Rigid Body properties. The defaults (60 steps per second with 10 iterations) provide for a very crude simulation. Increase your steps and iterations (eg, steps 600 and iterations 300 - or even higher if required) until you get a stable simulation without causing too much CPU overhead (more steps and iterations require more computation time).


Mapping Node, Box projection, and rotation Goal

I'm trying to map a texture on a cube;

Since my texture is not exactly fitting the correct orientation, I need to rotate it. The results are not as expected.

Setup description

I'm using the setup shown in the following pictures. I've set the projection mode to Box have the texture visible on all faces. Texture mode is set on Repeat to avoid undesired clamping (default value).
What I'm trying to achieve is to have the planks horizontal instead of vertical on the front face (rotate around X axis). The rotation is applied in a Mapping Node.

Results

The face I need is properly rotated, but the others get this blurry effect, which reminds me of the "Clamp" mode in OpenGL. Is this expected behavior ? How to solve this ?

**Additional note (edits) **

Both the cube and the material are simplified versions of the original problem. The meshes I have are more complex, a few thousands faces, and with complex shapes (such as switches or sockets outlets). Very few faces are not aligned with the world axes, and thus they can be ignored. The material needs to be applied on various shapes, so UV map can't be made manually. The purpose of this is to automatically create a diffuse map of each textured item, where every face with a similar direction/normal would have a similar rotation applied.

For simplificity sake, the cube seems to be a good sample

"I'm trying to map a texture to a cube"

Perhaps a simpler way of mapping a texture to a cube and have control of the orientation of the texture on each of the 6 faces is to use UV mapping?

Starting with the node setup you have already :

In the Texture Coordinate node change to UV, and the Mapping node change to Point (and reset the rotation and scale to Zero).
Drag open a new viewport and change Editor Type to UV Editor.
3D viewport > Edit Mode > select the cube, then U to open the UV Mapping menu and choose the Reset option. This will reset the UV's so that each face of the cube is mapped to the complete UV space. (Each face stacked one above the other).
3D Viewport > select the face that you would like to change the orientation of the texture.
In the UV Viewport > select the face (if it is not already highlighted in orange then use the A key to select it) and rotate it 90° with R90.

Or you can probably find the answer here http://www.blenderinsight.com/beginners-guide-to-cycles-nodes-the-procedural-way/  Under the chapter titled Object (with no reference object) :)


How to tell if Blender has crashed? I am unsure whether or not Blender has crashed / stalled.
The screen, especially the timer, haven't changed in over an hour (while usually the timer tells you how much time has elapsed since rendering began).
But I'm thinking, hey, maybe the timer's just slowing down because it's processing and thinking too hard to update?

Is there a way to know? As far as I know, when I hover over the different buttons in the properties panel, they change color (and so does the X for cancelling rendering), so it might just be working (that's what indicates my Activity Monitor as well, as seen in the image below).

But what's a certain way to know whether or not Blender has stalled / crash?

If the interface is still responsive, Blender hasn't crashed (yet). But in this case is engaged on some heavy computing.

In this case the issue is that you are trying to render using an insane number of samples!

You've set up 1000 samples but have the square samples box enabled, that will make the number 1,000,000 (1000 samples x 1000).

A million samples will require massive computing power!

Uncheck the square samples box and bring the number of samples to a reasonable number...


Why does Blender think this driver expression is a security issue? I wrote "PI" in a driver expression, and Blender threw up this warning message. I don't understand why it thinks there's a problem, nor what implications any of the choices have.
What is the security issue with using PI in a driver expression? What "unexpected behavior" is it talking about? If I choose "Ignore", will my driver stop working? If I choose "Allow Execution", am I inadvertently allowing other scripts I'm unaware of to run? And what does "Permanently allow execution of scripts" mean, is it saying any python scripts in any blender file can run henceforth, or what?

The problem isn't with the specific driver you've implemented, but with python scripts in general. The automatic execution of all python scripts is disabled by default.
From the Blender 2.90 Manual:

The ability to include Python scripts within blend-files is valuable
for advanced tasks such as rigging and automation. However, it poses a
security risk since Python does not restrict what a script can do.
Therefore, you should only run scripts from sources you know and
trust.
Automatic execution is disabled by default, however, some blend-files
need this to function properly.

This is mostly an issue when you are opening a Blender file which you didn't yourself make. It could contain any conceivable script.
In Blender Preferences > Save & Load there is a checkbox to Auto Run Python Scripts. You can add excluded paths to, for example, your downloads folder, so that foreign blend files are still restricted.
You can also manually enable scripts in specific blend files as you open then, by checking the Trusted Source box in the File Browser.


Face Rigging Armature How would I be able to stop the "Eye Bones" from interacting with the Body Mesh? The eyes are already their own mesh and the Eye Mesh is already parented to the Eye Bones. But when Parenting the Body Mesh and the Armature, somehow the Eye Bones took control of the face.

When you parent a mesh to an armature, the automatic weight function assign some weight to all bones marked as "deforming", no matter if they are controlling other meshes (a bone can control more than one mesh).

To solve the problem, select the body mesh, enter edit mode, select all vertices, in the properties window, vertex group tab, select the group named as the "eye bone" and click "Remove".


Creating sinusoidal struts using bpy I want to use Blender and bpy to create sinusoidal struts. I have been using Python with VTK in the past, but it is causing some trouble and I feel Blender might be the better solution.

An example of what I want to create is depicted below. It is planar in a sense that only one axis is modified with a sin (or in this case cos) function. It is also tilted by 45°, but that's not the big hurdle.

Since I am very new to Blender, I googled around a bit and found this: http://wiki.theprovingground.org/blender-py-mathmesh

It contains the following code that creates a surface that is modified with sin:

import bpy
import math

# mesh arrays
verts = []
faces = []

# mesh variables
numX = 10
numY = 10

# wave variables
freq = 1
amp = 1
scale = 1

#fill verts array
for i in range (0, numX):
    for j in range(0,numY):

        x = scale * i
        y = scale * j
        z = scale*((amp*math.cos(i*freq))+(amp*math.sin(j*freq)))

        vert = (x,y,z)
        verts.append(vert)

#fill faces array
count = 0
for i in range (0, numY *(numX-1)):
    if count < numY-1:
        A = i
        B = i+1
        C = (i+numY)+1
        D = (i+numY)

        face = (A,B,C,D)
        faces.append(face)
        count = count + 1
    else:
        count = 0

#create mesh and object
mesh = bpy.data.meshes.new("wave")
object = bpy.data.objects.new("wave",mesh)

#set mesh location
object.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(object)

#create mesh from python data
mesh.from_pydata(verts,[],faces)
mesh.update(calc_edges=True)

I just can't rewrite it to just creating a strut, though. Originally, I created the points using the following approach with numpy + vtk, but when I try this in Blender I get error messages ('Unsupported operand type(s) for /: "tuple" and "int"' on the line where I define y in the function).

def strut(x, node_dist=5, amp=1):
    """Takes 1D array x, creates shape and normalizes it to fit the length of the cosine function."""
    x = x * 2 / node_dist * np.pi  # normalize length to fit [-4pi; 4pi]
    y = amp / 2 * np.cos(x) + amp / 2  # adjusting position and amplitude
    return y

a = np.linspace(-2 * node_dist, 2 * node_dist, points_per_line)
b = strut(a, node_dist, amp) - node_dist / 2.
c = strut(a, node_dist, amp) + node_dist / 2.

for i in range(0, a.shape[0], 1):
    if strut_number == 1:
        x = a[i]
        y = b[i]
        z = c[i]

If I could just get some help with being able to define how many points on the line I want(-> smoothness) and how to define the shape (ideally quadratic) around the strut I could figure the rest out myself. I hope my question is specific enough and not too odd. Thanks for any help!

Got it to work with Bmesh (not necessary but easier to work with IMHO).
Had to add several chunks of code that will generate 4 waves as the main longitudinal edge loops, and add faces to the mesh.

This can be fairly easily expanded to generate other shapes, or non-quad based struts. Here you can control the width (thickness) of the 3D strut via the width global and zw / xw variables within the loop.

I also changed the strut function a tiny bit. Instead of normalizing between -4 to +4 X pi, I just use the Y values provided. In this example I'm providing the minimum and maximum Y values as multiples of pi directly, so I removed the normalization to open up the possibility to create a wave in whichever length and number of peaks you want.

Here's the code:

import bpy, bmesh, math
from mathutils import Vector
import numpy as np

numPoints  = 100
yMin       = -3 * np.pi
yMax       = 1 * np.pi
width      = 0.5

def strut( x, node_dist = 5, amp = 1 ):
    """ Takes 1D array x, creates shape y values """
    return amp / 2 * np.cos(x) + amp / 2  # adjusting position and amplitude

bm    = bmesh.new() # Generate bmesh object
loops = []          # Strut major longitudinal loops array

# Calculate vertex coordinates
# Essentially generate 4 longitudinal loops that represent the top, bottom. left and right edge loops of the strut
y = np.linspace( yMin, yMax, numPoints )
for zw, xw in zip( [1, 0, -1, 0], [0, -1, 0, 1] ):
    z = strut( y, amp = 2 ) + zw * width
    x = strut( y, amp = 0 ) + xw * width

    loop = [
        bm.verts.new( Vector(( xi, yi, zi )) )
        for xi, yi, zi in zip( x, y, z )
    ]

    loops.append( loop )

# Add faces
for i in range( len( loops ) ):
    for j in range( len( loops[i] ) - 1 ):
        verts = []
        if i == len( loops ) - 1:
            verts.append( loops[0][j] )
            verts.append( loops[0][j+1] )
            verts.append( loops[i][j + 1] )
            verts.append( loops[i][j] )
        else:
            verts.append( loops[i][j] )
            verts.append( loops[i][j + 1] )
            verts.append( loops[i+1][j+1] )
            verts.append( loops[i+1][j] )

        bm.faces.new(verts)

# Add caps faces
for i in [0, len( loops[0] ) - 1 ]:
    bm.faces.new([ loops[j][i] for j in range(len(loops)) ])

# Generate mesh data and object, and link to scene
m = bpy.data.meshes.new('strut')
bm.to_mesh(m)

o = bpy.data.objects.new('strut', m)
bpy.context.scene.objects.link( o )


Emission wont emit through black colour screen I have a mesh plane which is a glass object, transmission and alpha all the way up, which means its 100% opaque.
Whenever I use a lighter colour the emission shader goes through the glass, but when I use a dark colour as shown in the example Black, the emission wont shine through, so I lower the alpha to get some emission going through.
Why does the black or dark colours effect the emission luminance once placed over it, since the alpha and transmission is all the way up?

Reframing the idea behind “Alpha” as occlusion should make the idea clearer, where “Transmission” is a degree of filtration.
The 0.0-1.0 range in alpha represents the degree of occlusion from 0% to 100% in a properly encoded image, while the RGB represents the quantity of emission. Something can be completely unoccluding (0.0 alpha, 0%) and emitting (nonzero RGB units), as well as completely occluding (1.0 alpha, 100%) and not emitting (0.0 RGB units).
Transmission represents the ratios of light permitted to pass through the object. 0.0 would indicate that 0% of the given channel is permitted to pass through, while 1.0 would indicate 100%. In this way, Transmission behaves like a light “filter”.
In this way, the RGB values are pulling double duty, both as the emission for the alpha component and as the filtration mechanism for Transmission. It is worth understanding that in different contexts the values present in the three channels can mean different things, and it's not always a "colour" per se.