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
B.Y.O.B
(Node Preview and LuxCore Addon Developer)
2
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:
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
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 > oldCount):
# current += number
current+=5
curve.thea_curveAngle = str(current) +CURVE_MS_count.degree_sign
CURVE_MS_count.start +=1
if int(count < 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???
B.Y.O.B
(Node Preview and LuxCore Addon Developer)
4
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).
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
B.Y.O.B
(Node Preview and LuxCore Addon Developer)
8
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”)
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?