6
$\begingroup$

I've found some code that could add a modifier but none can set parameters like Octree.

enter image description here

$\endgroup$
1
  • $\begingroup$ What modifier is this? $\endgroup$
    – Mutant Bob
    Commented Jan 17, 2017 at 18:00

2 Answers 2

13
$\begingroup$

You can add a new modifier to an object with ObjectModifiers.new(). If you store the result of calling ObjectModifiers.new() in a variable (in the example below I call it modifier) you then have access to all the properties of the new modifier:

import bpy

object = bpy.data.objects['Cube']

modifier = object.modifiers.new(name="Remesh", type='REMESH')
modifier.octree_depth = 5

You can see the type of modifier by hovering the mouse over the modifier in the Add modifier menu and you can see the name of the properties by hovering over the properties on the modifier.

$\endgroup$
2
  • $\begingroup$ how do you figure the parameters of each modifiers ? $\endgroup$
    – Phil
    Commented May 12, 2022 at 13:08
  • $\begingroup$ @Phil If you have Python tooltips enabled you can just hover over the values in the interface. $\endgroup$ Commented May 12, 2022 at 21:42
0
$\begingroup$

If you mouse over the field you should get a pop-up that show you a python expression for what the field refers to. Since my knowledge of modifiers is far from encyclopedic I can not reproduce your situation in my blender.

Nevertheless, mouse-over is a standard technique for figuring out the python path to a field (although there are some data blocks whose path is complicated enough that you just end up with a ... in the middle)

$\endgroup$
1
  • $\begingroup$ well there is no hint on these fields, hence my post, but I used autocomplete in python console $\endgroup$
    – Phil
    Commented May 13, 2022 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .