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

Поделиться
HTML-код
  • Опубликовано: 2 авг 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

Комментарии • 39

  • @CGPython
    @CGPython  11 месяцев назад +2

    Here is a link to the video with the advanced version of the context manager:
    ruclips.net/video/XcdCzB3tILs/видео.html
    I have a short video explaining decorators here:
    ruclips.net/user/shortsXzDFbWnWxzU

  • @alvarobyrne
    @alvarobyrne 11 месяцев назад +6

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

    • @CGPython
      @CGPython  11 месяцев назад +2

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

    • @CGPython
      @CGPython  11 месяцев назад +2

      Here is a link to the video with the advanced version of the context manager:
      ruclips.net/video/XcdCzB3tILs/видео.html
      I hope you like!

    • @alvarobyrne
      @alvarobyrne 11 месяцев назад

      @@CGPython sure do

  • @BrettKromkamp
    @BrettKromkamp 8 месяцев назад +1

    The best RUclips channel to learn Python scripting in Blender ❤

    • @CGPython
      @CGPython  8 месяцев назад

      Thanks Brett ❤️

  • @ckat609
    @ckat609 6 месяцев назад

    Soooo good! Thank you!

  • @phiarchitect
    @phiarchitect 10 месяцев назад

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

    • @CGPython
      @CGPython  10 месяцев назад

      Thank you! ❤️

  • @mind_of_a_darkhorse
    @mind_of_a_darkhorse 11 месяцев назад

    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  11 месяцев назад

      Thank you!
      That is great to hear! 🥳

  • @root0062
    @root0062 11 месяцев назад +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  11 месяцев назад +2

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

    • @CGPython
      @CGPython  11 месяцев назад +1

      Here is a link to the video with the advanced version of the context manager:
      ruclips.net/video/XcdCzB3tILs/видео.html

    • @root0062
      @root0062 11 месяцев назад

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

  • @MetalGearMk3
    @MetalGearMk3 11 месяцев назад

    I just discovered your channel :O

  • @CGPython
    @CGPython  11 месяцев назад +1

    I have a short video explaining decorators here:
    ruclips.net/user/shortsXzDFbWnWxzU

  • @jonathanhutchinson5649
    @jonathanhutchinson5649 11 месяцев назад +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  11 месяцев назад +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 11 месяцев назад

      @@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  11 месяцев назад

      ​@@jonathanhutchinson5649 this is video with the advanced version of the context manager:
      ruclips.net/video/XcdCzB3tILs/видео.html

  • @SD_simma
    @SD_simma 11 месяцев назад

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

    • @CGPython
      @CGPython  11 месяцев назад

      I have done a couple of videos on working with geo nodes from Python
      ruclips.net/video/Is8Qu7onvzM/видео.html
      ruclips.net/video/hlZ_cFSlaMs/видео.html
      I need to loop back to some Python geo nodes at some point.

  • @bohdanpolovinka178
    @bohdanpolovinka178 11 месяцев назад +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  11 месяцев назад

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

  • @SD_simma
    @SD_simma 11 месяцев назад

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

    • @CGPython
      @CGPython  11 месяцев назад +1

      Have you seen this playlist?
      ruclips.net/video/nmJqIaSZlRs/видео.html
      I have a couple of videos on animation at the start of the playlist

    • @SD_simma
      @SD_simma 11 месяцев назад

      @@CGPython definitely missed that Playlist. Thanks

  • @MetalGearMk3
    @MetalGearMk3 11 месяцев назад

    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  11 месяцев назад +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 11 месяцев назад

      @@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  11 месяцев назад

      Great idea!

  • @bohdanpolovinka178
    @bohdanpolovinka178 11 месяцев назад +1

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

    • @CGPython
      @CGPython  11 месяцев назад

      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
      ruclips.net/video/Z7tVeI1D7CY/видео.html

    • @bohdanpolovinka178
      @bohdanpolovinka178 11 месяцев назад

      thank you@@CGPython

  • @WahranRai
    @WahranRai 4 месяца назад +1

    too fast !
    background music disturbing

  • @mikeeotool2677
    @mikeeotool2677 7 месяцев назад

    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  7 месяцев назад

      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.