Hey, all.
I’m writing an operator that casts rays from the center towards certain amounts of points and finds the faces rays hit. I’m facing this annoying error, when I change the property of the operator.
I’ve managed to strip the code down to minimal code to reproduce this, that works on default scene
import bpy
import bmesh
from bpy.props import *
from mathutils import *
class SomeOperator(bpy.types.Operator):
bl_idname = "some_operator"
bl_label = "Some operator"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
prop = IntProperty(name="Prop",
description="Prop",
min=10,
max=50,
default=10)
def execute(self, context):
obj = context.active_object
if bpy.context.mode != 'OBJECT':
raise Exception("Please switch to object mode")
cover = [Vector((0,0,1)), Vector((0,0,-1)), Vector((1,0,0)), Vector((-1,0,0))]
for pt in cover:
dummy1, dummy2, faceInd = obj.ray_cast(Vector((0.0, 0.0, 0.0)), pt)
obj.data.polygons[faceInd].select = True
return {'FINISHED'}
Thanks,
Denis.