v1.0
Pastes a copy of something without going through the clipboard.
This is the scripting equivalent of a drag-and-drop operation. You
can use this command to move items that already exist in the scene
(for example, reparenting a scene object) or to paste items that
are sitting in the TransientObjectContainer (for example, instances
of built-in property sets such as the Annotation).
Note: The CopyPaste command is the only way to transfer things from
the TransientObjectContainer to the current scene, because the
TransientObjectContainer is inaccessible from the UI.
Warning: Prior to v7.0, you could also use this command to create a
shader from preset and copy it to the TransientObjectContainer
until you were ready to connect it in the RenderTree. However, this
command no longer supports that functionality: now you must create
a temporary copy of the shader in the scene's material library
("Sources.Materials.DefaultLib.Scene_Material") using the CreateShaderFromPreset command
instead. See the ReplaceShader
reference page for an example.
CopyPaste( [Source], [FileName], Target, [Mode] ); |
Parameter | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Source | String | Object to copy | ||||||||||
FileName | String | File or preset to import in the scene | ||||||||||
Target | String | Target object | ||||||||||
Mode | vbCopyPaste constant or Integer | The (VisualBasic) mode to copy paste.
Default Value: vbDefaultCopyPaste
|
# # Example of creating a temporary custom property (aka custom pset) # which can be written to before actually depositing in the scene # app = Application from win32com.client import constants as c app.NewScene( "", 0 ) # Demonstrate how you can use it to create a built-in custom pset presetFullPath = XSIUtils.BuildPath( app.InstallationPath(c.siFactoryPath), "Data", "DSPresets", "Properties", "Annotation.Preset" ) oAnnotation = app.CreateObjectFromPreset2( presetFullPath, "Notes" ) if ( oAnnotation ) : # Even though it only exists on the clipboard you can still populate it app.InspectObj( oAnnotation, "", "Annotation Test", "siModal", 0 ) # Notice how the owner of this annotation doesn't have to # exist until you are ready to cut-and-paste it oNull = app.ActiveSceneRoot.AddModel("", "Jerry") app.CopyPaste(oAnnotation, "", oNull, 1) # Just to prove that it exists any modifications for oParam in oNull.Properties("Notes").Parameters : app.LogMessage( oParam.Name + ": " + str(oParam.Value) ) else : app.LogMessage( "Couldn't create Annotatation property." ) # Expected results (similar to): # INFO : Title: # INFO : Text: need to refine right bicep # INFO : Keyword: modeling # INFO : Flag 1: False # INFO : Flag 2: True |
/* This example demonstrates how to use the CopyPaste command to reparent scene objects by physically moving objects under their new parents (a la drag-and-drop in the UI). */ // Create a new scene with 4 nulls var app = Application; NewScene(null, false); GetPrim("Null"); GetPrim("Null"); GetPrim("Null"); GetPrim("Null"); // Reparent null2 and null3 under null1 CopyPaste("null3", null, "null1", 1); CopyPaste("null2", null, "null1", 1); // Reparent null under null2 CopyPaste("null", null, "null2", 1); // Print the visual hierarchy ShowMeTheHierarchy(app.ActiveSceneRoot, ""); // Expected results: // INFO : Camera_Root // INFO : ...Camera // INFO : ...Camera_Interest // INFO : light // INFO : null1 // INFO : ...null3 // INFO : ...null2 // INFO : ......null // Convenience function to print out a graphical representation // of the hierarchy in the scene starting at the specified object function ShowMeTheHierarchy(in_parent, in_depth) { var kid = new Enumerator(in_parent.Children); for (; !kid.atEnd(); kid.moveNext()) { app.LogMessage(in_depth + kid.item().FullName); if (kid.item().Children.Count) { ShowMeTheHierarchy(kid.item(), in_depth + "..."); } } } |