User
Write something
Coffee Hangout is happening in 5 days
Script background size problem
Hi, I'm back :) This time I have a (probably trivial) problem that I can't solve. But let's start from the beginning. I wrote a script (addon for Blender 4.x) which, when called (Shift + Ctrl/Opt + k), allows keyframing individual parameters of an animated object. I'm trying to animate something, and clicking the mouse on the transformation panel just gets tedious for me :) The 'i' key inserts keyframes in all fields, and with 'k' the option to insert a keyframe for only one axis in a given transformation is missing, and besides, the Graph Editor gets dense with those unwanted keyframes. I mean, specifically the location along the Z-axis, or the rotation along the Y-axis, etc. There's even an option to remove a keyframe if one exists on the current frame. But I don't know why the background of this script (addon/plugin) expands to the width of the window instead of adjusting to the content of the UI elements. What should I do about this, how can I live? :D I'm including below the script & screenshot.
Script background size problem
Sorting Vertices on a path / 1st attempt to scripting
What I have: A mesh object in the form of a path. The indices of the individual vertices and edges correspond to the order of creation, but not to the direction of the path. What I want: The vertices and edges should be in the order of the path's direction. While playing around with KDTree(), I discovered that it doesn't take the path itself into account, but only considers the distances between the individual vertices. Unfortunately, that wasn't what I needed. So I put together my own script that proceeds as follows: 1. Create a list with (number of edges plus 1) entries. Each entry is 0, and the index corresponds to the index of the vertices of the unordered path. 2. Iterate over all edges and increment the value in the list corresponding to the index by 1. This gives me a list of all vertices, along with the value of how many edges are connected to each vertex. The two indices, each containing only the value 1, represent the starting and ending points. 3. Take the first index, which has the value 1, and determine the corresponding index of the edge. Since the index of one vertex is already known, the other vertex becomes the new starting point. 4. Iterate over all edges again, ignoring the first edge, and find the other vertex each time. Write the result in a new list. 5. Repeat step 4 for all remaining edges. 6. The new list contains the indices of the vertices in the direction of the path. From this, the coordinates can be read, and a new path can be created in the same order, with the vertices in the order of the path's direction. I'm sure there are much simpler and more elegant ways to do this. There may even be ready-made methods in Blender for this. This was my first attempt, and it actually works. But how can I do it more elegantly? What are things i should not do? (When I learned to program more than 40 years ago, spaghetti code was common—and that's exactly what my script looks like.)
Help debugging my addon
Hey its been a while, but I have been spending that time modifying my add-on a lot. I would like for you guys to download the add-on and see if there are any bugs or any other funny stuff going on. V-------------------------------------------------------------------------------------------------------------------------------------------------------------- What is the addon? The addon is an attribute editor menu, making it so that you can edit attribute values all in one place without going to Mesh > SetAttribute every time you want to edit a single attribute value. Saves time and reduces clicks. How to download it: Download the attached ZIP file, once you have done so go into blender Preferences > Get Extensions and in the top right hand corner there should be a down arrow. Click it then click on "Install from Disk" and select the addon zip and restart Blender. How to use it: - Once installed open the side bar or press N and you should see a tab called "AttributeMenu". - In "Attribute Props Panel" click on "add new attribute". - There you can select from a list of attributes. If you don't have any attributes, go to the properties panel and go to Data > Attribute and create a new attribute. - When you select an attribute from the list of attributes, you'll be able to see and edit it in the "Attribute Props Panel" Make sure that the attribute data type is either an int or bool or float data type, otherwise it wont work (I am planning to add support for different data types in the future). If you don't see the attribute in the property panel then its is likely in a different domain. So if you add an attribute, which domain is in face, but you are in vertex mode, just make sure to go to face select mode, and you should see the attribute in the panel. ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Like I said I would like help debugging and finding errors and bugs n stuff, also new ideas on how to improve the addon would be greatly appreciated as well!
Vertex attribute editor
So for like the past month and a half I've been trying to create a menu that can edit all your custom attributes. And with the help of @Victor Stepanov, @Christian Coppes and a little bit of chat gpt, this is what I was able to do it. I wanted to not only showcase what I've done, but ask for a code reveiw because I feel like there is a bit more that could be optimised and I just wanted to see if there is anything worth improving. Like for instance I think in lines 119-122 and 223-226 I think that if you have a ton of attributes you want to create a property for, you could run into an issue where that section of the code takes up 15 lines instead of like the, so far, managable 4 lines. Attached is the script as well as a short gif demonstrating what it does. Tysm
Vertex attribute editor
Error in Part 2, chapter 1, exercise 3
In this exercise, I’m to add a random colour to a point light and give the light a location. If I run the script repeatedly (after clearing the scene each time), however, I eventually get this error message which crashes the script: Python: Traceback (most recent call last): …line 46, in <module> …line 44, in add_light ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 3 items, not 4 Just wondering what’s happening. I’ve attached my blend file for reference. Thanks!
1-19 of 19
CG Python Academy (Free)
skool.com/cgpython
3D artists learning Blender Python.
Leaderboard (30-day)
Powered by