I would like to select the dynotopo and place a check into the field, yet I can only find a toggle script. bpy.ops.sculpt.dynamic_topology_toggle() I'm not sure where I am going wrong. All other sculpt options seem to work.

  • $\begingroup$ You want it to only check it, and not uncheck it when the script is run again? $\endgroup$ – Nate_Sycro27 Feb 1 at 4:47
  • $\begingroup$ It needs to be checked when the script runs. $\endgroup$ – Michael Teiniker Feb 1 at 4:54

All objects have the use_dynamic_topology_sculpting property, which allows you to check whether or not dynamic topology is activated. Therefore your script could look like this:

import bpy

active_object = bpy.context.view_layer.objects.active

if active_object.mode == "SCULPT" and not active_object.use_dynamic_topology_sculpting:
| improve this answer | |
  • $\begingroup$ BTW: The "use_...._sculpting" link above goes nowhere?! Anyway were would said code go? in a timer firing every second or is there a handler or event listener for when sculpting mode is switched to? and a View3D window becomes active? $\endgroup$ – Master James Mar 11 at 9:39
  • $\begingroup$ @MasterJames Fixed the link. Like I wrote as a comment to your own question, you likely want to use the msgbus. Unfortunately I currently don't have the time to write an answer. The code above simply enables dynamic topology if it isn't already enabled, which was the topic of this question. $\endgroup$ – Robert Gützkow Mar 11 at 9:47
  • $\begingroup$ Yes thanks very useful it does show the value for this toggle to add the listener for the properties change. Your input is valued and much appreciated. $\endgroup$ – Master James Mar 11 at 10:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.