PDA

View Full Version : Changing a RGMRecipe Items value using VSTA



cdaly2001
31st August 2014, 12:56
Hi,

The method set_DynamicProperties of the RGMRecipeValue object does not seem to alter the value.

I have written the following code;

public void Macro_editRecipeItem()
{
String newRecipeName;
newRecipeName = this.Variables().Item("rcpNewRecipeName").get_Value(0).ToString();
// MessageBox.Show(newRecipeName);




this.RGMGroups().Item("Amp Rose").RecipeItem(newRecipeName).ValueItem("rcpVar").set_DynProperties("Type", 2);

//This has no effect on the recipe items value
this.RGMGroups().Item("Amp Rose").RecipeItem(newRecipeName).ValueItem("rcpVar").set_DynProperties("Value", 10);


//This shows the recipe variables correct value, so it proves the names are all correct
MessageBox.Show(this.RGMGroups().Item("Amp Rose").RecipeItem(newRecipeName).ValueItem("rcpVar").get_DynProperties("Value").ToString());

}

Has anyone used this method successfully before?

BR

Chris

bernhardf
1st September 2014, 07:16
Hi,

altering the

this.RGMGroups().Item("Amp Rose").RecipeItem(newRecipeName).ValueItem("rcpVar").set_DynProperties("Value", 10);

directly won't work (don't ask my why exactly but there is something special about the RGM in the API which is not the same as for other zenon objects)

You have to do it like this:
(create variables/a copy of the RGM object and modify this copy/variables):



public void Macro_AlterMyRGMRecipe()
{
zenOn.IRGMRecipeGroups zRGM;
zRGM = this.RGMGroups();

zenOn.IRGMRecipeGroup zRecipeGroup = zRGM.Item("groupName");
zenOn.IRGMRecipe zRecipe = zRecipeGroup.RecipeItem("recipeName");

zRecipe.ValueItem("variableName").set_DynProperties("Value", 10);

zRecipe.Save();
zRecipeGroup.Save();
}


Tested it here in 7.11 and it works that way.

Kind regards,
Bernhard

cdaly2001
1st September 2014, 07:54
Thank you Bernhard, works perfectly.