| Code: |
|
# Search comments for tyre flags if tyre_string in comments[ (each_element - 1) ]: print(comments[ (each_element - 1) ] + comments[ each_element ] + "\n") ascii_num += 1 # Set width of tyre depth = position_m[ (each_element) ] - position_m[ (each_element - 1) ] # Generate inner diameter cylinder for boolean difference bpy.ops.mesh.primitive_cyli:?: nder_add(vertices=32, radius=Rad, depth=(depth + 1.0), end_fill_type='NGON', view_align=False, enter_editmode=False, location=(0, ((position_m[ each_element ] + position_m[each_element - 1])/2.0), 0), rotation=((pi/2),0,0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)) # Assign active object to a variable for later identification cyl1 = bpy.context.active_object cyl1_name = bpy.context.active_object.name # Diagnostic print to console print(cyl1) # Generate outer diameter cylinder for boolean difference bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=(Rad + (Rad * 0.50 )), depth=(depth), end_fill_type='NGON', view_align=False, enter_editmode=False, location=(0, ((position_m[ each_element ] + position_m[ (each_element - 1) ])/2.0), 0), rotation=((pi/2.0),0,0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)) # Assign active object to a variable for later identification cyl2 = bpy.context.active_object # Diagnostic print print(cyl2) # Apply material to outer tyre bpy.context.object.data.materials.append(tyre_mat) # Conduct boolean difference to generate tyre bpy.ops.object.select_all(action='DESELECT') # Set active object to outer cylinder bpy.context.scene.objects.active=cyl2 # Create modifier bpy.ops.object.modifier_add(type='BOOLEAN') # Select modifier object to inner diameter cylinder cyl2.modifiers[0].object = cyl1 # Set operation cyl2.modifiers[0].operation = 'DIFFERENCE' # Conduct boolean bpy.ops.object.modifier_apply(apply_as='DATA', modifier=cyl2.modifiers[0].name) # Remove inner diameter cylinder after boolean bpy.ops.object.select_all(action='DESELECT') # Select inner diameter cylinder as active bpy.context.scene.objects.active=cyl1 # Diagnostic information for console temp=bpy.context.active_object.name print("Active object is: " + temp) # Delete active object bpy.ops.object.delete(use_global=True) else: print ('Tyre ID not found at %i \n' % (each_element)) |
| Code: |
| bpy.ops.object.delete(use_global=True) |
| Code: |
| bpy.context.scene.objects.unlink(cyl1) |
| CoDEmanX wrote: |
| you deselect everything, then you make the inner cylinder active:
there is a difference between selected and active object, operators mostly require a selection so you should select cyl1 rather than making it active object: bpy.ops.object.select_all(action='DESELECT') cyl.select = True # delete |