C# Node Error: Element is not registered

I’m developing a Zero Touch node, but I’m having some trouble returning the elements that my program is creating. I’ve been looking around but haven’t found any support for this error message which is kind of surprising! I thought the approach I used was pretty common sense since it worked on the Dynamo canvas.

Here is the code that I’m working with, where A is a list of furniture elements, and B is a list of objects that contain the properties of those elements. Hopefully there’s a simple solution out there.

The error message I’m receiving states that the element is not registered. I assume it has something to do with the elements requiring an ID, but as I said, can’t find an example or documentation for this. Thanks!

List<Element> A = new List<Element>();
for (int i = 0; i < B.Count; i++)
{
    Element elem;
    FamilyInstance inst;
    FamilyType myType;
    Point myPoint;

    myType = FamilyType.ByFamilyNameAndTypeName(B[i].family, B[i].type);
    myPoint = Point.ByCoordinates(B[i].X, B[i].Y);
    inst = FamilyInstance.ByPoint(myType, myPoint);
    temp = inst.SetParameterByName(Param, B[i].value);
    A.Add(temp);
}
return A;

Looks like you’re attempting to call the Parameter.Set method on the Family Instance object - I’ve not checked the API, so that method you’re using may be correct, but try extracting the parameter object from the Family Instance first, then call Set and input your value.

what’s Param in your code? SetParameterByName if I remember correctly takes two inputs. One is string for the parameter name and another is obj for parameter value. Is Param a string name of the parameter?

I’m trying this method but not having any luck. I’m assuming you mean something like this: inst.Parameters.SetValue(B[i].value, 7); Here 7 is the index of the parameter I want to set.
Unfortunately it’s just not working, maybe because the parameter is a boolean, but I’ve also tried using 0’s and 1’s, so that probably isn’t it.
Anyways I would prefer a solution that uses the SetParameterByName method because that way the user has more flexibility. I suppose if the SetValue method worked, I could write a function to cycle through the parameters looking for a match, but who wants to do that…

Yes, Param is a string and the value is a boolean.

I’ve made some adjustments to my code and I’m not experiencing this error any more. There’s a new topic for the subsequent error here.

For reference I got rid of the error by not using the Element type at all. Just adding the FamilyInstance directly to the list of elements.