Getting ParamBlock from Modifier

 
 
 
Posted by:Vincentt
Data created:28 February 2015

Hello again,

 

I'm trying to add a UVW Map modifier on my object and change some of the parameters. But I don't seem to be able to get the IParamBlock(2). I'm pretty sure I need IParamBlock and not IParamBlock2 because in the C++ samples they use: "pblock = (IParamBlock*)rtarg" 

I've tried the following but they all return null. NumParamBlocks even returns 0, this doesn't sound good?

var uvmapMod = (IModifier)m_CoreInterface.CreateInstance(SClass_ID.Osm, m_Global.Class_ID.Create(0xf72b1, 0));
var uvmapModContext = m_Global.ModContext.Create(m_Global.Matrix3.Create(true), null, null);

var numrefs2 = uvmapMod.NumRefs; //returns 2
for (int j = 0; j < numrefs2; j++)
{
       IReferenceTarget refTarget = uvmapMod.GetReference(i); //null

       if (refTarget != null && refTarget.SuperClassID == SClass_ID.ParameterBlock2)
       {
               IIParamBlock2 pblock = (IIParamBlock2)refTarget;
               pblock.SetValue(PB_LENGTH, m_CoreInterface.Time, 50.0f, 0);
       }
}

IIParamArray uvmapModParams = uvmapMod.ParamBlock; 
IIParamBlock2 uvmapModpb2 = uvmapMod.GetParamBlockByID(0);
IIParamBlock2 uvmapModpb2_ = uvmapMod.GetParamBlock(0);

So none of the above work when trying it on a uvmap modifier, I've tried a bend modifier which uses paramblock2 and it works, so I'm not sure what I'm doing wrong.

var bendMod = (IModifier)m_CoreInterface.CreateInstance(SClass_ID.Osm, m_Global.Class_ID.Create(0x00010, 0));
IIParamBlock2 iBendParams2 = bendMod.GetParamBlock(0);

Any ideas? 

Thanks,

Vin

IParamBlock and IParamBlock2 are mutually exclusive. Older 3dsmax plugins will use IParamBlock where as newer ones (10 years old or so) will use IParamBlock2. To get IParamBlock you need to iterate over Animatable's sub-anims (myObj.SubAnim( i )) and see if you can cast the result to IIParamBlock.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hey Marsel,

 

Thank you very much again for your help! I guess it's normal then that the NumParamBlocks return 0 because it returns ParamBlock2s. I've itereated over the subanims and it works now! :) 

 

Thanks again!
Vin