Topic: Linked cloth simulation settings editing script  (gelezen 5525 keer)


Offline Mark aka Dark

  • *
  • Berichten: 782
    • Bekijk profiel
    • Mijn eigen site
« Gepost op: 23 januari 2015, 15:07:35 pm »
Hier alvast het begin van het script wat ik aan het maken ben om cloth settings van een gelinkte cloth sim aan te passen.
Zorg dat de cloth sim eerst zichtbaar is dmv het pinnen van het cloth object.

Kopieer dit script in de texteditor van blender. Pas de object naam en variabelen aan zodat ze ALLEMAAL staan zoals je ze wilt hebben. Klik dan op run script onder in de taskbar van de texteditor. Et voila! Als de wijzigingen niet direct zichtbaar zijn beweeg dan met je muis over het settings gedeelte.

Vooralsnog kun je alleen de settings van de Cloth en de Cloth Cache aanpassen, maar ik ben bezig het script uit te breiden!

#Script to modify cloth simulation setings from opbjects from Linked File
#Author: Mark van Dijk

import bpy

#######set the object you want to change cloth settings from, place the name between "s
# EXAMPLE: "My_Object"
objectname = "Cylinder"

#######Cloth Settings
QualitySteps = 5            #Quality of the simulation in steps per frame
MaterialMass = 0.3          #Mass of the cloth material
MaterialStructural = 15     #stiffness of structure
MaterialBending = 0.5       #Wrinkle Coefficent
DampingSpring = 5           #Damping of cloth velocity
DampingAir = 1              #Thickness of the air, slowing falling things
DampingVelocity = 1         #Help cloth to reach resting position faster USAGE: must between 0 and 1
Pinning = True              #Enable pinning of cloth vertices       USAGE: True or False
PinVertexGroup = 'Pin'      #Vertex group for pinning Vertices      USAGE: place groupname between ''
PinSpringStiffness = 1      #Pin spring stiffness
PrerollFrames = 0           #Start simulation a number of frames earlier to let the cloth set in

#Cloth Cache Settings
FrameStart = 1          #Frame on which the simulation starts.      EXAMPLE: FrameStart = 1
FrameEnd = 50           #Frame on which the simulation ends.        EXAMPLE: FrameEnd = 50
DiskCache = True        #Save cache files to disk                   USAGE: True or False
UseLibPath = False      #Use this file's path for the disk
                        #cache when library linked into another file USAGE: True or False
Compression = 'NO'      #Compression method to be used              USAGE: 'NO' or 'LIGHT' or 'HEAVY'


################################################
### Don't change anything beneath this block ###
################################################

#setting the object, modifier and Cache
obj = bpy.data.objects [objectname]
Cloth = obj.modifiers["Cloth"]
ClothCache = Cloth.point_cache

#changing Settings
Cloth.settings.quality = QualitySteps
Cloth.settings.mass = MaterialMass
Cloth.settings.structural_stiffness = MaterialStructural
Cloth.settings.bending_stiffness = MaterialBending
Cloth.settings.spring_damping = DampingSpring
Cloth.settings.air_damping = DampingAir
Cloth.settings.vel_damping = DampingVelocity
Cloth.settings.use_pin_cloth = Pinning
Cloth.settings.vertex_group_mass = PinVertexGroup
Cloth.settings.pin_stiffness = PinSpringStiffness
Cloth.settings.pre_roll = PrerollFrames

ClothCache.frame_start = FrameStart
ClothCache.frame_end = FrameEnd
ClothCache.use_disk_cache = DiskCache
ClothCache.use_library_path = UseLibPath
ClothCache.compression = Compression

« Laatst bewerkt op: 23 januari 2015, 15:09:52 pm door Mark aka Dark »
MAD staat voor: Mark Aka Dark
Problemen met inloggen? Mail naar: info@dbc-3d.nl

Offline JvL

  • Member
  • *
  • Berichten: 3,415
    • Bekijk profiel
    • Llyr Studio
« Reactie #1 Gepost op: 23 januari 2015, 15:25:46 pm »
Top Mark, ik ga hem vanavond direct uitproberen!

Offline JvL

  • Member
  • *
  • Berichten: 3,415
    • Bekijk profiel
    • Llyr Studio
« Reactie #2 Gepost op: 23 januari 2015, 17:42:54 pm »
Mark, je bent een topper!  ;)

