Geo Nodes and Python - Blender Tutorial

2024 ж. 21 Мам.
36 916 Рет қаралды

Advanced Geometry Nodes course: www.canopy.games/p/advanced-g...
Grab the beginner course: www.canopy.games/p/bcs-geomet...
Tutorial on how to read a CSV file into Blender with Python and store it on a mesh as named attributes.
I'm pretty new to Python so please let me know how to improve in the comments!
CSV files, python script, and final Blend file: / 75728528
---
$40 off a holographic display? Yes please. lookingglass.refr.cc/erindalew
Geometry Nodes Toolkit: gum.co/erintools
Merch? erindale.threadless.com/
Discord: / discord
---
Contents:
00:00 - Introduction
00:30 - What is a CSV?
03:34 - Planning the script
05:38 - get_file_path(file_name)
11:00 - read_csv(file_path)
13:50 - csv_column(data, col)
17:30 - Declarations
21:30 - Creating vertices with Geo Nodes
29:42 - tigger_update()
31:30 - add_attribute(obj, attr_name, type, domain)
37:25 - Write to our named attribute
38:25 - String to Int list
43:00 - Visualising the data with Goemetry Nodes
---
Patreon: / erindale
Ko-fi: ko-fi.com/erindale
Twitter: / erindale_xyz
Instagram: / e.r.i.n.d.a.l.e
Gumroad: gumroad.com/erindale
Blender Market: blendermarket.com/creators/er...

