How to add lines to PresetEffects.xml from script
hi, want add lines in preseteffects.xml text file or javascript add lines how can that???:
<group name="$$$/ae/preset/animalhead14/mouth=mouth">
<slider name="$$$/ae/preset/animalhead14/mouthoffsetx=mouth offset x" default="0" valid_min="-30000" valid_max="30000" slider_min="-500" slider_max="500" precision="1" display_percent="true"/>
<slider name="$$$/ae/preset/animalhead14/mouthoffsety=mouth offset y" default="0" valid_min="-30000" valid_max="30000" slider_min="-500" slider_max="500" precision="1" display_percent="true"/>
<slider name="$$$/ae/preset/animalhead14/mouthscalewidth=mouth scale width" default="100" valid_min="-30000" valid_max="30000" slider_min="-500" slider_max="500" precision="1" display_percent="true"/>
<slider name="$$$/ae/preset/animalhead14/mouthscaleheight=mouth scale height" default="100" valid_min="-30000" valid_max="30000" slider_min="-500" slider_max="500" precision="1" display_percent="true"/>
</group>
</effect>
onclick.btn function {
//add text file lines in preseteffects.xml
i did once, this:
var scripteffect = {}; scripteffect.xml = <effect matchname="my suppper effector" name="$$$/ae/preset/supppereffector=suppper effector"> <group name="$$$/ae/preset/colors=colors"> <color name="$$$/ae/preset/pointercolor=pointer color" default_red="20" default_green="192" default_blue="50"/> <slider name="$$$/ae/preset/scenedepth=stereo scene depth" display_percent="true" default="3" valid_min="0.0" valid_max="100" slider_min="0.0" slider_max="100"/> </group> <group name="$$$/ae/preset/convergenceoptions=convergence options"> <checkbox name="$$$/ae/preset/convergecameras=converge cameras"/> <popup name="$$$/ae/preset/convergeto=converge to" popup_string="$$$/ae/preset/convergefrom/popup=camera position|camera point of interest|zoom distance" default="2"/> <slider name="$$$/ae/preset/convergencezoffset=convergence z offset" default="0.0" valid_min="-50000.00" valid_max="50000" slider_min="-1000" slider_max="1000"/> </group> </effect>; scripteffect.matchname = scripteffect.xml.@matchname.tostring(); function installscripteffect(){ var ret; var file = new file(folder.apppackage.absoluteuri + "/preseteffects.xml"); var str, idx, header, xml; var xmlsettings = xml.settings(); xml.setsettings(xml.defaultsettings()); try{ if (!file.exists) throw "err_file_not_found"; file.open("r"); str = file.read(); file.close(); idx = str.indexof("<effects>"); if (idx<0) throw "???"; header = str.substring(0, idx-1); xml = new xml(str.substring(idx, str.length)); if (!xml.contains(scripteffect.xml)){ xml.appendchild(scripteffect.xml); if (!file.copy(new file(file.absoluteuri+".bak"))) throw "err_cannot_write"; file.open("w"); if (!file.write(header + xml.toxmlstring())) {file.close(); throw "err_write_failed";}; file.close(); alert("preset installed succesfully. please restart after effects"); } else{ alert("preset installed. need restart after effects make effective."); }; ret = true; } catch(e){ file.close(); alert(e); ret = false; }; xml.setsettings(xmlsettings); return ret; };
then, when want add effect, check mylayer.effect.canaddproperty(scripteffect.matchname).
if true, nothing do, else use installscripteffect function. normally, works (haven't tried in a long time).
xavier
More discussions in After Effects Scripting
adobe
Comments
Post a Comment