ya, geeze alan... what were you thinking!
On Thu, Feb 28, 2013 at 1:43 PM, Alan Fregtman <alan.fregt...@gmail.com>wrote: > Actually, it'll be faster if we change the [] to a () so it's a generator > instead of a full loop. My bad. I need coffee. > > > > coll = XSIFactory.CreateObject('XSI.Collection') > coll.SetAsText('*.visibility.*') > > valueDict = dict(((x.FullName,x.Value) for x in coll))print valueDict > > > > On Thu, Feb 28, 2013 at 1:20 PM, Alan Fregtman <alan.fregt...@gmail.com>wrote: > >> What if you use list comprehensions? >> >> >> >> coll = XSIFactory.CreateObject('XSI.Collection') >> coll.SetAsText('*.visibility.*') >> valueDict = dict([(x.FullName,x.Value) for x in coll])print valueDict >> >> >> >> >> On Thu, Feb 28, 2013 at 12:59 PM, Enoch Ihde <emi...@gmail.com> wrote: >> >>> sorry, i wasn't really clear. i'm aware the tagging bit was slow, i >>> couldn't be bothered to tag it object modelwise. >>> >>> i'm referring only to the value retrieval of the parameter. not the >>> setup time. >>> >>> >>> again: >>> # INFO : 0.788785183814 seconds <--- accessing 3618 parameters's values >>> by tag >>> >>> # INFO : 2.12563553863 seconds <--- accesssing 3618 parameters's values >>> by GetPropertyFromName2(propertyname).Parameters(paramname) >>> >>> # INFO : 7.84713397563 <---- accessing 3618 parameter's values by >>> Property(propertyname).Parameters(paramname) >>> >>> tagging is by far the fastest, but in imo, is unacceptably slow. >>> compare that to a method such as IsSelected(), getting a report on a >>> large number of objects is negligible. >>> >>> >>> >>> On Wed, Feb 27, 2013 at 10:29 PM, Matt Lind <ml...@carbinestudios.com>wrote: >>> >>>> 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:* softimage-boun...@listproc.autodesk.com [mailto: >>>> softimage-boun...@listproc.autodesk.com] *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" <emi...@gmail.com> 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**** >>>> >>>> >>>> >>>> **** >>>> >>> >>> >> >