The slowness is coming from using the Tag() command. Try using the object
model to cut out the middle man:
// Jscript
main();
function main()
{
var oItems = ActiveSceneRoot.FindChildren2();
LogMessage( oItems.Count );
for ( var i = oItems.Count - 1; i >= 0; i--) {
var oItem = oItems(i);
var oParameter = oItem.Properties(
"Visibility" ).Parameters( "viewvis" );
oParameter.Tags = siTagNone;
}
return;
}
If the parameters you are attempting to modify have a large degree of
consistency in name and location, you can use some of Softimage's wildcards to
find them faster:
var oParameters = XSIFactory.CreateActiveXObject( "XSI.Collection" );
oParameters.Unique = true;
// Get viewvis and rendvis parameters of the visibility
property on each X3DObject
oParameters.items = "*.visibility.{viewvis,rendvis}";
LogMessage( oParameters.Count );
If there is a large degree of consistency in the parameter fullname, you can
apply values to the parameters en masse very efficiently:
SetValue( "*.visibility.{viewvis,rendvis}", false );
Matt
From: [email protected]
[mailto:[email protected]] On Behalf Of Enoch Ihde
Sent: Wednesday, February 27, 2013 9:55 PM
To: softimage
Subject: Re: fastest way through script to get all parameters in a scene of
certain value?
better stated: certain parameter name, not value, apologies, running behind on
sleep, words are challenging.
On Feb 27, 2013 7:54 PM, "Enoch Ihde"
<[email protected]<mailto:[email protected]>> wrote:
these are the three methods i've tried.
using tags is the fastest, but a little prohibitive, as you have to have
anticipated needing to get a param quickly, so it must be tagged in advance.
also, even with getting by tags, performance imo is pretty poor.
results on my machine from the code below:
# INFO : object count is 3618
# INFO : 0.788785183814
# INFO : tagged param count is 3618
# INFO : 2.12563553863
# INFO : 7.84713397563
is there a better way?
<snip>
import time
import win32com.client
xsi = win32com.client.Dispatch( "XSI.Application" ).Application
xsiPrint = xsi.LogMessage
from win32com.client import constants as c
items = xsi.ActiveSceneRoot.FindChildren2()
##### this bit is really slow
for item in items:
xsi.Tag(item.fullname + '.visibility.viewvis', c.siTag1)
xsiPrint('object count is ' + str(items.count))
#### and only needs to be run once
t = time.clock()
val = xsi.ActiveSceneRoot.TaggedParameters(c.siTag1, False)
for v in val:
someStuff = v.value
xsiPrint(time.clock() - t)
xsiPrint('tagged param count is ' + str(val.count))
t = time.clock()
for obj in items:
vis = obj.GetPropertyFromName2("Visibility")
v = vis.viewvis.value
xsiPrint(time.clock() - t)
t = time.clock()
for obj in items:
vis = obj.Properties('visibility').Parameters('viewvis').value
xsiPrint(time.clock() - t)
</snip>
tia,
enoch