0
$\begingroup$

I am trying to write a new operator using bpy. It will operate on the currently selected objects and add particle systems, then use a user-selected object as the render object in the particle systems (this user-selected object would be the parameter). This appears to be the wrong way to think about things in Blender, but I could not find the Blender way to think about it.

The tutorials and reference materials explain how to add properties to the operator. I added these and they work fine for value parameters like numbers and strings. When using bpy.props.PointerProperties Blender throws the error ValueError: bpy_struct "MESH_OT_place_foliage" doesn't support datablock properties, and the property doesn't show up in the operator panel.

When looking this up I found other people with the same issue, in particular I found this question where it is suggested that the asker shouldn't be doing things that way, but no suggestion on the way they should be doing it.

Additionally, I found some code examples of bpy.props.PointerProperties, but none targeted objects, which again suggests I am working against the grain. I also tried to think of official operators that I'd used that took secondary object inputs; the only family I thought of was bool tools, and they operate on the active object and the selected objects, rather than separating the operands into separate parameters.

What is the Blender way to think about this problem? I'd greatly appreciate examples as well.

$\endgroup$
3
  • 1
    $\begingroup$ In a round about way, my take on this is you cannot assign a pointer property to an operator. Easily worked around with a string to pass the name, get the object and set it to the pointer property of whatever. In the question linked (well my answer to) it is a pointer property on the scene.,, For the string property use the prop search layout as demode in link blender.stackexchange.com/a/159155/15543 If you want to paramaterize objects with pointers to other objects, assign properties on the object type. $\endgroup$
    – batFINGER
    Sep 8 at 11:55
  • $\begingroup$ IMO The blender operator way here would prob be make "the object" the context object, and add particle systems on selected using "the object" as render object, just like setting a parent. $\endgroup$
    – batFINGER
    Sep 8 at 12:20
  • $\begingroup$ Thank you @batFINGER, that's a useful link. The second point about making the render object the context object makes me think that I could rename my operator to make the context objects and selected objects as intuitive as Set parent, currently it is Place foliage but it could be Place foliage cluster on surfaces or hopefully something even more obvious. $\endgroup$ Sep 8 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.