seems there was some changes to how to deal with properties
here is sample script
import bpy,bmesh
from bpy.props import *
from mathutils import *
from math import *
from mathutils import Matrix, Vector
bpy.types.Scene.vecFloat1 = FloatVectorProperty( # Myfloat is the name of the Float variable = Scene property
name="Direction Vector", # Name printed in button
description="Enter a Vector", # Tip tool
default = (1.0,2.0,3.0),
subtype='DIRECTION',
unit='LENGTH',
min = -100,
max = 100)
print ()
print (' Vector float')
print ()
# Property Class
print ()
print ('Property Class Vector float %%%%%%%%%%')
print ()
print ('vecFloat1 =',bpy.types.Scene.vecFloat1) # Print Class of the property
# Property value
print ()
print ('Property value Vector float %%%%%%%%%%')
print ()
print ('Propertie vecFloat1 =',bpy.context.scene.vecFloat1) # Print data value of the property
# Property assign
print ()
print ('Property assign Vector float %%%%%%%%%% ')
print ()
bpy.context.scene['vecFloat1'] = (2,4,6) # assign a value to the property
# Value
print ()
print ('Property Value Vector float %%%%%%%%%% ')
print ()
val1=bpy.context.scene.vecFloat1 # get a value to the property
print ('vecFloat1 value propr =',val1)
print ()
how do you print
the property class
the property value
assign a value
for instance if i assing a vecfloat to a var
and print it it prints the class not the value!
the float prop seems to work well
only thing is that if i use the SKIP save
i still get some old value as default not certain where it is coming from!
and the vecfloat one is a vector not a single float
i have one working in one simple panel
but in the other script one it is crashing for whatever reason
i’ll do some testing tomorrow may be i’ll see why !
when i print the vector one it looks like the class more then the value!
i check latest API and saw some new prop for mesh
any example on what it is and how to use this?
any good doc on these?
only thing is that if i use the SKIP save
i still get some old value as default not certain where it is coming from!
Did you test with restarting blender? 'cause it caches property values somehow. Register a new prop, set a value, unregister, register with same name -> it should still have the previously set value.
and the vecfloat one is a vector not a single float
Did anyone claim something else? It’s an array of floats, as the name implies.
when i print the vector one it looks like the class more then the value!
Always make sure you access properties the right way, ob[‘prop’] for object properties and ob.prop for global properties.
Those aren’t new properties (it’s nowhere related to bpy.props), those are basically methods to acess custom data layers, so a port of the bmesh module’s custom data layers abilities to the standard API.
import bpy
import bmesh
from bpy import data as D
from bpy import context as C
f = C.object.data.polygon_layers_float.new("my flop")
f.data[0].value = 1
f.data[0].value # 1.0
f.data[1].value # 0.0
bm = bmesh.new()
bm.from_mesh(C.object.data)
l = bm.faces.layers.float['my flop']
bm.faces[0][l] # 1.0
bm.faces[1][l] # 1.0
Looks bad, should not use square brackets
bpy.context.scene[‘MyFloat1’] = 22.6 # assign a value to the property
bpy.context.scene.MyFloat1 = 22.6 # correct
and in panel i get a square with a circle in center
Screeshot please! Sounds like you used some subtype for the property, and those change the representation when added to UI.
bpy.types.Scene.vecintaxis1 =bpy.props.IntVectorProperty(
name=“Direction Vector”, # Name printed in button
description=“Enter a Vector”, # Tip tool
default = (0,1,1),
subtype=‘DIRECTION’,
min = 0,
max = 1)
object prop like ID?
adding a propertie to all object may be!
ob[…] = … is ID property yes, but the same is sort of confusing. It adds a custom property to just that object. Registered properties (bpy.props.*) are added to all objects of the type you register it to (e.g. bpy.types.Scene).
what would these layers be ?
and is this available only when using polygon acess method
Well, custom data. Custom data is e.g.
UV mapping and vertex color (loop custom data layer)
Shape keys, vertex bevel weight and crease (vertex CD layer)
edge crease and bevel weight (edge CD layer)
texture assignments and freestyle faces (face CD layer)
You can create new layers with primitive types int, string and float. The polygon_layers_* thing let’s you access the face CD layer with standard API, loop/vert/edge acces seems to be missing. You can use bmesh module for that however.
and it gives this icon in Panel window
It’s not an icon, it’s an interactive input field. If you don’t want that, don’t use that subtype
did not see any doc on that one
i can see that there is a special menu with RMB not certain !
but don’t see any values from prop on that one
i 'll change it too complicated !
1- type
i wanted to select an axis so i used an intvector instead of a float
and it did not realy work but the float seems to work
is there a way to make it work with int vector or another way may be
to select an axis - like 1,0,0 or 0,1,0 or 0,0,1…
2 - del prop
i see here that you added prop and also delete the prop in the unregister
is this a enw ay of dong thigs
what are advantagea or disavntages
i saw another way last month do use prop group instead
thanks
you should always delete them in the unregister function. The stored values will persist, just make sure you got the addon enabled that registers and uses the properties so they load with .blend
I guess you are talking about a pointerproperty that points to a bpy.types.PropertyGroup subclass? You should use that instead of cluttering the entire namespace of e.g. bpy.types.Scene, so whenever your addons use a lot of registered props