I have a problem that makes no sense. I have written and operator to create a custom object, using bezier curves. Here is part of the code:
class MESH_OT_primitive_cable_add(bpy.types.Operator):
bl_idname="mesh.primitive_cable_add"
bl_label="Stretch a Cable"
bl_options={'REGISTER','UNDO'}
E0=FloatVectorProperty(name="Start Point",subtype='XYZ',precision=5,step=1,default=[0.0,-1.0,0.0])
E1=FloatVectorProperty(name="End Point",subtype='XYZ',precision=5,step=1,default=[0.0,1.0,0.0])
Sag=FloatProperty(name="Cable Sag",precision=3,step=1,default=1.0)
Solid=BoolProperty(name="Solidify",default=True)
Radius=FloatProperty(name="Cable Radius",precision=4,step=1,default=0.1)
CableRes=IntProperty(name="Sag Res",default=12,min=1)
XsecRes=IntProperty(name="Circum Res",default=4,min=1)
def execute(self,context):
bpy.ops.object.select_all(action='DESELECT')
Cable=HangCable(context,self.E0[0],self.E0[1],self.E0[2],self.E1[0],self.E1[1],self.E1[2],self.Sag,self.CableRes)
context.scene.objects.link(Cable)
Cable.select=True
context.scene.objects.active=Cable
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY',center='MEDIAN') # set origin
if self.Solid==True:
Xsec=CreateBevel(self.Radius,self.XsecRes) #Create Bezier Circle
context.scene.objects.link(Xsec)
bpy.data.objects["Xsec"].hide=True
bpy.context.object.data.bevel_object=bpy.data.objects["Xsec"] # bevel cable curve
bpy.ops.object.convert(target='MESH',keep_original= False) # convert active to mesh
bpy.ops.object.shade_flat()
context.scene.objects.unlink(Xsec) # remove circle
return {'FINISHED'}
HangCable() and CreateBevel() are functions that create custom bezier curves.
Now, the crazy part: If I add the expression: I=self.XsecRes*4 anywhere in the execute() function, the operator no longer works properly. “XsecRes” is used to set “resolution_u” of the bezier circle, in the CreateBevel() function. The value can be changed in the user interface. However, when I add I=self.XsecRes resolution_u can no longer be changed. The integer value of “XsecRes” changes—but, not resolution_u in the circle’s data.
How is this possible? I can find absolutely nothing to cause this!