Mesh Editing in Blender with Python: I Wish I'd Learned THIS Sooner

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • Join me in this tutorial as I dive deep into using context managers in Blender for mesh editing with Python's bmesh module. I'll walk you through a hands-on example of transforming code to use a context manager and demonstrate how to effectively debug it in VSCode. By the end, you'll not only gain a solid understanding but also have challenges to test and reinforce your skills. Perfect for those eager to enhance their Blender-Python prowess!
    Blender Python script that bevels the edges of an active object that is in OBJECT mode
    gist.github.com/CGArtPython/3...
    Blender Python script that bevels the edges of an active object that is in EDIT mode:
    gist.github.com/CGArtPython/c...
    Blender Python script that bevels the edges of an active object that is in EDIT mode:
    gist.github.com/CGArtPython/c...
    Script explanation in this video "Blender Scripting Guide: Mastering Mesh Editing with Python"
    • Blender Scripting Guid...
    5 Steps to setup VSCode for Blender Python (on Windows)
    • 5 Steps to setup VSCod...
    5 Steps to setup VSCode for Blender Python (on macOS)
    • 5 Steps to setup VSCod...
    5 Steps to setup VSCode for Blender Python (on Linux)
    • 5 Steps to setup VSCod...
    #Blender #Python #bmesh #VSCode

