Blender Scripting Guide: Mastering Mesh Editing with Python

Поділитися
Вставка
  • Опубліковано 17 сер 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-...

КОМЕНТАРІ • 56

  • @mind_of_a_darkhorse
    @mind_of_a_darkhorse 11 місяців тому +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  11 місяців тому +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 11 місяців тому

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

  • @teccc42
    @teccc42 11 місяців тому +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  11 місяців тому

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

  • @ShirazHazrat
    @ShirazHazrat 7 місяців тому

    Excellent. Thanks!

  • @ludthx
    @ludthx 11 місяців тому +1

    You're back !! great !!

    • @CGPython
      @CGPython  11 місяців тому

      Yes! Thank you!

  • @JosueMartinez-ww1vj
    @JosueMartinez-ww1vj 9 місяців тому +1

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

    • @CGPython
      @CGPython  9 місяців тому +1

      Glad you liked it! 🥳

  • @rafamichalski6150
    @rafamichalski6150 11 місяців тому +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  11 місяців тому +1

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

  • @KevinMerinoCreations
    @KevinMerinoCreations 8 місяців тому +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  8 місяців тому +1

      Welcome aboard! ❤️🚀

  •  11 місяців тому

    Amazing!

    • @CGPython
      @CGPython  11 місяців тому

      Thank you! Cheers!

  • @stefanguiton
    @stefanguiton 11 місяців тому +1

    Great video!

    • @CGPython
      @CGPython  11 місяців тому

      Thank you! Glad you enjoyed it.

  • @dshot92
    @dshot92 11 місяців тому

    Great Intro Video!

    • @CGPython
      @CGPython  11 місяців тому

      I'm glad you like it

  • @AlHowell
    @AlHowell 11 місяців тому +1

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

    • @CGPython
      @CGPython  11 місяців тому +1

      I'm glad you did! Welcome aboard!

  • @mixchief
    @mixchief 11 місяців тому

    This is so useful, thankk you thank you CG Python

    • @CGPython
      @CGPython  11 місяців тому

      You're very welcome!

  • @Crowdrender
    @Crowdrender 10 місяців тому +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  10 місяців тому +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)
      ua-cam.com/video/TJXtio1YDCw/v-deo.html

    • @Crowdrender
      @Crowdrender 10 місяців тому

      @@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  10 місяців тому +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 9 місяців тому +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.

  • @alextsui8551
    @alextsui8551 11 місяців тому +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  11 місяців тому

      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 11 місяців тому

      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 11 місяців тому

      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  11 місяців тому

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

    • @alextsui8551
      @alextsui8551 11 місяців тому

      You'er my hero!@@CGPython

  • @briantriesart
    @briantriesart 3 місяці тому

    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  3 місяці тому +1

      Thanks for the tip! 💖

  • @WhatsThisStickyStuff
    @WhatsThisStickyStuff 5 місяців тому

    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  4 місяці тому

      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 4 місяці тому

      @@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  4 місяці тому

      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.

  • @RomboutVersluijs
    @RomboutVersluijs 18 днів тому

    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  14 днів тому

      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

  • @danil9843
    @danil9843 11 місяців тому

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

    • @CGPython
      @CGPython  11 місяців тому

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

  • @joantonio6331
    @joantonio6331 4 місяці тому +1

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

  • @AbhinavKumar-po9hk
    @AbhinavKumar-po9hk 9 місяців тому +1

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

    • @CGPython
      @CGPython  9 місяців тому

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

    • @AbhinavKumar-po9hk
      @AbhinavKumar-po9hk 9 місяців тому

      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  8 місяців тому

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

    • @AbhinavKumar-po9hk
      @AbhinavKumar-po9hk 8 місяців тому +1

      @@CGPython creating instance of object collection for faster rendering

    • @guy_roh
      @guy_roh 6 місяців тому

      the music is too loud@@CGPython

  • @okayBro0001
    @okayBro0001 11 місяців тому

    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  11 місяців тому +1

      Thank you for the idea! ❤️

  • @2and3d_com
    @2and3d_com 9 місяців тому

    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  9 місяців тому

      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()
      ```