Ik heb je script net getest (speciaal vroeg van mijn werk naar huis gegaan  ;D) en het werkt geweldig! Nog niet alle instellingen zijn getest maar die ik geprobeerd heb veranderen netjes mee. Echt super!

Offline Mark aka Dark

  • *
  • Berichten: 782
    • Bekijk profiel
    • Mijn eigen site
« Reactie #3 Gepost op: 24 januari 2015, 12:45:21 pm »
Nu kun je alle instellingen aanpassen.
Zorg er wel voor dat ALLE instellingen staan zoals je ze wilt, want het script past alles aan. En het script komt al met instelligen in zich.

#Script to modify cloth simulation setings from opbjects from Linked File
#Author: Mark van Dijk

import bpy

#######set the object you want to change cloth settings from, place the name between "s
# EXAMPLE: "My_Object"
objectname = "Cylinder"

#######Cloth Settings
QualitySteps = 5            #Quality of the simulation in steps per frame
MaterialMass = 0.3          #Mass of the cloth material
MaterialStructural = 15     #stiffness of structure
MaterialBending = 0.5       #Wrinkle Coefficent
DampingSpring = 5           #Damping of cloth velocity
DampingAir = 1              #Thickness of the air, slowing falling things
DampingVelocity = 1         #Help cloth to reach resting position faster USAGE: must between 0 and 1
Pinning = True              #Enable pinning of cloth vertices       USAGE: True or False
PinVertexGroup = 'Pin'      #Vertex group for pinning Vertices      USAGE: place groupname between ', use '' if empty
PinSpringStiffness = 1      #Pin spring stiffness
PrerollFrames = 0           #Start simulation a number of frames earlier to let the cloth set in

#Cloth Cache Settings
FrameStart = 1          #Frame on which the simulation starts.      EXAMPLE: FrameStart = 1
FrameEnd = 50           #Frame on which the simulation ends.        EXAMPLE: FrameEnd = 50
DiskCache = True        #Save cache files to disk                   USAGE: True or False
UseLibPath = False      #Use this file's path for the disk
                        #cache when library linked into another file USAGE: True or False
Compression = 'NO'      #Compression method to be used              USAGE: 'NO' or 'LIGHT' or 'HEAVY'

#Cloth Collision
UseCollision = True         #Enable collisions with other objects
CollQuality = 2             #How many collision iterations should be done
Distance = 0.015
Repel = 0
RepelDistance = 0.001
Friction = 5
SelfCollision = True
SelfCollQuality = 1         #How many self collision iterations should be done
SelfCollDistance = 0.75
VertexGroupNoColl = ''    #Vertex group of vertices which won't collide USAGE: place groupname between ', use '' if empty
CollisionGroup = None       #Limit colliders to this group

#Cloth Stiffness Scaling
UseStiffnessScaling = False
StructuralStiffnessGroup = ''
MaxStructStiffness = 0
BendingStiffnessGroup = ''
MaxBendStiffness = 0

#Cloth Sewing Springs
UseSewingSprings = False
SewingForce = 0
ShrinkingClothGroup = ''
MinShrink = 0
MaxShrink = 0

#Cloth Field Weight
EffectorGroup = None
Gravity = 1
All = 1
Force = 1
Vortex = 1
Magnetic = 1
Wind = 1
CurveGuide = 1
Texture = 1
SmokeFlow = 1
Harmonic = 1
Charge = 1
LennardJones = 1
Turbulence = 1
Drag = 1
Boid = 1


################################################
### Don't change anything beneath this block ###
################################################

#setting the object, modifier and Cache
obj = bpy.data.objects [objectname]
Cloth = obj.modifiers["Cloth"]
ClothCache = Cloth.point_cache

#changing Settings
Cloth.settings.quality = QualitySteps
Cloth.settings.mass = MaterialMass
Cloth.settings.structural_stiffness = MaterialStructural
Cloth.settings.bending_stiffness = MaterialBending
Cloth.settings.spring_damping = DampingSpring
Cloth.settings.air_damping = DampingAir
Cloth.settings.vel_damping = DampingVelocity
Cloth.settings.use_pin_cloth = Pinning
Cloth.settings.vertex_group_mass = PinVertexGroup
Cloth.settings.pin_stiffness = PinSpringStiffness
Cloth.settings.pre_roll = PrerollFrames

ClothCache.frame_start = FrameStart
ClothCache.frame_end = FrameEnd
ClothCache.use_disk_cache = DiskCache
ClothCache.use_library_path = UseLibPath
ClothCache.compression = Compression

