Difference between revisions of "Slack Coding Channel"

From The Foundry MODO SDK wiki
Jump to: navigation, search
m
m
Line 2: Line 2:
  
  
 +
 +
==Drop script - Feb 13 2019==
  
  
<big>'''Drop scrip'''t</big> - Feb 13 2019
 
----
 
 
Allows a Python script to be executed on the drag and drop. Source will be called when this item is dragged on to others in the 3D viewport, and Destination will be called when others are dragged onto this one.
 
Allows a Python script to be executed on the drag and drop. Source will be called when this item is dragged on to others in the 3D viewport, and Destination will be called when others are dragged onto this one.
 
The Source and Destination item is passed as an argument to the script, and can be received using lx.args().
 
The Source and Destination item is passed as an argument to the script, and can be received using lx.args().

Revision as of 16:50, 13 February 2019

<Parked page for any insights on the slack developer channel>


Drop script - Feb 13 2019

Allows a Python script to be executed on the drag and drop. Source will be called when this item is dragged on to others in the 3D viewport, and Destination will be called when others are dragged onto this one. The Source and Destination item is passed as an argument to the script, and can be received using lx.args(). For example, this script will print out the source and destination of the drag and drop, and then call the parent command to parent the destination to the source. You get the source and destination item, what you do next is up to whatever you're trying to achieve.

#python
 
import lx
 
source = lx.args()[0]
destination = lx.args()[1]
 
print "The Source item is: {}".format(source)
print "The Destination item is: {}".format(destination)
 
lx.eval("item.parent {} {} 0 inPlace:1 duplicate:0".format(source, destination))