'Duplicates randomly objects from a picked group and Pose Constraining to each point of a picked Cloud 'Pick the Cloud, and pick the group ; notice that this script work only if the Cloud is under the SceneRoot model 'This script is for crowd simulation, if particles appears or disappears it doesn't work. 'Writting by Nicolas Delbecq on Autrechose's request '------------------------------------ PICKSESSION ------------------------------------ deselectall PickObject "Pick Cloud", "Pick Cloud", oCld, button SelectObj oCld deselectall PickObject "Pick InstanceGroup", "Pick InstanceGroup", oModz, button SelectMembers oModz set oModels = getvalue("selectionlist") deselectall '------------------------------------ INITIALISE ------------------------------------ GInstance = CreateGroup ("G_Instances") deselectall c=0 nb = 0 oIn = GetValue ("PlayControl.GlobalIn") oOut = GetValue ("PlayControl.GlobalOut") SelectObj oCld ActivateVertexSelTool SelectAllUsingFilter "Vertex", siCheckComponentVisibility for each selected in selection if ( selected.Type = "pntSubComponent" ) then for each thing in selected.SubElements nb = nb+1 next end if next logmessage nb&" Instances vont etre generees" dim progressbar set progressbar = XSIUIToolkit.progressbar progressbar.maximum = nb progressbar.CancelEnabled = true progressbar.visible = true '------------------------------------ LET'S GO ------------------------------------ for each selected in selection if ( selected.Type = "pntSubComponent" ) then for each oPnt in selected.SubElements c=c+1 progressbar.caption = "Duplicating Objects #"&c&" on "&nb randomize r = Int((oModels.count - 0 + 1) * Rnd + 0) oPoz = Duplicate (oModels(r), , 2, 1, 1, 0, 0, 1, 0, 1, , , , , , , , , , , 0) progressbar.caption = "Constraining Objects #"&c&" on "&nb ApplyCns "ObjectToCluster", oPoz, selected.Subcomponent.Parent3DObject.Name&".pnt["&oPnt&"]" SIAddToGroup GInstance, oPoz SetValue oPoz&".name", "Duplicated"&c progressbar.increment 1 next end if next progressbar.caption = "Finaling" nDup = GetPrim ("Null") ParentObj nDup, "Duplicated*" SetValue nDup&".name", "Duplicated_objects" logmessage "DONE" '-----------------------------------------------------------------------------------------------