@Clinton
I noticed that the Copy Attributes script does not really stop the script from running if the Clintons3dPlugin.rsx plugin is not Loaded
Using the code you shared with the Material Converter, does this seem to be correct for the Copy script?
Does it need to have the try & Catch and if so how would you implement that?
Code: Select all
var CONFLG_DIRTY = 1
var CONFLG_OUT = 2
var CONFLG_IN = 4
var CONFLG_INOUT = 6
var CONFLG_RESERVED = 8
var CONFLG_EXPORTED = 16
var CONFLG_HIDDEN = 32
var CONFLG_CACHING = 64
var CONFLG_NONOTIFY = 128
var CONFLG_CONTROLFLOW = 256
var CONFLG_DISABLECACHING = 512
var CONFLG_REGISTERED = 1024
var CONFLG_CUSTOM = 2048
var CONFLG_TOPOLOGY = 4096
var CONFLG_LOCAL = 8192
var CONFLG_LAST = 8193
function Execute(params)
{
var Source = params.ConValue('Source');
var Destination = params.ConValue('Destination');
var Verify = params.ConValue('Verify');
if(!Source) return
if(!Destination) return
if(!pluginInstalled() ) {
System.Alert("Clintons3dView plugin must be Installed and Loaded.");
params.SetTerminationFlag();//stop downstream execution
return;
}
// try {
// utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
// } catch(err) {
//System.Error("Requires the " + "("+" Clintons3dPlugin.rsx )" + " plugin to be Installed and Loaded in the Package Manager")
// return "Requires Clintons3dPlugin.rsx plugin";
// }
var utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
currentnode = Source;
thedata = utilitydata.GetConnectorData(currentnode);
connectors = thedata.split("\n");
for(i=0;i<connectors.length;i++)
{
connector = connectors[i].split("\t");
//connector[0] = script connector name
//connector[1] = connector name
//connector[2] = connector type
//connector[3] = flags
if(connector[3] & CONFLG_IN && !(connector[3] & CONFLG_HIDDEN)) {
//System.Trace(connector[0]);
if(Node.ConExists(Destination, connector[0])) {
System.Trace(connector[0]);
try {
if(Verify) {
if(Question("Copy the " + "( " + connector[0] + " )" + " attribute to the Destination?"))
Node.Value(Destination, connector[0]) = Node.Value(Source, connector[0]);
}
else
Node.Value(Destination, connector[0]) = Node.Value(Source, connector[0]);
} catch(e) {
//System.Trace("Failed to copy " + connector[0]);
//System.Error("Failed to copy " + connector[0]);
}
}
}
}
Node.ConReset(System.ThisOwner(),"Source")
Node.ConReset(System.ThisOwner(),"Destination")
}
function pluginInstalled()
{
// check that plugin is installed and loaded
var xmldoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmldoc.load(System.GetMainDir() + "\\Scripts\\Plugins.xml");
var doc = xmldoc.documentElement;
for(var i=0;i<doc.childNodes.length;i++)
{
var child = doc.childNodes.item(i);
var grandchild = child.childNodes.item(0);
var NAME = grandchild.getAttribute("NAME");
if(NAME == "Clintons3D Package") {
var STATUS = grandchild.getAttribute("STATUS");
if(STATUS == "LOADED") {
return true
}
}
}
//System.Alert("Clintons3dView plugin must be installed and loaded.");
return false;
}
function Question(strText)
{
var nSecondsToWait = -1;
var strTitle = "Question"; // Titlebar text
//values are hexadecimal
var MB_YESNO = 4;
var MB_SYSTEMMODAL = 4096;//1000L force on top
var MB_ICONQUESTION = 32;//20L question mark symbol // 16;= 10L stop-sign symbol
var nType = MB_YESNO+MB_SYSTEMMODAL+MB_ICONQUESTION;
var IDYES = 6;
var IDNO = 7;
var shell = new ActiveXObject("WScript.shell");
var button = shell.Popup (strText, nSecondsToWait, strTitle, nType);
if(button == IDYES) return true;
return false;
}