Hi,
I’m new for here and I have ported Dial & Scale add-on to Blender 2.80, I’m not the author (in the link the GitHub page), I changed some code and all the features work fine in 2.80 except the orientation of the ticks in Circular Dial Mode (see the images).
This is the original code for Dial Type options:
while pos < end: if self.dialType == "circular": vec3d = mathutils.Vector((self.offset, 0, 0)) vpos = vec3d * mathutils.Matrix.Rotation( -angle , 3, 'Z') elif self.dialType == "horizontal": x = x + self.offset vpos=(x,0,0) else: y = y + self.offset vpos = (0,y,0) bpy.ops.object.text_add() ob=bpy.context.object ob.data.body = str(num) ob.data.font = bpy.data.fonts[ self.font ] bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') bpy.ops.transform.translate(value=vpos) for t in range(0,self.ticks): bpy.ops.mesh.primitive_plane_add(radius=.04 if t == 0 else .02) if self.dialType == "circular": tick_step = angle_step / self.ticks vec3d = mathutils.Vector((self.offset*self.tickOffset, 0, 0)) tpos = vec3d * mathutils.Matrix.Rotation( -(angle + (t*tick_step)) , 3, 'Z') bpy.ops.transform.resize(value=(6,1,1)) bpy.ops.transform.rotate(value= angle + t*tick_step, axis=(0, 0, 1)) elif self.dialType == "horizontal" and pos < end-1: tick_step = self.offset / self.ticks tpos=(x+t*tick_step,self.tickOffset,0) bpy.ops.transform.resize(value=(1,6,1)) elif pos < end -1: tick_step = self.offset / self.ticks tpos=(self.tickOffset,y+t*tick_step,0) bpy.ops.transform.resize(value=(6,1,1)) bpy.ops.transform.translate(value=tpos) angle = angle - angle_step pos = pos + 1 num = num + self.step return {'FINISHED'}
This is the changed code:
while pos < end: if self.dialType == "circular": vec3d = mathutils.Vector((self.offset, 0, 0)) vpos = vec3d @ mathutils.Matrix.Rotation( -angle , 3, 'Z') elif self.dialType == "horizontal": x = x + self.offset vpos=(x,0,0) else: y = y + self.offset vpos = (0,y,0) bpy.ops.object.text_add() ob=bpy.context.object ob.data.body = str(num) ob.data.font = bpy.data.fonts[ self.font ] bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') bpy.ops.transform.translate(value=vpos) for t in range(0,self.ticks): bpy.ops.mesh.primitive_plane_add(size=.04 if t == 0 else .02) if self.dialType == "circular": tick_step = angle_step / self.ticks vec3d = mathutils.Vector((self.offset*self.tickOffset, 0, 0)) tpos = vec3d @ mathutils.Matrix.Rotation( -(angle + (t*tick_step)) , 3, 'Z') bpy.ops.transform.resize(value=(6,1,1)) bpy.ops.transform.rotate(value= angle + t*tick_step, orient_axis='Z') elif self.dialType == "horizontal" and pos < end-1: tick_step = self.offset / self.ticks tpos=(x+t*tick_step,self.tickOffset,0) bpy.ops.transform.resize(value=(1,6,1)) elif pos < end -1: tick_step = self.offset / self.ticks tpos=(self.tickOffset,y+t*tick_step,0) bpy.ops.transform.resize(value=(6,1,1)) bpy.ops.transform.translate(value=tpos) angle = angle - angle_step pos = pos + 1 num = num + self.step return {'FINISHED'}
I’m not an expert in Python but I think that the problematic part of code is: “axis=(0,0,1)”
Looking in internet I found this solution orient_axis=‘Z’, but it doesn’t work, the addon creates the circular dial but with bad orientation of the ticks.
Is there a solution for this issue?
Thanks in advance!