Dial & Scale ported to 2.80-2.81

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!

Hi, I found this updated version by Sambler: https://raw.githubusercontent.com/sambler/blender/master/DialScale.py

You can see what he changed from here if you’re iterested in that:

It’s a bit outdated, so you need to change the axis argument in that too. Then it should work.

Thanks you very much for the link , with that info I did some minor changes and it works fine now in 2.80 and 2.81. :grin:

Thanks again!!

A question, where can I upload the new version to share with everyone?

best option would be a pull request on the GitHub page for that add-on.

Thanks, I have uploaded the update as .zip here Update DialScale 2.80-2.81