VertexMap Display (Behavior Equivalent to Double-Click)
-
When you select a Vertex Map tag on an object and double-click it, the colors become visible in the viewport. How can I replicate this double-click behavior through a script?
import c4d def main(): obj = doc.SearchObject("PointObj") vmap_tag = None for tag in obj.GetTags(): if tag.CheckType(c4d.Tvertexmap): vmap_tag = tag break doc.SetActiveTag(vmap_tag, c4d.SELECTION_NEW) c4d.EventAdd() if __name__ == '__main__': main() -
Hey @ymoon,
Thank you for your question. First of all, your code is more complicated than it has to be. You can just call
BaseObject.GetTagto get the first tag of a specific type on an object. Also, your code already does what you are asking for, it selects the tag and therefore causes Cinema 4D to draw the vertex map in the viewport (equivalent to single clicking the tag).To have the Paint Tool enabled (i.e., what happens when you double click a vertex map), you could either activate the tool yourself, or just send
MSG_EDITto the tag, the message which is sent to scene elements when they are double clicked.Cheers,
FerdinandCode
import c4d doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. def main() -> None: """Called by Cinema 4D when the script is being executed. """ if not op: return c4d.gui.MessageDialog("Please select an object.") tag: c4d.BaseTag | None = op.GetTag(c4d.Tvertexmap) if not tag: return c4d.gui.MessageDialog("The selected object has no Vertex Map tag.") doc.SetActiveTag(tag, c4d.SELECTION_NEW) tag.Message(c4d.MSG_EDIT) c4d.EventAdd() if __name__ == '__main__': main() -
@ferdinand
Thank you. It works well. --> tag.Message(c4d.MSG_EDIT)