Blender Scripting Guide: Mastering Mesh Editing with Python

Sdílet
Vložit
  • čas přidán 17. 08. 2023
  • Start exploring the power of the BMesh Python module in Blender with this tutorial designed for 3D artists. Understand the essentials of manipulating and editing geometry seamlessly using a Python script. Whether you're a beginner or looking to enhance your Blender scripting skills, this BMesh introduction will provide valuable insights. Start building the foundation for creating advanced 3D modeling scripts and add-ons today. Perfect for those passionate about taking their 3D artwork to the next level. #Blender3D #BMesh #3DModeling #pythonscripting
    Used "A Baker Kneading the Dough" Video by ROMAN ODINTSOV: www.pexels.com/video/a-baker-...

Komentáře • 56

  • @mind_of_a_darkhorse
    @mind_of_a_darkhorse Před 11 měsíci +4

    A great tutorial! BMesh is a lot to grasp and you explained it succinctly and well! Glad to see you are back after a short break! You were missed!

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

      Glad it was helpful!
      Thank you!
      I definitely want to do some more with BMesh. Just scratching the surface with this. I don't want to overload everyone.

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

      @@CGPython The best way to tackle a large problem is to break it down into small parts! So, I totally agree!

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

    Excellent. Thanks!

  • @teccc42
    @teccc42 Před 11 měsíci +1

    Thank you so much for your videos! I am working my way slowly through all of them. You are an excellent teacher!

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

      You're very welcome!
      I'm really happy you like them! 🥳

  • @KevinMerinoCreations
    @KevinMerinoCreations Před 8 měsíci +1

    Got pointed to your channel through your sponsorship on @CurtisHolt Blender 4.0 video. Look forwarded to following your content as well! 👏👏👏

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

      Welcome aboard! ❤️🚀

  • @ludthx
    @ludthx Před 11 měsíci +1

    You're back !! great !!

  • @rafamichalski6150
    @rafamichalski6150 Před 11 měsíci +2

    I have wondered for a long when you are going to start tutorials about Edit Mode, and now there is one. Wish to know more about all actions, like extrusion, inset... Great work, thank you.

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

      Thank you!
      Yes, I want to cover that as well.
      Stay tuned 📺

  • @JosueMartinez-ww1vj
    @JosueMartinez-ww1vj Před 9 měsíci +1

    A great introduction, Thanks so mesh, I mean much 👍👍

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

      Glad you liked it! 🥳

  •  Před 11 měsíci

    Amazing!

  • @stefanguiton
    @stefanguiton Před 11 měsíci +1

    Great video!

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

      Thank you! Glad you enjoyed it.

  • @dshot92
    @dshot92 Před 11 měsíci

    Great Intro Video!

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

      I'm glad you like it

  • @AlHowell
    @AlHowell Před 11 měsíci +1

    Found you from film booth. I’m glad I did 💪

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

      I'm glad you did! Welcome aboard!

  • @mixchief
    @mixchief Před 11 měsíci

    This is so useful, thankk you thank you CG Python

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

      You're very welcome!

  • @briantriesart
    @briantriesart Před 3 měsíci

    Hi, I love your channel. thanks for sharing your knowledge! Just a comment: I humbly think the zoom-in and zoom-out in the post-video editing are not necessary. You can save some time by skipping this step and the video will be perfectly understandable saving your valuable time for more content :) haha Thank you.

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

      Thanks for the tip! 💖

  • @joantonio6331
    @joantonio6331 Před 4 měsíci +1

    As of blender 4.0, you do not need to add bmesh update

  • @alextsui8551
    @alextsui8551 Před 11 měsíci +1

    Great tutorial! Looking forward to next one about loops. I dont't know how to change loop normal to face normal, in other words modify the split normal same to face normal. Hope you could teach that in the next one. Thanks a lot!

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

      Thanks for the idea!
      Do you have an example script you are using this in?
      So I can understand your use case better

    • @alextsui8551
      @alextsui8551 Před 11 měsíci

      Thanks for your reply! After bevel each edge of a cube, enable the Auto Smooth and apply a Weighted Normal modifier, the split normal will be different to ones before, and it make sense. But for lowpoly or stylized model appearance, I would like to change the split normal back to before just same as the face normal. Thx again!
      @@CGPython

    • @alextsui8551
      @alextsui8551 Před 11 měsíci

      I tried many ways but can not find a proper way to modify loop normal, it seems like using different data structure for split normal. Code below is most of my attempt.
      import bpy
      import bmesh
      obj = bpy.context.edit_object
      mesh = obj.data
      bm = bmesh.from_edit_mesh(mesh)
      for face in bm.faces:
      if face.select:
      normal = face.normal
      for loop in face.loops:
      split_normals[loop.index] = normal

      bm.free()
      bmesh.update_edit_mesh(obj.data)
      @@CGPython

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

      You can actually update the split normals via the mesh data (without bmesh)
      Here is an example
      gist.github.com/CGArtPython/96abf841bd732ee54a6c89643df45cab

    • @alextsui8551
      @alextsui8551 Před 11 měsíci

      You'er my hero!@@CGPython

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

    Nice video! A couple of questions, can you build a performant addon that allows modifying the visible mesh in real time? Would imagine that constantly creating bmesh objects would be slow. So is there a way to either do this efficiently, by updating a bmesh from the object's mesh? Or is it better to somehow visualise the bmesh and edit that, similar to how edit mode works?

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

      Do you have some examples of what you want to do?
      For example, the MESHmachine add-on uses bmesh to edit meshes in real time
      machin3.gumroad.com/l/MESHmachine
      At the end of the day, you would need to go through bmesh to apply edits to meshes in Blender. Even if you have an external library that is written in C++ or Rust that does the heavy lifting.
      Here is an example of how you can speed up geometry processing with Rust from the World Blender Meetup Day 2022 Part 3 (link with timestamp)
      czcams.com/video/TJXtio1YDCw/video.html

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

      @@CGPython Thanks :) we worked on a scultping addon with @JamieDunbar, we're working on the next edition and wanted to look at how we could display what a merged set of objects would look like in real time without actually merging them yet. So, first idea after watching this video was bmesh but the thought of constantly creating multiple bmesh objects for different meshes doesn't sound like it would be fast!

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

      I would still try to see how bad it would look if you just used pure python bmesh before you start optimizing.
      If that doesn't work try looking into Cython? IIRC @JacquesLucke used that in the animation nodes add-on.
      Also not sure how this would look, but maybe draw the merged mesh with some debug lines?

    • @MACHIN3
      @MACHIN3 Před 9 měsíci +1

      @@CGPython Thanks for the shoutout :) To add something to the topic, bmesh generally works to edit meshes in real time, but of course it depends on the operations you do and the complexity of the mesh you are handling. There definitely are situations where it does make sense to previs the to-be-created/changed geometry and only push to the new mesh at the end in a single step, instead of doing it with each modal execution for instance.

  • @danil9843
    @danil9843 Před 11 měsíci

    Hi. Great video. Can you make tutorial how to insert pose asset browser to keyframe? Thank in advance. Subscribed.

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

      Thank you for the idea! 💪
      I'll think about it 🤔

  • @AbhinavKumar-po9hk
    @AbhinavKumar-po9hk Před 9 měsíci +1

    Thank you for the tutorial you provided for beginner. If possible could you please upload videos with some better voice output.

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

      Thank you for your feedback
      Can you share exactly what you don't like about the audio quality?

    • @AbhinavKumar-po9hk
      @AbhinavKumar-po9hk Před 9 měsíci

      In some of your videos, your voice is not audible properly, after putting on headphone and on full volume, then only getting the some part of the audio. @@CGPython Again thanks a lot. your videos helped ma a lot in my project. can you make videos on optimize scene and configurator render

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

      Got it!
      What do you mean by “scene optimization”?

    • @AbhinavKumar-po9hk
      @AbhinavKumar-po9hk Před 8 měsíci +1

      @@CGPython creating instance of object collection for faster rendering

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

      the music is too loud@@CGPython

  • @RomboutVersluijs
    @RomboutVersluijs Před 22 dny

    Was wondering why we use this on bmesh leverl and why not simply run the bevel operator in the active object. What is the difference. Not sure I saw that in the video

    • @CGPython
      @CGPython  Před 17 dny

      Great question!
      Yeah, you are correct that we can also use a bevel op.
      With bmesh you can chain multiple types of edits and you have more control over the mesh editing process.
      Also, the Blender devs outline some issues when if you use operators
      docs.blender.org/api/current/info_gotcha.html#using-operators

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

    Hi! If I already have a GLTF file or a model made can I export python code that will create the exact same model?

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

      You don't need to write Python code to import a glTF file
      You can use the built in add-on
      docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html

    • @WhatsThisStickyStuff
      @WhatsThisStickyStuff Před 4 měsíci

      @@CGPython Right but I want to turn a 3D model into a python script and then hypothetically send that script to someone else and have them make the 3D model using just the script

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

      It would be possible to do this, but I don't know why you would need to do this.
      If the other person has Blender, why not just send them the glTF file?
      Maybe this is just for fun?
      You need to look at the add-on that I mentioned to understand how that data is represented via Python and then create a Blender Python script that adds the verts and faces to create the mesh.
      Probably the most challenging part would be creating the encoded Materials, Textures, and Animations.

  • @okayBro0001
    @okayBro0001 Před 11 měsíci

    Please make the complete series on a beginner to advanced level blender bone and rigging series by scripting
    Thank you so much From India 🇮🇳

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

      Thank you for the idea! ❤️

  • @2and3d_com
    @2and3d_com Před 9 měsíci

    great tutorial... please how do you select a particular vertices and merge them, i have been having a hard time figuring this out

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

      Here is an example of using bmesh.ops.collapse
      ```
      # get a reference to the active object
      mesh_obj = bpy.context.active_object
      # create a new bmesh and initialize it from mesh data in Edit Mode
      bm = bmesh.from_edit_mesh(mesh_obj.data)
      selected_edges = [edge for edge in bm.edges if edge.select]
      selected_edge = selected_edges[0]
      bmesh.ops.collapse(bm, edges=[selected_edge])
      bmesh.update_edit_mesh(mesh_obj.data)
      # clean up/free memory that was allocated for the bmesh
      bm.free()
      ```