Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
Running scripts are slow - newbie

Running scripts are slow - newbie

2005-05-23       - By Jeff McFall

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Thanks!

Definitely sounds like I should try to get a handle on the OM approach.

Jeff


-- --Original Message-- --
From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of
Bernard Lebel
Sent: Monday, May 23, 2005 3:55 PM
To: XSI@(protected)
Subject: Re: Running scripts are slow - newbie

First of all, I you have 1500 objects, you may not want to print their name.
Each time you log a message it ads to the execution time. On a small bunch of
object it doesn't matter that much, but on longer lists it may affect execution
time significantly. If you really want a log message to show progress you may
print such message only once every 10 or 100 objects. Only when the script is
giving you troubles you will force it to print every object.

Now Kim is 100% right, using the object model instead of the command model will
make your scripts enormously faster. In fact, do not pretend you know scripting
until you use the object model (or at least know how to use it!) ;-)

So lets's look at the various of your script... (see [Bernard] below)


Jeff McFall wrote:

>CreateImageClip " .... \VIDEO_ELEMENTS\Mosaic_test_mdb\Pictures\relief.pic"
>
>SelectObj "Clips.relief_pic"
>
>set oImageClip = Selection(0)
>set oImage = oImageClip.GetImage
>
>
>for i = 1 to 1567
>
>
>SelectObj("cube" & i)
>
>'   show where we are
>logmessage i
>  
>
[Bernard] Remove this logmessage, as explained above.

>xPos = Selection(0).posX.Value
>yPos = Selection(0).posZ.Value
>
>
>     xImagepos = CInt(720 - (xPos*100))
>     yImagepos = CInt(540 - (yPos*100))
>    
>
>       set oPixelColor = oImage.GetPixel (xImagepos , yImagepos)  
>      
>       ApplyShader "Phong"
>      
>    
>       SetKey obj & ".Material.Phong.Diffuse.red", 91 , oPixelColor.Red
>       SetKey obj & ".Material.Phong.Diffuse.green", 91 , oPixelColor.Green
>       SetKey obj & ".Material.Phong.Diffuse.blue",  91 , oPixelColor.Blue
>      
>       SetKey obj & ".Material.Phong.Ambient.red",  91 , oPixelColor.Blue
>       SetKey obj & ".Material.Phong.Ambient.green", 91 , oPixelColor.Blue
>       SetKey obj & ".Material.Phong.Ambient.blue", 91 , oPixelColor.Blue
>  
>
[Bernard] There is a way to replace the set key commands. First, apply
an fcurve to the parameters you wish to keyframe. The AddFCurve() method
will return a FCurve object. Now use that object to add keyframes, with
the AddKey() method.
The AddKey() entry in the docs have a good example of how to do these
two things.

>      
>            
>       height = ((oPixelColor.Red + oPixelColor.blue + oPixelColor.green) * 1.5)
>       size = (oPixelColor.Red + oPixelColor.blue + oPixelColor.green)
>      
>    
>       SetKey  obj & ".kine.local.posy", 91, height
>        
>      
>       SetKey  obj & ".kine.local.sclx", 91 , size
>       SetKey  obj & ".kine.local.scly", 91 , size
>       SetKey  obj & ".kine.local.sclz", 91 , size
>
>      
>next
>  
>
[Bernard] The same applies. Instead of setting keys onto the
transformation of the object, you should add fcurves and use addkey().


Cheers
Bernard

---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi