18. Building the update logic for elements

Questions and discussion for this lecture live here. Fire away by hitting Reply below :fire:

Hi Sean,

Iā€™m really enjoying the course so far; itā€™s definitely one of my favorites on this platform. Thanks for putting it together!

Iā€™m running into a couple of issues and was hoping to get some advice.

First, Blender has been crashing quite a bit, which is a little frustrating. Iā€™m trying to save frequently as you recommended at the beginning of the course, but I was wondering if thereā€™s anything else I could do to improve stability and reduce these crashes.

Second, Iā€™m having some trouble with the item updating implementation in Serpens. The node logic makes sense to me, and Iā€™ve replicated the steps in Serpens, double-checking against your implementation. Everything seems to match, but the code isnā€™t working as expected. I suspect the issue might be with the ā€œFunction Runā€ node for the Update Elements function. When I try to connect its output, the wire turns red, which seems like an error. In the terminal, I get the following:

Blockquote
Compiled successfully!
Traceback (most recent call last):
File ā€œā€, line 223, in sna_update_sna_structure_object
File ā€œā€, line 72, in sna_update_sna_structure_object_DB425
TypeError: object of type ā€˜NoneTypeā€™ has no len()
File ā€œā€, line 221, in sna_update_sna_structure_object

Additionally, Iā€™m unable to use the Print node to debug the output, as the Print node no longer seems to be working, even for parts of the code where I previously verified it was functioning correctly. Iā€™m sure Iā€™m missing somethingā€¦

Hey @Oliviero - great to hear youā€™re enjoying the course! Donā€™t forget to leave a review :wink:.

Ok - Blender does crash a little more than usual when youā€™re building addons - as I explain in the course - this is somewhat to be expected since weā€™re essentially generating code with our NodeTrees. That said - it shouldnā€™t be crashing so frequently that it becomes a significant issue during development. While originally developing StructureWorks - crashes were relatively frequent (say 1 every hour or two) but getting in the habit of manically saving my file, reduced this to a minor annoyance.

If Blender crashes when connecting up nodes - thatā€™s your first clue, look at what nodes youā€™ve just connected immediately before the crash - usually, youā€™ll be able to determine what the issue is - the console messages can also be helpful (and sometimes cryptic!) The only real advice I have for you here is to just try and tackle the source of each crash as it happens - try not to let multiple crashing bugs start to accumulate - and remember you always have the downloadable development file to compare against.

For youā€™re second question - itā€™s difficult for me to say exactly what the problem is - but you are correct - if the wire turns red, it means there is a compatibility error - youā€™re trying to do something that doesnā€™t make sense, could be a mismatched data type or a mismatched node type for example.

If youā€™re really hitting a brick wall with this - email me your development file (and associated scripts) in one big zip folder and Iā€™ll take a quick look for you.

BTW - Iā€™m just wrapping up the next batch of lectures - should go live this week.

SeƔn

Hey @Sean, I managed to solve it, and I really appreciate your helpful suggestions! I think what I needed most was to step away and come back to ā€œthe codeā€ with a fresh mind. I realized I had a few key connections missing because I didnā€™t fully understand how some nodes worked. Looking back now, I couldnā€™t see those mistakes the other dayā€”I was probably just too tired.

While I have your attention, Iā€™d like to ask you something else. I couldnā€™t find much online documentation about how to reference Blender elements in a Python script. For example, in our script for updating elements, we use something like edge.vertices[0]. But how do I figure out that ā€œverticesā€ is the correct way to access the vertices of the element? (I hope itā€™s considered a ā€œmethod,ā€ but Iā€™m not really sure about the terminology).

This example is maybe too simple because it feels intuitive, but in other cases, knowing how to navigate stuff like this would be useful.

Oliviero

p.s. I wanted to progress a bit further in the course so I could leave a more comprehensive review, but Iā€™ll definitely write one soon! As I mentioned, this course is something Iā€™m really enjoying, and I find it opens up so many possibilities.

p.p.s. I also canā€™t wait to see the new lessons!

Yes - very often, a break is all thatā€™s needed!

In terms of API docsā€¦you should find all you need hereā€¦Blenderā€™s official API doc siteā€¦itā€™s basically ā€˜ground zeroā€™ for all Blender Python API infoā€¦

No rush on your review :wink:

Cheers,
SeƔn