bp-4520-how to delete a face

bp4520-how to delete a face

====================================


import bpy
import bmesh

print("--------")
#----- MUST BE IN OBJECT MODE - OBJECT SELEED
obj = bpy.context.object
sm = bpy.context.tool_settings.mesh_select_mode
sm = [False,False,True]
#----- MUST BE IN EDIT MODE
bpy.ops.object.mode_set(mode='EDIT', toggle=False)      
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.editmode_toggle()
#----- MUST BE IN OBJECT MODE
for f in obj.data.polygons:
#condition to remove face
    if f.index < 4:
        f.select = True
        print('-------true---------')
sm = [False,False,True] 
bpy.ops.object.mode_set(mode='EDIT', toggle=False)       
bpy.ops.mesh.delete(type='FACE')

#bpy.ops.object.editmode_toggle()

bp-4510-Mesh Manipulation

bp-4510-Mesh Manipulation –great video tutorial

00:00​ – Intro

00:36​ – Main Data Types

01:44​ – Accessing Object Data

02:27​ – Getting Vertices

02:56​ – Getting Edges

05:02​ – Get Vertex From Edge

05:46​ – Vertex Counts For Faces

06:26​ – Getting Faces

06:54​ – Creating Vertices

07:27​ – Creating Edges

09:58​ – Skin Modifier Tip

10:59​ – Creating Faces

11:26​ – Building the Mesh (pydata)

14:23​ – BMesh

14:40​ – Final Thoughts

15:19​ – Sponsor (Sketchfab)

Crash Course Chris Holt
========== 00:00​ – Intro 00:45​ – Setup 03:25​ – Modules 06:21​ – Creating a Cube 07:41​ – Accessing Objects 08:18​ – Moving an Object 09:19​ – Rotating an Object 12:57​ – Adding Modifiers 16:55​ – Smoothing a Mesh 20:18​ – Creating Textures 22:57​ – Creating Materials
31:54​ – Python Templates
operator simple
32:22​ – Creating the Operator 38:26​ – Creating Properties 43:35​ – Sponsorship 44:12​ – Outro

More possible code to modify faces

BPY-API

Accessing data from the currently loaded blend file is done with the odule bpy.data
examples

========== step 1 ========
import bpy
print(list(bpy.data.objects))

bpy.data.objects[0] bpy.data.objects[“Cube”] ====================

bpy.context.object #- this gets the last object selected, not necessarily an actively selected obhect

========get the data block- see python tool tip on button==
bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align=’WORLD’, location=(0, 0, 0), scale=(1, 1, 1))

==========================

==========================

bmesh
newer video
old video


bm-1100-Screencast

bm-1100-Screencast – my video

Not very useful in my opinion, doesn’t compensate for a bad video. If you can’t follow what is being described, having the keys and mouse displayed is not going to make the video any better.

t

Reference


DCP Web Designers – pretty good

bp-20100 -CodeSamples

bp-20100 -CodeSamples

====location rotation dimensions scale======================

p1=====================
p3_dimx=bpy.data.objects[“p3”].dimensions[0]
p3_dimy=bpy.data.objects[“p3”].dimensions[1]
p1_z=0
p1_locx = (p3_dimx / 2)
bpy.data.objects[“p1”].location = (p1_locx,0,0)
print (p1_locx )

========== FOR LOOP ========

x=0
x1=0
for x in range(3):
bpy.ops.mesh.primitive_uv_sphere_add(radius=1, enter_editmode=False, align=’WORLD’, location=(x1,0,0), scale=(5,5,5))
x1= x1 + 10

==============
bpy.data.materials[“Blue”].node_tree.nodes[“Principled BSDF”].inputs[0].default_value = (0, 0, 1, 1)