macroscript gp_shareFFXdata category:"gp_tools" tooltip:"shareFFXdata" ( -- shareFFXdata 1.1 by Pavles Goran created in april 2008 -- This utility is useful when you have big areas that will have a lot of Simulations. -- f.e. a plane bombarding a field or town. -- I do then create for each explosion one FumeFx. And as the conditions for most of these new FFX are the same, -- I don't want to load the settings for each one by hand. -- When creating many FumeFx,I don't use shift+drag to copy them. This is why I wrote this -- utility. I had trouble in simulating when the FXX were copied. -- -- INSTRUCTION: -- ----------- -- Create one fumeFX where you sett your settings. -- When all is good, create as many FFXgrids as you need. -- Then run this script, select the original FFX as reference. -- Add all the other FFX's to the List at which you want to apply the settings of the first one. -- In the settings List select what Settings you want to copy. -- "Spacing will copy the "GridSpacing" -- "Dimensions" will copy the Grid settings but NOT the SPACING! -- -- "Lights" will pick the lights form the reference File into all the other FFX. The ILLUMINATION settings are in the LIST on the left! -- -- "Sources","spaceWarps" and "Objects": -- If checked, the script will assign all the objects,space warps and sources IN THE LIST below. You have to pick these nodes by hand first. -- But oly one more time ;o) -- Unfortunately I didn't find a way to read out which are picked in the reference FumeFX. One more thing I want to meniton is, -- if you select objects, they won't match the "solid", "shell" or "freeflow" setting. This has to be done by hand at the moment. -- -- PATH: be careful with this!!It is buggy! When you assign a path, it will do this for all the added FFX in the list on top. -- NOT for the referenceFFX! -- If you assing a path, and press "force Path" it will assign the path you see in the line. BUT: as soon as you do this, -- you won't be able to change it from the FumeFX UI anymore. It will show an error message. -- That's why there is a "forcePath" button. You don't have to do this ;o) -- The path is set together from the global path you assign to it + a folder for each FFX + *.fxd (f.e. C:/fumeTemp/FumeFX01/FumeFX01_.fxd) -- -- "simAll" will sim all selected FFX including the reference FFX at first place -- "start Simulation" will run each simulation one after the other -- -- for any questions or suggestions or bugs feel free to contact me at goran.pavles@squirlart.com -- You can modify this script as much as you want. I would apperciate it if you would send me your changements :o) -- -- My Ideas for the future would be to be able to adjust the time settings directly for each FumeFX in one UI. Maybe with some timesliders. -- Having random offset values per setting in the copy panel -- And to remove all the bugs that are allready there ;o) ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------- --STRINGS------------------------------------ --------------------------------------------- myString = "myString" --ARRAYS------------------------------------- --------------------------------------------- ffxArr = #() simArr=#() copyArr=#("#grid_play","#sim_main","#sim_smoke","#sim_fuel","#sim_temp","#sim_fm","#render_main","#shader","#illum") settingsArr=#(#grid_play,#sim_main,#sim_smoke,#sim_fuel,#sim_temp,#sim_fm,#render_main,#shader,#illum) toCopyArr=#() nodesArr=#() --VARIABLES---------------------------------- --------------------------------------------- global selectFFX global copyFFX global simulateFFX global doSelect global doRemove global doCopy global ruSim globalPath = "C:\\fumeTemp" makeDir globalPath --selectFFX.referenceFFX.object = undefined --FUNCTIONS---------------------------------- --------------------------------------------- fn doSelect =( if selectFFX.referenceFFX.object == undefined then( fn ffxFilter obj = classof obj == FumeFx and finditem ffxArr obj.name == 0 ) else( fn ffxFilter obj = classof obj == FumeFx and findItem ffxArr obj.name == 0 and selectFFX.referenceFFX.object.name != obj.name ) selectedFFX = selectByName filter:ffxFilter obj if selectedFFX != undefined do( for i in selectedFFX do( append ffxArr i.name ) ) if ffxArr.count != 0 then( selectFFX.listBoxFFX.items = ffxArr ) )----- ------ fn referenceUI =( if selectFFX.referenceFFX.object != undefined then( myRef = selectFFX.referenceFFX.object select myRef print myRef if myRef.EditUI == true then( myRef.EditUI = false ) else( myRef.EditUI = true ) ) )----- ------ fn openUI = ( myFFXUI = (getNodeByName (selectFFX.listboxFFX.items[selectFFX.listboxFFX.selection])) select myFFXUI if myFFXUI.EditUI == true then( myFFXUI.EditUI = false ) else( myFFXUI.EditUI = true ) )----- ------ fn doRemove = ( if selectFFX.listBoxFFX.selection != 0 then( deleteItem ffxArr selectFFX.listBoxFFX.selection selectFFX.listboxFFX.items = ffxArr ) )----- ------ fn addN = ( fn nodesFilter obj = classof obj == wind or classof obj == Gravity or classof obj == Drag or classof obj == pBomb or classof obj == vortex or superclassof obj == GeometryClass and classof obj != FumeFx or classof obj == Simple_Src or classof obj == Object_Src or classof obj == Particle_Src or classof obj == Gravity_Vector and findItem nodesArr obj.name == 0 selectedNode = selectByName filter:nodesFilter obj if selectedNode != undefined do( for i in selectedNode do( append nodesArr i.name ) ) if nodesArr.count != 0 then( copyFFX.listBoxNodes.items = nodesArr ) )----- ------ fn removeN = ( if copyFFX.listBoxNodes.selection != 0 then( deleteItem nodesArr copyFFX.listBoxNodes.selection copyFFX.listBoxNodes.items = nodesArr ) )----- ------ fn doCopy = ( if selectFFX.referenceFFX.object == undefined then( messagebox "please choose a reference FumeFx first" ) else( myFile = (selectFFX.referenceFFX.object.name + "_asReference") selectFFX.referenceFFX.object.savePresets myFile toCopyArr=#() for i in copyFFX.multyListFFX.selection do append toCopyArr settingsArr[i] -- print toCopyArr for i in selectFFX.listBoxFFX.items do( myFume = (getNodeByName i) if toCopyArr.count != 0 then( myFume.LoadPresets myFile toCopyArr ) if copyFFX.copySpacing.state == true then myFume.gridSpacing = selectFFX.referenceFFX.object.gridSpacing if copyFFX.copyDimensions.state == true then( myFume.width = selectFFX.referenceFFX.object.width myFume.length = selectFFX.referenceFFX.object.length myFume.height = selectFFX.referenceFFX.object.height ) if copyFFX.copyLights.state == true then( for L in selectFFX.referenceFFX.object.Lights do( myFume.addLight L ) ) if copyFFX.copySources.state == true do( myFume.blurSource = selectFFX.referenceFFX.object.blurSource for myNodes in copyFFX.listBoxNodes.items do( myNode = (getNodeByName myNodes) if classof myNode == Simple_src or classof myNode == Object_src or classof myNode == Particle_src or classof myNode == simple_src or classof myNode == Gravity_Vector then( myFume.addSource myNode ) ) ) if copyFFX.copySpaceWarps.state == true do( myFume.blurSource = selectFFX.referenceFFX.object.blurSource for myNodes in copyFFX.listBoxNodes.items do( myNode = (getNodeByName myNodes) if classof myNode == wind or classof myNode == Gravity or classof myNode == Drag or classof myNode == pBomb or classof myNode == vortex then( myFume.addForce myNode ) ) ) if copyFFX.copyObjects.state == true do( myFume.blurSource = selectFFX.referenceFFX.object.blurSource for myNodes in copyFFX.listBoxNodes.items do( myNode = (getNodeByName myNodes) if superClassOf myNode == GeometryClass then( myFume.addForce myNode ) ) ) ) ) ) ------ fn doSetPath=( myGlobalPath = getSaveFileName caption:"FumeFX Output" filename:simulateFFX.OutPutFFX.text if myGlobalPath != undefined then( simulateFFX.OutPutFFX.text = myGlobalPath makeDir simulateFFX.OutPutFFX.text ) ) fn doForcePath =( if selectFFX.listBoxFFX.items.count != 0 do( for i in selectFFX.listBoxFFX.items do( myName = (getNodeByName i).name makeDir (simulateFFX.OutPutFFX.text + "\\" + myName) (getNodeByName i).setPath (simulateFFX.OutPutFFX.text + "\\" + myName + "\\" + myName + ".fxd" ) "fxd" -- print (simulateFFX.OutPutFFX.text + "/" + myName + "/") ) ) )----- ------ fn runSim = ( if simulateFFX.simALL.state == true then ( if (classof selectFFX.referenceFFX.object) == FumeFx then ( if finditem simArr selectFFX.referenceFFX.object == 0 do( insertItem selectFFX.referenceFFX.object simArr 1 ) if selectFFX.listBoxFFX.items.count != 0 then ( for i in selectFFX.listBoxFFX.items do ( if finditem simArr (getNodeByName i) == 0 do append simArr (getNodeByName i) ) ) else messagebox "there's no FumeFX selected to copy to!\nyour reference fume you can also run easyly\n from the FumeFX UI ;o)" ) else messagebox "there's no FumeFX reference object!" ) else ( if findItem simArr selectFFX.referenceFFX.object != 0 do( deleteItem simArr (findItem simArr selectFFX.referenceFFX.object) ) for i in selectFFX.listBoxFFX.items do( if finditem simArr (getNodeByName i) == 0 do append simArr (getNodeByName i) ) ) -- print "arrayItems:" -- for i in simArr do print i for i in simArr do i.runSimulation() )----- --ROLLOUTS------------------------------------ ---------------------------------------------- ------ rollout selectFFX "selectFFX"( fn ffxFilt obj = classof obj == FumeFX and findItem ffxArr obj.name == 0 pickButton referenceFFX "reference FFX" filter:ffxFilt autodisplay:true pos:[15,20] height:50 listbox listboxFFX "Fumes" width:120 pos:[110,20] button selectButton "addFFX" pos:[52,110] tooltip:"doubleclick in list to open UI" button removeButton "removeFFX" pos:[35,135] on referenceFFX picked obj do() on referenceFFX rightclick do referenceUI() on selectButton pressed do doSelect() on removeButton pressed do doRemove() on listBoxFFX doubleClicked itm do openUI() ) ------ rollout copyFFX "copy Settings"( multiListBox multyListFFX "Settings to Copy" items:copyArr selection:#(2,3,4,5,6,7,8,9,10) height:10 width:90 checkbox copySpacing "Spacing" checked:true pos:[120,25] checkbox copyDimensions "Dimensions" checked:false pos:[120,40] groupBox copyObj "Obj and Lights" pos:[110,60] width:120 height:80 checkbox copyLights "Lights" checked:true pos:[120,75] checkbox copySources "Sources" checked:true pos:[120,90] checkbox copySpaceWarps "spaceWarps" checked:true pos:[120,105] checkbox copyObjects "Objects" checked:true pos:[120,120] listbox listBoxNodes "Obj/Src/Force" pos:[12,170] height:5 width:220 button addButton "addNode" pos:[93,163] button removeButton "removeNode" pos:[154,163] button copyButton "doCopy!" pos:[12,260] on copyButton pressed do doCopy() on addButton pressed do addN() on removeButton pressed do removeN() ) ------ rollout simulateFFX "simulateFFX"( edittext outPutFFX "" text:globalPath readOnly:true button saveFFX "saveTo" align:#left button forcePath "forcePath" pos:[70,29] checkBox simAll "simulate all" checked:true button doSim "start Simulation" align:#left on saveFFX pressed do doSetPath() on forcePath pressed do doForcePath() on doSim pressed do runSim() ) shareFFXdata = newRolloutFloater "shareFFXdata 1.1" 250 700 900 100 addRollout selectFFX shareFFXdata addRollout copyFFX shareFFXdata addRollout simulateFFX shareFFXdata )