Page MenuHome

Add a new Copy As Driver context menu option for properties.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Wed, Jul 31, 5:44 PM.

Details

Summary

It is a very common need to create drivers that set the value of
a property to the value of some other property, but it currently
requires multiple actions: Copy Data Path on the input property,
adding a driver to the output property, selecting the input ID
reference, and pasting the path.

This adds a new Copy As Driver context menu option, which creates
a complete driver in the clipboard that reads the current property,
so all that remains is to paste it to the output property. It is
also possible to paste just the new driver variable into an existing
driver to combine multiple inputs.

Diff Detail

Repository
rB Blender

Event Timeline

I wonder if this should also take over the Ctrl-Shift-C shortcut for Copy Data Path? I'm not sure how often Copy Data Path would be needed after this is added. Or maybe this should be merged with Copy Data Path to do everything in one operation?..

Or maybe this should be merged with Copy Data Path

How do you mean?

Merge the internal logic or merge the operators?

There are times you want to copy a data path and not create a driver.

"Copy Data Path" indeed is both for drivers and Python scripting. If there is now a better alternative to create drivers, "Copy Data Path" could be renamed to "Copy Python Path"?

source/blender/editors/interface/interface_ops.c
238–243

Simpler: return (but && (but->optype != NULL));

There are times you want to copy a data path and not create a driver.

This only "creates" a driver in the clipboard. The reason I'm suggesting merging this with Copy Data Path to avoid more and more options, is that they can be considered a common action: copy a reference to the property to the clipboard. I.e. this can be an extension to Copy Data Path that stores the reference in "multiple formats" to be used in different types of paste operations, rather than just a string.

source/blender/editors/interface/interface_ops.c
238–243

This code is old, it was just moved to the correct \name section.

It wasn't immediately obvious to me what "Copy as Driver" does from the name. It's also quite close to "Copy Driver" which does something different.

Not sure this is ideal either, but a suggestion would be to name this "New Driver From". Then when you click it, it prints an info message in the status bar telling you to use Paste Driver on another property.

Functionality seems fine otherwise.

source/blender/editors/interface/interface_ops.c
216–217

"reading" is a bit of a programming term in this context, I think we use "input" more in descriptions for drivers.

I think we can be more verbose like this:

Create a new driver with this property as input, and copy it to the clipboard. Use Paste Driver to add it on the target property, or Paste Driver Variables to extend an existing driver

This only "creates" a driver in the clipboard. The reason I'm suggesting merging this with Copy Data Path to avoid more and more options, is that they can be considered a common action: copy a reference to the property to the clipboard. I.e. this can be an extension to Copy Data Path that stores the reference in "multiple formats" to be used in different types of paste operations, rather than just a string.

I think no matter what we name this, it's not obvious to users that copying a path for Python scripting and creating a new driver are somehow related. Two separate menu entries seem useful for that reason, even if they are technically somewhat redundant.

It wasn't immediately obvious to me what "Copy as Driver" does from the name. It's also quite close to "Copy Driver" which does something different.
Not sure this is ideal either, but a suggestion would be to name this "New Driver From". Then when you click it, it prints an info message in the status bar telling you to use Paste Driver on another property.

Maybe "Copy As New Driver" or "Copy Link As Driver"? "Copy" in the name automatically suggests using "Paste" later. Also, what about the keyboard shortcut - I suspect that shortcut was intended primarily to make driver creation easier, and that usage would shift to this operation.

Maybe "Copy as Driver Input"?

Brecht Van Lommel (brecht) requested changes to this revision.Fri, Aug 2, 12:39 PM

Marking as request changes for a better name and tooltip. "Copy As New Driver" is fine with me.

This revision now requires changes to proceed.Fri, Aug 2, 12:39 PM

Changed the menu item name and tooltip, and added basic property name
sanitization (custom properties created via UI can have weird names).

This revision is now accepted and ready to land.Sun, Aug 4, 12:47 PM