[Q] IntProperty with steps of 5

Im looking for a IntProperty which instead of 1 step at a time, steps each time by 5. Ive looked into the documentation and did saw something about step, it doesnt work sadly.

I also tried looking at making “RNA_UI” but i cant get it working

this is what i could find and build for my own use to test. But the ‘[“x”]’ doesnt get found when i add it to a panel in data tab.

Ive added this to the register part:

curve = bpy.context.curve
    curve["x"] = 1.0
#    if "_RNA_UI" not in scene.keys():
    curve["_RNA_UI"] = {}
    curve["_RNA_UI"]["x"] = {"description": "Value: 1.0",
                              "name": "X",
                              "max": 10.0}

This part is added to a panel;
below the draw header i added curve = context.curve

layout.prop(curve, '["x"]')

This error is given in the console

rna_uiItemR: property not found: Curve.["x"]

What can i do to make a slider step by 5 instead of 1 or some lower decimal number

I can confirm that step seems to do nothing with IntProperty.
I think it works with FloatProperty.
Maybe you can solve it by attaching a custom update function to the property, see https://docs.blender.org/api/2.79/bpy.props.html

If your property is named x, you draw it in the UI like this:

layout.prop(curve, <b>"x"</b>)

Thanks BYOB for pointing it out.

I went allong and tried something i could comeup with. Im now using a string and a label, the string to be updated and the label to show the deg. I dont wont users to be able to fill out the deg cause the 5deg is important. The label uses getattr to set the deg counted as label text. Its not very clear but it works.

This how it looks now

https://www.dropbox.com/s/qoc51wkjy7bvn0b/custom-curuve-panel-deg.gif?raw=1

This is my code for the counting, perhaps not really well though out. BUt sort of works. I do believe i have a issue when i reload the file, seems like the numbers arenet stored unless i make it some kind of proprty i guess.

class CURVE_MS_count():
    start = 9
    degree_sign= u'\N{DEGREE SIGN}'
    def updateSteps(self, context, number):


        oldCount = CURVE_MS_count.start * int(number)
        curve = context.curve
        current = int(curve.thea_curveAngle.strip(CURVE_MS_count.deg  ree_sign))
        count = curve.thea_curveSmoothAngle * 5
        print("COunt: %s - OldCount: %s" % (count, oldCount))
        if int(count &gt; oldCount):
    #        current += number
            current+=5
            curve.thea_curveAngle  = str(current) +CURVE_MS_count.degree_sign
            CURVE_MS_count.start +=1
        if int(count &lt; oldCount):
            current-=5
            curve.thea_curveAngle  = str(current) +CURVE_MS_count.degree_sign
            CURVE_MS_count.start -=1
        if int(count==0):
            CURVE_MS_count.start = 0

I also had to put it in a class because the start count needs to start at 8. Using a variable outside the function didnt work, it didnt see the variable somehow???

To attach persistent properties to Blender ID types, do this:

bpy.types.Curve.thea_curveAngle = bpy.props.IntProperty(name="Your Name Here")

People usually put this in the register function (after you register your classes).

Okay and how do i add the value in steps of 5 then? The int sliders does only 1 step or some decimal value (precision).
My setup is weird but it works :slight_smile:

I had hoped that i could get the RNA_UI to work. But i dont even know how it would look hahaha

Here’s an example.


The panel is at the bottom in the curve data when a curve is selected.

Save this code as testaddon.py, then install it as addon via user preferences -> install addon from file.

import bpyfrom bpy.types import Panel
import bl_ui
from bl_ui.properties_data_curve import CurveButtonsPanel


bl_info = {"name": "My Test Addon", "category": "Object"}




#class Settings(bpy.types.PropertyGroup):




class MyPanel(CurveButtonsPanel, Panel):
    bl_label = "My Panel Label"


    @classmethod
    def poll(cls, context):
        return context.curve


    def draw(self, context):
        row = self.layout.row()
        
        real_angle = 5 * context.curve.angle
        row.label(str(real_angle))
        row.prop(context.curve, "angle")




def register():
    print("Hello World")
    bpy.utils.register_class(MyPanel)
    bpy.types.Curve.angle = bpy.props.IntProperty(name="Angle", default=0)
    
def unregister():
    print("Goodbye World")
    bpy.utils.unregister_class(MyPanel)



SO essentially its the same i have, but way simpler. Its the same without my update function, damn! hahaha i wasted i think 2-3 hours on that. BUt always nice to learn faster and better methodic approach!

Thanks men!

PS dont you have a issue cause your accessing Int propery Angle before its drawn? Its above it in the list, normally you would set that below. I see some warnings all the time when i reference something before its defined

The IntProperty exists on all curve objects from the moment it is attached to bpy.types.Curve.
We could access that property in all kinds of methods or classes without ever drawing it.
So in the drawing code I do not create it, I just pass its name to the row.prop() method.

The creation code is bpy.types.Curve.angle = bpy.props.IntProperty(…)

The drawing code is row.prop(context.curve, “angle”)

Hope that makes it clear.

Well i was thinking that cause when i use active and sub and the order is wrong it says the reference is used before the declaration. While than the type also exists earlier as you said or is this different metho?