Cloth.collision_settings.use_collision = UseCollision
Cloth.collision_settings.collision_quality = CollQuality
Cloth.collision_settings.distance_min = Distance
Cloth.collision_settings.repel_force = Repel
Cloth.collision_settings.distance_repel = RepelDistance
Cloth.collision_settings.friction = Friction
Cloth.collision_settings.use_self_collision = SelfCollision
Cloth.collision_settings.self_collision_quality = SelfCollQuality
Cloth.collision_settings.self_distance_min = SelfCollDistance
Cloth.collision_settings.vertex_group_self_collisions = VertexGroupNoColl
Cloth.collision_settings.group = CollisionGroup

Cloth.settings.use_stiffness_scale = UseStiffnessScaling
Cloth.settings.vertex_group_structural_stiffness = StructuralStiffnessGroup
Cloth.settings.structural_stiffness_max = MaxStructStiffness
Cloth.settings.vertex_group_bending = BendingStiffnessGroup
Cloth.settings.bending_stiffness_max = MaxBendStiffness

Cloth.settings.use_sewing_springs = UseSewingSprings
Cloth.settings.sewing_force_max = SewingForce
Cloth.settings.vertex_group_shrink = ShrinkingClothGroup
Cloth.settings.shrink_min = MinShrink
Cloth.settings.shrink_max = MaxShrink

Cloth.settings.effector_weights.group = EffectorGroup
Cloth.settings.effector_weights.gravity = Gravity
Cloth.settings.effector_weights.all = All
Cloth.settings.effector_weights.force = Force
Cloth.settings.effector_weights.vortex = Vortex
Cloth.settings.effector_weights.magnetic = Magnetic
Cloth.settings.effector_weights.wind = Wind
Cloth.settings.effector_weights.curve_guide = CurveGuide
Cloth.settings.effector_weights.texture = Texture
Cloth.settings.effector_weights.smokeflow = SmokeFlow
Cloth.settings.effector_weights.harmonic = Harmonic
Cloth.settings.effector_weights.charge = Charge
Cloth.settings.effector_weights.lennardjones = LennardJones
Cloth.settings.effector_weights.turbulence = Turbulence
Cloth.settings.effector_weights.drag = Drag
Cloth.settings.effector_weights.boid = Boid
MAD staat voor: Mark Aka Dark
Problemen met inloggen? Mail naar: info@dbc-3d.nl

Offline JvL

  • Member
  • *
  • Berichten: 3,415
    • Bekijk profiel
    • Llyr Studio
« Reactie #4 Gepost op: 24 januari 2015, 13:42:28 pm »
Hier ben ik echt mee geholpen, ben er dan ook erg blij mee.  Kan het niet vaak genoeg zeggen. 8)

Is het ook mogelijk om hiermee de instellingen voor meerder sims tegelijk te regelen of is het beter/makkelijker om het script meerdere keren te runnen?
In mijn geval moet ik dat toch doen want ik heb 2 sims die ik apart van elkaar moet baken omdat ze elkaar anders in de weg zitten.

Ben wel benieuwd of het je lukt om hier een addon van te maken want je hebt natuurlijk wel erg veel instellingen die er in verwerkt moeten worden maar het zou wel heel erg gaaf zijn.

Offline Mark aka Dark

  • *
  • Berichten: 782
    • Bekijk profiel
    • Mijn eigen site
« Reactie #5 Gepost op: 24 januari 2015, 14:20:29 pm »
Ik weet niet of al je sims dezelfde instellingen hebben? Dan zou dat kunnen. Dan moet ik wel het script aanpassen (iets), maar dat boeit niet. Anders kun je beter het script 2 keer in je blend file plakken en verschillende namen geven (welke naam mag je helemaal zelf weten), dan kun je per script het object aanpassen en de instellingen ingeven die je voor dat object wilt.

MAD
MAD staat voor: Mark Aka Dark
Problemen met inloggen? Mail naar: info@dbc-3d.nl

Offline JvL

  • Member
  • *
  • Berichten: 3,415
    • Bekijk profiel
    • Llyr Studio
« Reactie #6 Gepost op: 24 januari 2015, 14:49:04 pm »
Ah duidelijk. Nee de sims hebben verschillende instellingen dus dan plak ik het script gewoon meerdere keren in de blend files. Dat houd het denk ik ook een stuk overzichtelijker in het gebruik.