Particle Skinner through maxscript not working


#1

Hi guys,
Not an expert maxscripter, so please be kind.

I have a Particle Skinner modifier assigned to an editable mesh (‘theMesh’). When I try to assign a Particle Flow System (‘pfSource’) to the modifier through maxscript like this…
theMesh.modifiers[#Particle_Skinner].Particle_Flow_Systems = #(pfSource)
…it throws this error:
“-- Runtime error: Invalid value for property: $PF_Source:PFSource_001 @ [0.000000,0.000000,0.000000]”

If I use the ‘append’ method, I get the same error.
If I do it manually, it work perfectly fine.
If I follow these steps, it also works ok:

  1. Assign Particle flow system manually.
  2. Remove it manually.
  3. Run the maxscript code.
    Works ok!

So I think it’s a 3ds max bug. I need to do all the work by code, not manually. So please help me.
If it’s a bug, please help me find some workaround for this.
Thanks in advance!


#2

I got it to work with the following code, wich I found on the web…
It uses the UIAccessor functions to simulate user inrteraction. I’m not familiar with UIAccesor.

The thing is the code works ok in 3ds Max 2015, but not in newer versions.

Do you know how can I make it work in all versions?

fn addParticleSkinnerMod theMesh masterSystem partSize:1.0 =
(
select theMesh
max modify mode
modPanel.addModToSelection (Particle_Skinner ()) ui:on
theMod = $.modifiers[1]
theMod.Before_Hide = off
maxHWND = windows.getMAXHWND()
cmdHWND = for d in UIAccessor.GetChildWindows maxHWND where UIAccessor.GetWindowText d == “Command Panel” do exit with d
btnHWND = (windows.getChildHWND cmdHWND “Add”)[1]
UIAccessor.PressButton btnHWND – press the ‘Add’ button
theMod.Particle_Flow_Systems = #(masterSystem)
UIAccessor.PressButton btnHWND – unpress the ‘Add’ button
theMod.falloff = partSize
sliderTime += 1f
theMod.activateSkinning()
clearSelection()
sliderTime -= 1f
)

addParticleSkinnerMod $Box001 $‘PF Source 001’ partSize:3.0