PDA

View Full Version : Simcloth3 Presets


frogspasm
02-10-2005, 07:15 AM
This is just an update to Bobo's old script for saving and loading presets in SimCloth.
No new functionality, I just made it work with SimCloth3.
I probably should have ripped out the stuff pertaining to global settings, since they seem to be shared across all the SimCloth modifiers in the scene. Also it could use a button/function for deleting presets.
I may get to that eventually if no one else beats me to it, wink, nudge.

Just save and run the script below and you will find it under:

Customize User Interface/toolbars/ChaosGroup/SimCloth3Presets

test

~Mike D.
-----------------------------------------------------------------------------

macroScript SimCloth3PRESETS category:"ChaosGroup"
(
------------------------------------------
--SimCloth PRESETS
--Version 0.1
--Started: 4/3/2000
--Edited: 4/5/2000
--by Borislav Petrov
--http://gfxcentral.com/bobo/
------------------------------------------
--updated to work with SimCloth3
--2/08/05
--by Mike Dudley

------------------------------------------


global simcloth_presets

fn collect_presets =
(
names_array = #()
preset_files = getFiles (scriptspath+"\\SimCloth\\*.scm")
for i = 1 to preset_files.count do
(
names_array[i] = getfilenamefile preset_files[i]
)
names_array
)

fn save_simcloth_presets work_object file_name =
(
try
(
modobj = work_object.SimCloth3
test_for_files = getFiles (scriptspath+"\\SimCloth\\"+file_name+".scm")
print test_for_files.count
if test_for_files.count == 1 then
(
txt = "Presets File "+file_name+".scm already exists.\nOverwrite?"
q = querybox txt title:"SimCloth3 Presets"
)
else
(
q = true
)
if q then
(
out_file = createfile (scriptspath+"\\SimCloth\\"+file_name+".scm")
format "%\n" "[SimCloth3 Presets Version 1.0]" to:out_file
format "%\n" modobj.type to:out_file
format "%\n" modobj.smoothResult to:out_file
format "%\n" modobj.smoothIterations to:out_file
format "%\n" modobj.particleMass to:out_file
format "%\n" modobj.stretchType to:out_file
format "%\n" modobj.springsStiffness to:out_file
format "%\n" modobj.springsDamping to:out_file
format "%\n" modobj.stretch_stiffness to:out_file
format "%\n" modobj.shear_stiffness to:out_file
format "%\n" modobj.stretchShear_damping to:out_file
format "%\n" modobj.bendEnabled to:out_file
format "%\n" modobj.bendType to:out_file
format "%\n" modobj.excludeSelectedEdges to:out_file
format "%\n" modobj.bendSpringsStiffness to:out_file
format "%\n" modobj.bendSpringsdamping to:out_file
format "%\n" modobj.bendAngleStiffness to:out_file
format "%\n" modobj.bendAngledamping to:out_file
format "%\n" modobj.spacewarps to:out_file
format "%\n" modobj.airDrag to:out_file
format "%\n" modobj.selfCollide to:out_file
format "%\n" modobj.friction to:out_file

--GLOBAL settings.
--These should'nt actually be here anymore
--since global settings are shared across
--all SimCloth3 modifiers in a scene.

format "%\n" modobj.useActiveTimeSegment to:out_file
format "%\n" modobj.startFrame to:out_file
format "%\n" modobj.endFrame to:out_file
format "%\n" modobj.substeps to:out_file
format "%\n" modobj.adaptiveSubdivs to:out_file
format "%\n" modobj.gravity to:out_file
format "%\n" modobj.collisionTolerance to:out_file
format "%\n" modobj.checkForIntersection to:out_file
format "%\n" modobj.solverPrecision to:out_file
format "%\n" modobj.useSSEinstructions to:out_file

close out_file
)--end if q
)
catch()
)--end fn



fn load_simcloth_presets work_object file_name load_mode=
(
--try (
in_file = openfile (scriptspath+"\\SimCloth\\"+file_name+".scm")
modobj = work_object.SimCloth3
version_line = readline in_file
if findstring version_line "SimCloth3" != undefined then
(
if load_mode != 2 then
(
modobj.type = execute (readline in_file)
modobj.smoothResult = execute (readline in_file)
modobj.smoothIterations = execute (readline in_file)
modobj.particleMass = execute (readline in_file)
modobj.stretchType = execute (readline in_file)
modobj.springsStiffness = execute (readline in_file)
modobj.springsDamping = execute (readline in_file)
modobj.stretch_stiffness = execute (readline in_file)
modobj.shear_stiffness = execute (readline in_file)
modobj.stretchShear_damping = execute (readline in_file)
modobj.bendEnabled = execute (readline in_file)
modobj.bendType = execute (readline in_file)
modobj.excludeSelectedEdges = execute (readline in_file)
modobj.bendSpringsStiffness = execute (readline in_file)
modobj.bendSpringsdamping = execute (readline in_file)
modobj.bendAngleStiffness = execute (readline in_file)
modobj.bendAngledamping = execute (readline in_file)
modobj.spacewarps = execute (readline in_file)
modobj.airDrag = execute (readline in_file)
modobj.selfCollide = execute (readline in_file)
modobj.friction = execute (readline in_file)
)
else
(
for c = 1 to 21 do readline in_file
)

--GLOBAL settings
if load_mode < 3 or load_mode == 5 then
(
modobj.useActiveTimeSegment = execute (readline in_file)
modobj.startFrame = execute (readline in_file)
modobj.endFrame = execute (readline in_file)
modobj.substeps = execute (readline in_file)
modobj.adaptiveSubdivs = execute (readline in_file)
modobj.gravity = execute (readline in_file)
modobj.collisionTolerance = execute (readline in_file)
modobj.checkForIntersection = execute (readline in_file)
modobj.solverPrecision = execute (readline in_file)
modobj.useSSEinstructions = execute (readline in_file)
)

select work_object
close out_file

)--end if version

--)catch()
)--end fn

rollout simclothpresets_roll "SimCloth3 Presets"
(
group "Save/Rename Preset"
(
edittext save_file_name text:"Preset1"
button save_preset "SAVE PRESET TO DISK" width:150
button rename_preset "Rename Preset" width:150
)
group "Messages:"
(
edittext messages_line text:"Ready."
)

group "Load Presets"
(
listbox presets_list items:#() height:7
button load_preset "LOAD PRESET" width:150 height:30
dropdownlist assign_mode items:#("All Settings->All Cloths","Global Settings->All Cloths","Local Settings->All Cloths","Local Settings->Selected","All Settings->Selected") default:2
)

on rename_preset pressed do
(
test = renameFile (scriptspath+"\\SimCloth\\"+presets_list.selected+".scm") (scriptspath+"\\SimCloth\\"+save_file_name.text+".scm")
if test then
(
presets_list.items = collect_presets ()
messages_line.text = "Preset Renamed."
)
else
(
messages_line.text = "Renaming FAILED!"
)

)

on save_preset pressed do
(
if selection.count == 1 and save_file_name.text != "" then
(
try
(
modobj = $.SimCloth3
save_simcloth_presets $ save_file_name.text
presets_list.items = collect_presets ()
presets_list.selection = presets_list.items.count
save_file_name.text = ("Preset"+(presets_list.items.count + 1) as string)
)
catch
(
messages_line.text = "SimCloth3 not found!"
)
)
else
(
messages_line.text = "Select exactly ONE object!"
)
)--end on


on load_preset pressed do
(
if assign_mode.selection < 4 then obj_array = geometry as array else obj_array = selection as array
if assign_mode.selection == 2 and obj_array.count > 1 then obj_array = #(obj_array[1])
for i in obj_array do
(
try
(
load_simcloth_presets i presets_list.selected assign_mode.selection
)
catch()
)--end i loop
)--end on

)--end rollout


try(closerolloutfloater simcloth_presets)catch()
simcloth_presets = newrolloutfloater "SimCloth Presets" 200 400 100 100
addrollout simclothpresets_roll simcloth_presets
makeDir (scriptspath+"\\SimCloth")
simclothpresets_roll.presets_list.items = collect_presets ()
simclothpresets_roll.save_file_name.text = ("Preset"+(simclothpresets_roll.presets_list.items.count + 1) as string)
)

CGTalk Moderation
02-10-2006, 08:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.