Пікірлер
  • Your script needs the object plane to be created (not added manually) and check if already exists when rerun ...

    @WahranRai@WahranRai13 күн бұрын
  • As a python noob myself i came up with this: def add_attribute(obj_name, attr_name, type="FLOAT", domain="POINT"): attr = bpy.data.objects[obj_name].data.attributes.new(attr_name, type, domain) return attr Only after an hour of trail and error though. Happy with myself, i was thinking afterwards maybe someone else had the same problem, only to read your comment😅 Anyways my line of thought was you can still parse the obj_name as a string and you don't have to parse the object itself Keep on the good work sir 💯 Your videos pop up always when i'm in need of the knowledge or when i didn't know i needed the knowledge♥

    @umadgrooves3449@umadgrooves3449 Жыл бұрын
    • Great work! Having those revelations for yourself are far more valuable than any tutorial or comment 🙌

      @Erindale@Erindale Жыл бұрын
  • Excellent visualization of data! You should do more python geo nodes tutorials! Maybe even a course!

    @mind_of_a_darkhorse@mind_of_a_darkhorse Жыл бұрын
    • Thank you! For sure, getting into Python has been amazing

      @Erindale@Erindale Жыл бұрын
  • A really nice walkthrough. Thanks as always!

    @boriskourt@boriskourt Жыл бұрын
  • So cool to finally meet you on common grounds!!^^ usually i have to focus quite a bit and think thrice before being able to follow your moves and today i find myself knowing your next logical step~ what a welcomed sight to have you explore every possible thing!!

    @sazaam@sazaam Жыл бұрын
    • Honestly just so excited about Python!

      @Erindale@Erindale Жыл бұрын
  • This tutorial is fantastic! ❤ Thank you for sharing Erindale!

    @CGPython@CGPython Жыл бұрын
    • If you want a bit more readability with your print statements, try `pprint` ``` import pprint pprint.print(price) ```

      @CGPython@CGPython Жыл бұрын
  • I'm pretty new to Python so please let me know how to improve in the comments! Edit: it was brought to my attention that I got latitude and longitude back to front so those high spikes should be London 😅 ---- I made a mistake on the add_attribute function. That's not the object name, that's the mesh name (it just aligns by default). It should actually be like this: def add_attribute(obj, attr_name, type="FLOAT", domain="POINT"): attr = obj.data.attributes.new(attr_name, type, domain) return attr

    @Erindale@Erindale Жыл бұрын
    • How have you been doing with C#? Heard a couple of months ago you were practicing

      @louis1001@louis1001 Жыл бұрын
    • @@louis1001 yeah started but stopped quite quickly to focus on Python. My work responsibilities are in Blender so it made sense ✌️

      @Erindale@Erindale Жыл бұрын
    • One thing you could be looking into is to use generators rather than lists to read in the csv. The code would be quite similar for the most part, but a few things would have to change. The big difference with generators is, that stuff gets read in on the fly (when it is actually needed), and then discarded (it's single-use, so if you want to continue access to the values, you'll have to store them again somewhere) The reason this is good, specifically for reading in files, is memory usage: A list is evaluated eagerly, meaning python tries to build it right away. But if you have a massive file with huge amounts of data, that can quickly turn into a huge bottleneck. In order to efficiently evaluate such large files, generators are much more suitable. One downside with generators is, that they are harder to debug, as you can't easily examine them: If you try to print out the value, that means the value gets read in, and therefore removed from the generator. A generator is basically like a for loop on stand-by. It only loops over the whole thing a single time. But the ability to handle much larger files is likely worth it, especially for production-scale situations.

      @Kram1032@Kram1032 Жыл бұрын
    • Instead of price_seq = [] for i in range(len(price)): price_seq.append(int(price[i])) this should be the exact same thing and slightly more efficient: price_seq = [int(p) for p in price] And since you are then just writing that to an attribute, likely not doing anything else with it, you could even go price_seq = (int(p) for p in price) with round parentheses rather than square brackets, which means it's a generator that gets instantly discarded once used. =================== =================== =================== doing the exact same thing for the coordinates is trickier but also possible, if you are willing to add some more utility stuff. For instance, you could write: def zeros(): while True: yield 0 which is an infinite sequence of 0s (another nice feature of generators is that this is possible without exploding memory, as they are taken on demand), and then go: coord_lists = (lattitude, longitude, zeros()) coords = [float(x) for t in zip(*coord_lists) for x in t] To see why this works requires quite a bit of understanding of these constructions. First, the * in front of coord_lists means "turn this iterable into a sequence" - essentially, you can use this to give an entire list or tuple etc. as an input to a function that only wants single values. Like, if you have: def add(a,b): return a+b you can call it like this: add(3,5) or you can also do this: inputs = [3, 5] add(*inputs) A sequence is like a naked tuple without the surrounding parentheses, basically. Next, zip takes the first element of each of its inputs and returns a tuple with those elements in it, then moves on to the next element, until the shortest input runs out. latitude and longitude should have the same length here, so that's not an issue. So at that point, if you have lat = [0,1,2] long = [0,-1,4] zeros = (0,0,0,...) and make it into a tuple (lat, long, zeros), zip(*(lat, long, zeros)) will give (0,0,0), (1,-1,0), (2,4,0) next, for t in zip(*coord_lists) iterates over this zip, so it takes out (0,0,0) and then (1,-1,0) and then (2,4,0) and stores it in t. And finally, for x in t will take those ts and iterate over them, so you end up with 0,0,0 and then 1,-1,0 and then 2,4,0 which together means the list gets flattened into 0,0,0,1,-1,0,2,4,0 which is what you want. Finally, since your lats and longs are actually strings, not integers, you want to call float(x) again. Putting it all together, you end up with the above coord_lists = (lattitude, longitude, zeros()) coords = [float(x) for t in zip(*coord_lists) for x in t] NOTE: This will ONLY work if lat and long have the same length. Otherwise, it *will* skip out on stuff and more complicated constructions are necessarily needed. For your use case here, that seems fine though.

      @Kram1032@Kram1032 Жыл бұрын
    • i've dabbled with coding on and off over the years, and always been kinda rubbish at it. this was really helpful. (so were @Kram1032's comments, for the record)

      @evilotis01@evilotis01 Жыл бұрын
  • Awesome Tutorial again and again, looking forward to more python combined with geo nodes tutorials.

    @kareldobbelaere1870@kareldobbelaere1870 Жыл бұрын
  • Kudos for this work! And kudos for your descriptive narration when adding nodes saying "add node Geometry: Sample Index or Mesh:Edge Neighbors". It makes it so much easier to find the nodes while listening, instead of fighting to remember which category it is in. Keep up the interesting work here... -David

    @drabodows@drabodows Жыл бұрын
    • Glad the format works for you! I know a lot of people just use the search but I like the menus for just discovering new nodes 😍

      @Erindale@Erindale Жыл бұрын
  • 47:11, voronoi from points, wow, pure wizardry!

    @Nicko16@Nicko167 ай бұрын
  • Thanks for the way of using python in blender with geometrynode. Data turns a beautiful mesh!!

    @blueitems1@blueitems1 Жыл бұрын
  • This became a very interesting tutorial about python in blender! It made me remember I made once a python script to import map data in text format into blender in the pre-geometry nodes time. I will have to adapt it to geonodes and share it also.

    @pedrotarroso@pedrotarroso Жыл бұрын
    • Nice! Yeah with geo nodes as a tool, python suddenly got a lot more interesting to me

      @Erindale@Erindale Жыл бұрын
  • python + geo nodes work almost like houdini sop. Great tutorial!

    @dejavu6591@dejavu6591 Жыл бұрын
  • very cool. i was also having some issues around 37 minutes creating the new attribute. at that point, for whatever reason it was creating the new price attributes onto my first plane that i'd ran the script on. i was deleting in between tries, but until i updated some stuff to be more like your final blend file I was having trouble adding it to my current selected object. guessing my own error somewhere. love your tutorials!

    @naughtynome4491@naughtynome4491 Жыл бұрын
  • Excellent tutorial and timing! I'm a Data Science student and I've been racking my brains for days about how I could create a more interesting visualisation of geodata for the next week's assignment (local restaurant ratings) with blender. This really fits perfectly, thank you so much for taking the time and explaining the process in detail.

    @DavidSchiess@DavidSchiess Жыл бұрын
    • Nice! Glad to help 😁

      @Erindale@Erindale Жыл бұрын
  • amazing tutorial. many more geo nodes and python to come i hope

    @meshybonehead7027@meshybonehead7027 Жыл бұрын
    • Let me know if you have any ideas ✌️

      @Erindale@Erindale Жыл бұрын
  • Exactly the tutorial I needed. Thanks!

    @JoseAlcerreca@JoseAlcerreca4 ай бұрын
  • Yes! I was waiting for something just like this!

    @XYZandRGB@XYZandRGB Жыл бұрын
    • Glad it's useful!

      @Erindale@Erindale Жыл бұрын
  • Woah, did not know I needed this until I saw it, nice work!

    @crackedConstant@crackedConstant Жыл бұрын
    • Thanks!

      @Erindale@Erindale Жыл бұрын
  • master merlin, very lovely magic you done. thx for sharing, have fun

    @aumhren3480@aumhren34806 күн бұрын
  • Amazing tutorial. Thank you!

    3 ай бұрын
    • Hope it helped!

      @Erindale@Erindale3 ай бұрын
  • It's so interesting!!! Great video mate!

    @mdriaz2002@mdriaz2002 Жыл бұрын
    • Thank you! You finally got me to start python

      @Erindale@Erindale Жыл бұрын
  • Excellent video. There's also a free add-on, the blender spreadsheet importer, developed by Simon Broggi, that works with both csv and json files to do most of the importing for you (any number of columns automatically imported to the correct number of points). Imports everything straight into general attributes that work well with geonodes.

    @CGFigures@CGFigures Жыл бұрын
    • There is! I should have mentioned it. I just wanted an excuse to write some Python 😁

      @Erindale@Erindale Жыл бұрын
    • @@Erindale I was working on a similar project right after BCon and wanted an excuse not to write python 😅

      @CGFigures@CGFigures Жыл бұрын
  • love your videos man, thanks for your effort.

    @alexeisaular3470@alexeisaular3470 Жыл бұрын
    • Thanks so much!

      @Erindale@Erindale Жыл бұрын
  • This is incredible. Can't wait to learn Python

    @UTubeSuhail@UTubeSuhail Жыл бұрын
    • Yes! It's a real accelerator

      @Erindale@Erindale Жыл бұрын
  • Thank you very much. Very nice explained lesson! 🙂

    @nurb2kea@nurb2kea Жыл бұрын
    • Thank you

      @Erindale@Erindale Жыл бұрын
  • This content is Great. I didn't know about CSV files... Now I know

    @visionary_3_d@visionary_3_d Жыл бұрын
    • JSON are also a good format and works maybe even better with python as they're just dictionaries

      @Erindale@Erindale Жыл бұрын
    • @@Erindale That is often what we use with Javascript! Data Visualization can be really cool whether you're creating a music visualizer or just visualizing city data like this.

      @visionary_3_d@visionary_3_d Жыл бұрын
  • by man finally learning python 👏🥳! keep it coming. (was a little overwhelming for me,but don't let that stop you. I have very minor coding experience)

    @shmuelisrl@shmuelisrl Жыл бұрын
    • Yes! Python is a blast

      @Erindale@Erindale Жыл бұрын
    • edit by = my

      @shmuelisrl@shmuelisrl Жыл бұрын
  • Great tutorial! Python + Blender opens many doors. I've messed around with geometry equations and such, but never considered loading in a CSV and using Blender as a visualizer 😲! It will be worth working on some beautiful and slick assets and use Blender as a super-charged "matplotlib" for data visualization. So many possibilities!

    @michaeldimattia9015@michaeldimattia9015 Жыл бұрын
    • Check out molecular nodes for some inspiration!

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Thanks! I'll cue that up next... Thank you for your content and contributions! Great work! I'm definitely inspired! Many blessings 🙂

      @michaeldimattia9015@michaeldimattia9015 Жыл бұрын
  • Oh, very cool. I know Python, and I use Blender. I have never put the two together before, but I've been wanting to learn about how Python might help me do stuff in Blender. I don't know much about Blender's Python API at all, so I really had no idea where to even start. I suppose this is as good a project as any to dip my toes in.

    @fakecubed@fakecubed Жыл бұрын
  • Incredible! Thanks a lot :)

    @PCgmesforever@PCgmesforever Жыл бұрын
    • Thank you

      @Erindale@Erindale Жыл бұрын
  • there is definite a possibility of visualizing data in 3d, please do more tuts on such topics, where data can be visualized in 3d

    @PranayVaidya007@PranayVaidya007 Жыл бұрын
    • Data vis is great fun. Going to do more definitely

      @Erindale@Erindale Жыл бұрын
  • Excellent video, thanks Erin! For the smoothing, instead of the multiple domain transfers, could you take the mean average from the attribute statistic and mix that with the actual data - the mix factor then becomes the smoothing amount?

    @duncanrudd348@duncanrudd348 Жыл бұрын
    • Doing the smoothing more localised will maintain overall regional trends which might be more representative. Totally depends on the data though and what you're using it for!

      @Erindale@Erindale Жыл бұрын
  • one of the coolest Blender+python+data tutorials I've ever seen! maybe the only one till now! I wanna learn python ASAP!! is it easy to use python for parametric design in architecture?

    @danialsoozani@danialsoozani Жыл бұрын
    • Yeah definitely! And mixing with geo nodes or Sverchok makes it extremely powerful

      @Erindale@Erindale Жыл бұрын
    • yeahh! I searched for sverchok tutorial and another tutorial of you came first, I'm watching it now!! thanks a lot for sharing these awesome and creative knowledge

      @danialsoozani@danialsoozani Жыл бұрын
  • Awesome stuff! here’s a shorter way to get the data into columns: col1, col2, col3, col4 = zip(*data[1:]) python is amazing 😊

    @hanlof1@hanlof1 Жыл бұрын
  • so useful. I did a tutorial on how to add blender models to your web page and basically just use html5 as a game engine. This would be very useful for online data visualisation

    @TommyLikeTom@TommyLikeTom Жыл бұрын
    • Woah nice! I'll have to check it out!

      @Erindale@Erindale Жыл бұрын
  • Erin, in the final part of the video, when you use the "Interpolate Domain" component there is no strategy to use the "For" loop in Python

    @brunodemasi381@brunodemasi381 Жыл бұрын
    • There is no method? Or there is? Geo Nodes will always be faster than any pure python stuff because it's in c and c++. We'll have a Smooth Attribute node though in 3.5 so best to use that for blurring attributes

      @Erindale@Erindale Жыл бұрын
  • You could also use the python api to create a grid mesh and add a property layer with the value you want. That thing with the node array seems a little awkward.

    @Andreas-gh6is@Andreas-gh6is Жыл бұрын
    • Yeah you can, I just didn't want to get deeper into python than absolutely necessary. I want people who are outside code to feel like they can start employing it alongside their tools. It's way too intimidating for most users to use for more than necessary 😅

      @Erindale@Erindale Жыл бұрын
  • if you want the proper index for the fill curve it is the same as the index and that is the point where you are loosing the data (side point: based on this idk why the developers can't make it retain there attributes) so you can use a sample by index frome right after the join geometry to a capture (or store) right after the fill curve and you can retain your data (I think you already know this. you probably just weren't thinking of it)

    @shmuelisrl@shmuelisrl Жыл бұрын
  • Hi Erin, nice tutorial as always! I just came here right after completing your Advanced Geometry Nodes Course (which btw, it is awesome). Btw, do you know if it is possible to program GeoNodes nodes in python, and the use them inside any GeoNode graph? Just like in Unreal Engine you can program functions in c++ and then use them in Blueprint graphs, I was wondering if you can program in Python nodes and use them inside GeoNodes 🤔

    @egalestrengehart@egalestrengehart Жыл бұрын
    • Unfortunately not at this moment. You could build your own blender though with custom nodes coded in C

      @Erindale@Erindale Жыл бұрын
  • As usual a great video, idea and situation... you should do a full training, Node and Dev like that, I will be happy to foll

    @philfounarcoleptik3d679@philfounarcoleptik3d679 Жыл бұрын
    • Thanks so much

      @Erindale@Erindale Жыл бұрын
  • Could be OS/Python version-specific (I'm on Mac, in case any other Mac people are following along), but so far I've got 2 mods: - when getting the file_path, I wrapped the path.join call in an os.path.normpath() call since my system was choking on a weird path. Then it works. - maybe the array variable is only local scope in the csv_column function? It was printing "None", but then when I "return array" at the end of it everything is fine.

    @TadThurston@TadThurston Жыл бұрын
    • Nice thanks for sharing!

      @Erindale@Erindale Жыл бұрын
  • What are the book titles in the background? I recognise some of them, but not all

    @adrimathlener8008@adrimathlener8008 Жыл бұрын
  • Haven't watched yet, but wanted to ask you a question directly before I cracked into this video. Using geometry nodes for modeling objects that need simple/uniform shapes, like doing buildings with some level of interior, or basic props I can easily repurpose: yay or nay? There are several reasons for why I'm considering this and why I think nodes would be advantageous for me, but in short.. Can't tell if it's practical to do that yet, or if I need to wait for a few more updates. I think last time I messed with nodes, I was trying to make a brick wall with multiple brick sizes and random order of the bricks.. gave up because, after asking someone who better knew the nodes, found out that the system at the time (new with most content in beta) didn't have a way to really make the array space itself out properly. I also enjoy coding, Python, and secretly hope this may see the game engine return allowing me to use Blender systems directly in a novel project. Already saw "Cartesian Caramel" make a simple game with the 3.5 Beta and the simulation nodes.

    @purpletrauma@purpletrauma Жыл бұрын
  • Hi @Erindale Awesome as always! one question! im trying to update the 'scene camera', position and rotation, with the position and rotation of an instance get from and instance on points NODE in geometry nodes, I see all the data on the spread sheet, but I cant access it from GeoNodes, is there a way to do it tough python though? cheers!

    @patriciocalvelo1839@patriciocalvelo1839 Жыл бұрын
    • An easy, non code way would be to make a new vertex object and select the camera, shift select the vertex object, tab into edit mode, select the vertex, ctrl+p and make vertex parent. Now the camera will follow that specific vertex and you can control the vertex through geo nodes

      @Erindale@Erindale Жыл бұрын
    • @@Erindale thanks for the answer! I did exactly what you said and I did try it before, but after the vertex is affected by instance on points, the camera is not following anymore the vertex, even if I realize instances, and I have a selection where I have only one point per frame.

      @patriciocalvelo1839@patriciocalvelo1839 Жыл бұрын
  • jeez, your camera is moving with your head ! lol, thx for sharing, have fun

    @aumhren3480@aumhren34806 күн бұрын
  • This video actually made me write my very first comment on KZhead. I've been following your videos for a long time and haven't seen anything comparable to your content on KZhead in terms of precision and ambition. As a software developer with years of Python experience myself, who was once proud of his first for loop that always outputs the same thing to the command line, I can only encourage you to continue on this path. I'm very excited to see what else you'll do with your skills. Erindale, Python and Geometry Nodes sounds like a combination to me that will soon move the topic of 3D rendering into the fourth dimension. Your content is incredibly inspiring and educational. Very high compliments! 👍

    @a-python-script@a-python-script Жыл бұрын
    • Thank you so much! I dropped out of uni in 2014 because I failed python 101 so finally learning to code and combine with blender and geometry nodes has been extremely affirming! Very excited to see how we can extend these tools as they continue to develop!

      @Erindale@Erindale Жыл бұрын
  • For data like this with such massively different scales, looking at it logarithmically might be a good idea

    @Kram1032@Kram1032 Жыл бұрын
    • Good shout!

      @Erindale@Erindale Жыл бұрын
    • Yeah, I was about to post the same thing. Either a logaritm or possibly a square root or something. The problem of course being that nonlinear mappings aren't as intuitive where you can look at something and immediately see that A is twice as big as B, but for datawiz, that's not necessarily important

      @wheany@wheany Жыл бұрын
    • @@wheany can always do both side by side if that's a big concern. The linear version to demonstrate the extreme difference, the logarithmic version to actually fit it all together into a single view

      @Kram1032@Kram1032 Жыл бұрын
  • Have you found your new house? excellent video, thank you, do more of it please.

    @nicolanarracci@nicolanarracci Жыл бұрын
    • Not finalised yet but I'm working on it! Thanks, definitely want to do more python fun

      @Erindale@Erindale Жыл бұрын
  • in the minute 27, where is the name "Input_2" defined? can it be change? thanks for the video! amazing

    @joaomacaumaia3834@joaomacaumaia3834 Жыл бұрын
    • If you hover over the modifier controls with python tooltips turned on then you should see the path there

      @Erindale@Erindale Жыл бұрын
  • If Simon Pegg did tutorials. Great content.

    @davef21370@davef213705 ай бұрын
    • 😂

      @Erindale@Erindale5 ай бұрын
  • Can this be used in creating the Colorful dashboard which is used to depict data using data used by data scientists

    @PranayVaidya007@PranayVaidya007 Жыл бұрын
    • I don't see why not. Data is just numbers and colour is just numbers so it's just about how you manipulate it once you have it inside Blender

      @Erindale@Erindale Жыл бұрын
  • any word on smoothing attributes? It would be cool if i could change it from accurate to more visual with just a slider

    @Firelegs101@Firelegs1015 ай бұрын
    • We do have a blur attribute node now so you can blur an attribute across connected geometry (continuous edges). Each blur iteration is a connection further over which it’s averaging

      @Erindale@Erindale5 ай бұрын
  • Is bpy.data.scenes[0].update_tag() not working to update? Switching between edit and object mode would be very slow with many verts.

    @kenjinks5465@kenjinks5465 Жыл бұрын
    • I've had update_tag() fail to solve the issue for me during mesh bakes using geo nodes unfortunately... Edit toggle is just a belt and braces method. I don't think it was really needed in this case though

      @Erindale@Erindale Жыл бұрын
    • @@Erindale I'll take a look for a solution, it is a common one, I know the python api had changed, it used to be just .update(). The edit toggle technique will stall my system when I'm in the millions of verts.

      @kenjinks5465@kenjinks5465 Жыл бұрын
  • Can someone expleain to me how works csv_column function ?

    @cagdasalperyegit1865@cagdasalperyegit1865 Жыл бұрын
  • Is it also possible to just have a list of numbers and just set them as a new atribute? e.g: [1,5,3,4,3,2,1...] and based on the index you would apply one of those numbers to one point. At the index of an object´s vertex is "0" the first number would be applied to the vertex

    @blendcreator@blendcreatorАй бұрын
    • Answered on discord but in case anyone has the same question: 1. Create a sequence of values as a flat list with enough values to cover the geometry (even if they’re just 0s) 2. Write that to an attribute with “obj.data.attributes[attr_name].data.foreach_set(‘value’, sequence)

      @Erindale@ErindaleАй бұрын
  • Hi, thank you for this amazing tutorial, I followed along myself and tried to put a color ramp on the extruded geometry so that it would change color on the material depending on the price, does anyone know how to do this or know a good video explaining something similar to this? Could not find it myself.

    @gabrieleriksson6108@gabrieleriksson6108 Жыл бұрын
    • Colour ramps work on a 0..1 range so you want to probably do something like map range the price attribute and use an attribute statistics node to find the min and max values to use as your from min/max. Then your to min/max will be 0 and 1. This can go into your colour ramp and then just store that colour on the geometry to use in the shader with an attribute node

      @Erindale@Erindale Жыл бұрын
    • @@Erindale It worked great, thanks a lot!

      @gabrieleriksson6108@gabrieleriksson6108 Жыл бұрын
  • i have a gold price data in .csv format, from 1969-2022, daily prices, open-high-low-close, aka bars. a LOT of data. once upon the time, i imported it into blender. it took (exaggerating) years to import, and when i was moving the 'chart', blender was struggling to keep up. any suggestions how could i draw price bar chart (calendar / time as x axis (horizontal)), in blender, without contributing to air pollution immensely ? usually chart would be drawn with python module, ie plotlib, or similar. thx for sharing, have fun

    @aumhren3480@aumhren34806 күн бұрын
    • As long as you’re drawing with geo nodes then you should be fine. Using python to evaluate and process that much data will always be slow in Blender. Writing what you need to vertices one time will take time as well but after that you can just plot your charts with curves in GN and curve to mesh at the end to make visible. That object should be easily tranformable!

      @Erindale@Erindale5 күн бұрын
  • Blender is HOR-RI-BLE at maintaining a consistent workflow through python. I'm trying to make a custom node group through code and there is not enough up to date info (if any).

    @Murderface666@Murderface666 Жыл бұрын
    • Traversing node trees with python is actually okay once you get your helper functions down. You are pretty much just walking back and forward though

      @Erindale@Erindale Жыл бұрын
  • Do you know of any way to put strings in as attributes? I can add a STRING attribute, but don't know how to fill it out or output it.

    @toboraton@toboraton11 ай бұрын
    • In geometry nodes? There is no way to store a string on geometry. We can only store things that are numerical like vectors and floats etc

      @Erindale@Erindale11 ай бұрын
    • @@Erindale ha! I have had that realization. Strange that one can add a string field, but not values. I'm trying to animate the chart of the nuclides, a table of thousands of nuclides with a unique combo of neutrons/protons and an element label. Do you know if I can use existing float/integer attributes to make indexed strings?

      @toboraton@toboraton11 ай бұрын
    • What do you mean by indexed strings? Fyi if it's not necessary for geometry nodes, you can store and reference strings as custom properties on objects via python

      @Erindale@Erindale11 ай бұрын
    • @@Erindale Basically I have an array data 3000 items long. They have 3 important pieces of data associated with them, an x location, y location, and a label. I want to make a square at the center of each x,y location, and label it with the x location, y location, and letter label. I imported the letters as a collection, so they are sorted out. I could do the same thing with the X and Y labels, but I'd rather use the imported data that I've already put in blender (imported by following your steps in this video.) So my question is, how do I take the values (floats) of an attribute, and convert it to a string?

      @toboraton@toboraton11 ай бұрын
    • You should check out how people have made index viewers in geo nodes. There is a value to string node but it doesn't work for fields, only constant values. Try this one by Riaz, you might find some techniques you can use in there artofriaz3d.gumroad.com/l/indexviewerfields?layout=profile

      @Erindale@Erindale11 ай бұрын
  • For the list type conversion - a better practice in python is to use a list comprehension. I appreciate you might have been trying to stay simple for teaching reasons but I think with python the list comprehension is such a essential construct might be worth learning early. Anyway. [ int(x) for x in price] - which basically says make a new list with int(x) for each item 'x' in the list price. given the odd coordinates vector that blender accepts - with interleaved items rather than tuples - the way you did it might be the most obvious

    @markwilliamson6884@markwilliamson6884 Жыл бұрын
    • Thanks! I'm very new to coding so also my own ignorance. I'll do some reading up on list comp

      @Erindale@Erindale Жыл бұрын
    • @@Erindale so, and I'm sure I'm preaching to the converted here- NEVER apologise for learning :-). Every language has its 'thing's and the only way you really learn them is from other practitioners and seeing what they do. & like I say - list comprehensions are one of those things in python. You will come across them everywhere in python code. (also they are pretty nifty - very succinct and readable I find). I'm just making a version of your script (with random numbers) just to see if there is an easier way to do the longitude and latitude thing - the blender data structure with the sequence of long,lat,0, long,lat,0 is not at all 'pythonic' although super common in C and similar languages :- )

      @markwilliamson6884@markwilliamson6884 Жыл бұрын
    • @@Erindale for the coords - given the weird structure it's kind of a lot less obvious coords = [itm for lst in [ [float(lo),float(la),0] for lo,la in zip(long,lat)] for itm in lst ] coord_attr.data.foreach_set('vector',coords) the itm for lst in [ < make a list of lists of coordinates >] for itm in lst] just flattens the list of lists BUT I had to figure out how to write that & I've written python for a living for 20 odd years so :-). Normally a python function would be expecting something like that inner part - just a list of coords as lists or tuples (tuples are a kind of fixed list represented by () rather than [])

      @markwilliamson6884@markwilliamson6884 Жыл бұрын
    • @@Erindale oh and BTW - I learned a lot from this too - I've not really used python in blender yet so cool to see the steps :-) so thank you

      @markwilliamson6884@markwilliamson6884 Жыл бұрын
    • Woah yeah the make a list of lists and then flatten it I would not be able to Google so I will put this straight into my snippets list. I have a good foundation in the logic side from Sverchok and Geometry Nodes but the syntax and specifics of the blender API have taken some time to start to understand

      @Erindale@Erindale Жыл бұрын
  • at 37:00 when you run the script my spreadsheet doesn't add a price column, I've been over it a couple times and I've checked my spelling. Anyone have ideas?

    @jdenn3@jdenn3 Жыл бұрын
    • lol ok one minute later I realized if you delete the modifier on the object the price column shows up. don't exactly know why tho

      @jdenn3@jdenn3 Жыл бұрын
    • That is odd but I'm glad you got it working 😂

      @Erindale@Erindale Жыл бұрын
    • @@Erindale This happened to me too, but when I delete the modifier, the price column does not show up. No errors and rechecked my spelling so many times. Do you know what it could be?

      @mackenzierpage@mackenzierpage Жыл бұрын
  • I’ve tried working through this, but get stuck on the attribute creation stage, which isn’t working. I’m on v3.3, so am now wondering if this part is specific to v3.4 only?

    @GbHandlebar@GbHandlebar Жыл бұрын
    • Nope, worked for a while. What error are you getting? The final script is on the patreon link if you want to compare

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Instead of adding the new column in the spreadsheet, it just empties it completely. No actual error is returned to the Python console.

      @GbHandlebar@GbHandlebar Жыл бұрын
    • @@GbHandlebar odd... Must be an error somewhere. You can share your code here or discord if you want

      @Erindale@Erindale Жыл бұрын
  • Hi Erindale I am getting this error when I run it on the Mac but works fine in windows NotADirectoryError: [Errno 20] Not a directory: This is the path (on Mac) '/Users/myNames/Dropbox/blender/Erindale_tutorials/process_csv.blend/../test_data.csv' Can you please suggest a solution for the Mac path issue Thank you very much.

    @GlassCanvas@GlassCanvas Жыл бұрын
    • Looks like Mac doesnt like using .. for parent directories. Rather than making your path that way, try this: os.path.join(os.path.dirname(bpy.data.filepath), "test_data.csv")

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Thank you that works with both PC and MAC

      @GlassCanvas@GlassCanvas Жыл бұрын
    • Here is the function. def get_file_path(file_name): '''Get the file path, works with PC and Mac''' # This works on PC & Mac file_path = os.path.join(os.path.dirname(bpy.data.filepath), file_name) # This only works on PC # file_path = os.path.join(os.path.dirname(__file__),"..", file_name) return file_path

      @GlassCanvas@GlassCanvas Жыл бұрын
    • @@GlassCanvas yeah that's the more "proper" way of doing things 😅 I grew up on command lines in Linux so I'm used to navigating file systems with cd commands

      @Erindale@Erindale Жыл бұрын
  • Have you ever been told you are the bob ross of blender? cause its 100% true

    @WibleWobble@WibleWobble Жыл бұрын
    • Hahah thank you it happened so much I started calling my livestreams the Joy of Proceduralism 😂

      @Erindale@Erindale Жыл бұрын
    • @@Erindale oh yeah! I noticed the name but I thought nothing of it, but now it completely makes sense

      @WibleWobble@WibleWobble Жыл бұрын
  • If you use Pandas to read your CSV, it is much more performant and you can slice and index the data in numerous ways.

    @Drew_Vernon@Drew_Vernon Жыл бұрын
    • Pandas is a good shout! Thanks

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Pandas is very powerful, but it doesn't come as part of the standard library, so you would need to install it with pip. That can be a bit tricky to do in Blender, but it's definitely possible! Could also be a bit hard to put in a tutorial for beginners, but you could probably make it work!

      @StrikeDigital3D@StrikeDigital3D Жыл бұрын
    • ​@@StrikeDigital3D My approach is to rename the Blender site-packages folder to site-packages_old, and then create a symbolic link to my main site-packages folder. This way, I can use all of my regular libraries in Blender without issue. I've got code that uses Numpy, SciPy, Pandas, and other libs inside Blender; with Visual Studio Code setup as my IDE. Only thing I haven't really got setup properly yet is debugging and code linting. Haven't quite figured that bit out yet. You can do all sorts of funky stuff by integrating Blender into your wider Python environment. Super cool!

      @Drew_Vernon@Drew_Vernon Жыл бұрын
    • That sounds great! The vscode blender development add-on is good for running blender and debugging to vscode and you can do line by line with it too

      @Erindale@Erindale Жыл бұрын
    • But also sym links are even more not beginner tutorial friendly 😂😭

      @Erindale@Erindale Жыл бұрын
  • I can't get this working on Blender+Ubuntu at all. __file__ just returns / I tried half a dozen suggested fixes from googling but cannot get __file__ to return anything else. The same code run from a terminal returns an absolute path. Inside Blender it only returns /. I've tried a few alternative methods but they come out the same, blender thinks the current script is in root.

    @petebateman143@petebateman143 Жыл бұрын
    • Try bpy.data.filepath to get the current blend file or os.path.dirname(bpy.data.filepath) for the directory

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Thanks, I'll give that a go.

      @petebateman143@petebateman143 Жыл бұрын
  • You made a terrain generator based on house price data and are sharing your diabolical UK terraforming plans in a coded message? 🤔

    @juryrigging@juryrigging Жыл бұрын
  • Unfortunately it's not working for me, because of several "undefined" things in the code :/

    @kleinaber_manu@kleinaber_manu Жыл бұрын
    • Probably you're not using a version of Blender that's as recent as this

      @Erindale@Erindale Жыл бұрын
    • @@Erindale I use 3.5.0 Do I need to install a plugin or another software first?

      @kleinaber_manu@kleinaber_manu Жыл бұрын
  • got the feeling that coding in python might finish be more confortable than geometric nodes lol

    @samduss4193@samduss41935 ай бұрын
  • Link to the project files for those who have Patreon blocked: drive.google.com/file/d/1ADGJtgNrBJl2Q_rVRkzLoj2QAcNQun9y/view?usp=share_link

    @mrdixioner@mrdixioner Жыл бұрын
    • Why are people blocking Patreon? 🤔

      @Erindale@Erindale Жыл бұрын
    • @@Erindale Patreon is blocked in Russia. I don't know why, but it is.

      @mrdixioner@mrdixioner Жыл бұрын
    • It doesn't work for me. Do I have to install something first?

      @kleinaber_manu@kleinaber_manu Жыл бұрын
    • What version of Blender are you using?

      @Erindale@Erindale Жыл бұрын
    • @@Erindale I use 3.5.0 Do I need to install a plugin or another software first?

      @kleinaber_manu@kleinaber_manu Жыл бұрын
  • AHH! Where is this source code. I need to fix it

    @busterdafydd3096@busterdafydd3096 Жыл бұрын
    • 😂

      @Erindale@Erindale Жыл бұрын
  • I love the tutorial. But maybe installing pandas is worth a try. Then the code is just "import pandas data = pandas.read_csv('export.csv') print(data) print(data["name"][1])"

    @BlenderFun_@BlenderFun_ Жыл бұрын
    • Nice one! Thanks for the code snippet

      @Erindale@Erindale Жыл бұрын
    • @@Erindale you are welcome. Learnt a lot from your tutorials!

      @BlenderFun_@BlenderFun_ Жыл бұрын
    • Unfortunately you can't import pandas or any modules into blender... Otherwise numpy and pandas would be at the top of the list for me lol

      @paullarkin2970@paullarkin2970 Жыл бұрын
    • @@paullarkin2970 of course you can. I will make a tutorial about it today. It’s a bit too much to explain in comments. You can install any module which you can install in python for Blender-python as well.

      @BlenderFun_@BlenderFun_ Жыл бұрын
    • @@paullarkin2970 I made a small tutorial, how you can do it: kzhead.info/sun/Zd6AeamKf4dooKM/bejne.html

      @BlenderFun_@BlenderFun_ Жыл бұрын
  • Weird, I did stuff like this in R (not ARGH!) the software... I assume you can do statistics in python, IIRC numpy or something? So, if you ain't gonna do cool statistical analysis... you're leaving that up to me... damn you, I can't resist statistical analyses that aren't lies, damn lies... or statistics... yeah, I didn't get a job in my Masters concentration cause I wouldn't fake whatever the results were being paid for... After I destroy my logo, maybe. I was never shown or cared what CSV databases were... I just thought of them as Excel files... man, once behind the curtain, how ordinary...

    @jeffreyspinner5437@jeffreyspinner5437 Жыл бұрын
    • Enjoy! 😂

      @Erindale@Erindale Жыл бұрын
    • @@Erindale I noticed a large long number attached to an invite I gave to a person that wanted to get her GN creation into Unity. That's metadata to uniquely identify who sent what to whom, right? I've never seen suffixes at all on any discord invite until yours yesterday... dun dun dunnnnn. Just wondering, given my experience with Twitter metadata is a larger portion of the whole data sent than the tweet itself, and with the right AIs can tell the current health status of the user... I stopped training to be a data engineer after that project. I will only be taken advantaged of once in my life creating weaponized stuff... but that's all the job offers I've gotten since my grad degree... That's why I ask, that long string of numbers pinged my passed life...

      @jeffreyspinner5437@jeffreyspinner5437 Жыл бұрын
KZhead