Komentáře • 39

  • @CGPython
    @CGPython  Před 10 měsíci +2

    Here is a link to the video with the advanced version of the context manager:
    czcams.com/video/XcdCzB3tILs/video.html
    I have a short video explaining decorators here:
    czcams.com/users/shortsXzDFbWnWxzU

  • @alvarobyrne
    @alvarobyrne Před 10 měsíci +6

    cool! please delve into more advanced topics and version of this one! well done! Learning tons here! Both python and blender!

    • @CGPython
      @CGPython  Před 10 měsíci +2

      Thank you!
      I'll share the more advanced version of this code soon.

    • @CGPython
      @CGPython  Před 10 měsíci +2

      Here is a link to the video with the advanced version of the context manager:
      czcams.com/video/XcdCzB3tILs/video.html
      I hope you like!

    • @alvarobyrne
      @alvarobyrne Před 10 měsíci

      @@CGPython sure do

  • @BrettKromkamp
    @BrettKromkamp Před 7 měsíci +1

    The best CZcams channel to learn Python scripting in Blender ❤

  • @phiarchitect
    @phiarchitect Před 9 měsíci

    The best demonstration of a custom context manager I have seen.

  • @ckat609
    @ckat609 Před 5 měsíci

    Soooo good! Thank you!

  • @mind_of_a_darkhorse
    @mind_of_a_darkhorse Před 10 měsíci

    Excellent explanation! Now, people have a new way to do things! I knew about context managers, but did not really understand how to use them! This is a big help!

    • @CGPython
      @CGPython  Před 10 měsíci

      Thank you!
      That is great to hear! 🥳

  • @root0062
    @root0062 Před 10 měsíci +2

    Thank you. Your an excellent teacher. You've given me a few tips that has already made me more peofficient in just a few weeks of practice.
    Really thank you sir 🙏
    Edit: I'd be interested to see the more advanced work around.
    However I do enjoy a good challenge !

    • @CGPython
      @CGPython  Před 10 měsíci +2

      Wonderful! ❤️
      I'll share the advanced version soon.

    • @CGPython
      @CGPython  Před 10 měsíci +1

      Here is a link to the video with the advanced version of the context manager:
      czcams.com/video/XcdCzB3tILs/video.html

    • @root0062
      @root0062 Před 10 měsíci

      @@CGPython Wow! thank you so much. Really appreciate this 🙏 🙏

  • @MetalGearMk3
    @MetalGearMk3 Před 10 měsíci

    I just discovered your channel :O

  • @CGPython
    @CGPython  Před 10 měsíci +1

    I have a short video explaining decorators here:
    czcams.com/users/shortsXzDFbWnWxzU

  • @jonathanhutchinson5649
    @jonathanhutchinson5649 Před 10 měsíci +1

    Id happily see the more advanced version. Is it used the overrides thingamy? This was an interesting video. Where on StackOver/etc did you come across it? Although it does feel a bit magical/not intuitive that it yields and then jumps and runs the line of code then back into the function.

    • @CGPython
      @CGPython  Před 10 měsíci +2

      I'll share the advanced version of this code soon. ⌛
      I actually have two more versions, one with a nested context manager and one using a class context manager.
      > Where on StackOver/etc did you come across it?
      I didn't really find it anywhere. I have been using Python for a long time. Eventually, you start seeing where to use context managers, just like in that scene in The Matrix movie. 😅

    • @jonathanhutchinson5649
      @jonathanhutchinson5649 Před 10 měsíci

      @@CGPython nice. I guess the extra import is the only downside. But yeah the whole stuff of repeated boiler plate code in blender and being in the right bpy.context, which is a minefield in itself, can lead to (for me personally) a lot of searching around repeatedly for certain lines again and again.

    • @CGPython
      @CGPython  Před 10 měsíci

      ​@@jonathanhutchinson5649 this is video with the advanced version of the context manager:
      czcams.com/video/XcdCzB3tILs/video.html

  • @SD_simma
    @SD_simma Před 10 měsíci

    Can you do video about practice vfx effect using Python into Blender's API with geometric nodes?

    • @CGPython
      @CGPython  Před 10 měsíci

      I have done a couple of videos on working with geo nodes from Python
      czcams.com/video/Is8Qu7onvzM/video.html
      czcams.com/video/hlZ_cFSlaMs/video.html
      I need to loop back to some Python geo nodes at some point.

  • @MetalGearMk3
    @MetalGearMk3 Před 10 měsíci

    How would you create a script to split edges at their midpoint, with the selection order kept in mind? I want to create an new edge between the selected edges at the midpoints.

    • @CGPython
      @CGPython  Před 10 měsíci +1

      After that operation, you will have a split face, right?
      This should work for you
      with get_bmesh(mesh_obj) as bm:
      selected_edges = [edge for edge in bm.edges if edge.select]
      bmesh.ops.subdivide_edges(bm, edges=selected_edges, cuts=1)

    • @MetalGearMk3
      @MetalGearMk3 Před 10 měsíci

      @@CGPython Thank you ! As a modeler I would love to see more tut on bmesh. Like how would you write a script to spin a edge clockwise. Assume you have 2 quads and you select the the middle edge, now you want to spin that edge clock wise.

    • @CGPython
      @CGPython  Před 10 měsíci

      Great idea!

  • @bohdanpolovinka178
    @bohdanpolovinka178 Před 10 měsíci +1

    I open texture using this code, and cant assign it to displayce modifier:
    import bpy
    bpy.ops.image.open('INVOKE_DEFAULT')
    In your example using voronoi texture (not image from pc)
    I can assign voronoi and other generated textures, but i cant assign image from pc
    Thank you

    • @CGPython
      @CGPython  Před 10 měsíci

      try this
      gist.github.com/CGArtPython/0f74f1c71051150514df309052a3a190

  • @SD_simma
    @SD_simma Před 10 měsíci

    And can you do a beginner tutorial on using Python for Animation in Blender's Bpy?

    • @CGPython
      @CGPython  Před 10 měsíci +1

      Have you seen this playlist?
      czcams.com/video/nmJqIaSZlRs/video.html
      I have a couple of videos on animation at the start of the playlist

    • @SD_simma
      @SD_simma Před 10 měsíci

      @@CGPython definitely missed that Playlist. Thanks

  • @bohdanpolovinka178
    @bohdanpolovinka178 Před 10 měsíci +1

    How to assign image texture to displayse modifier using pythom??? HELP! HELP! HELP!

    • @CGPython
      @CGPython  Před 10 měsíci

      In this file
      github.com/CGArtPython/blender_plus_python/blob/main/holder/script_done.py
      look for the `def add_displace_modifier(name, texture_type, empty_obj=None):` function
      I go over an example use case in this video
      czcams.com/video/Z7tVeI1D7CY/video.html

    • @bohdanpolovinka178
      @bohdanpolovinka178 Před 10 měsíci

      thank you@@CGPython

  • @WahranRai
    @WahranRai Před 3 měsíci +1

    too fast !
    background music disturbing

  • @mikeeotool2677
    @mikeeotool2677 Před 7 měsíci

    if you only teach the correct way to script, you dont have to show or mention what can go wrong or any alternative way to do the same thing, if a beginer learns the correct way to doit from the egining, then he would not make any mistakes. simplifie your tuts, they will e more useful.

    • @CGPython
      @CGPython  Před 6 měsíci

      Thank you for the input!
      The "correct way" to script is a subjective thing.
      For example, writing scripts in pythonic way requires a lot of preparation. I can't think of a good way to teach that from the start.