Error happens when I try to edit the parameter of a family instance

Error happens when I try to edit the parameter of a family instance

Anonymous
Not applicable
906 Views
5 Replies
Message 1 of 6

Error happens when I try to edit the parameter of a family instance

Anonymous
Not applicable

Hello everyone,

I've been using Revit to create a few Family and tring to manage them in my addin. Notice that I create these family for a Rail Station, these're families like Rail, Turnout, Fastener, and so on. So these families do not have a system definition (is my expression right?).

It's been ok when I try to place them in a Revit project, but when I try to edit the parameter of a family instance of one of the above families, it kept showing an error message like "Create the Family Type Failed"... I'm really confused right now.

 

Here're my codes:

Transaction instanceEdit = new Transaction(doc, "Instance Edit");
instanceEdit.Start();

FamilyInstance fi = ***;
    foreach (Parameter p in fi.Parameters)
    {
        if (p.Definition.Name == "length")
        {
            p.Set(dataSet.dataLength);
        }
        if (p.Definition.Name == "width")
        {
            p.Set(dataSet.dataWidth);
        }
        if (p.Definition.Name == "height")
        {
            p.Set(dataSet.dataHeight);
        }
    }

instanceEdit.Commit();

I'm sure of these parameters' existence, the "foreach" can find these parameters, but when the transaction commit, it shows an error says "Cannot generate Type: ***". (I'm using the Chinese version so I'm not sure how the original English error message says, is it saying Type or Symbol... but please tell me you understand what the error is)

 

Is my approach to edit the parameter wrong? Or?

 

Thanks!

0 Likes
Accepted solutions (1)
907 Views
5 Replies
Replies (5)
Message 2 of 6

Charles.Piro
Advisor
Advisor

Hi,

 

Are you sure, that "dataSet.XXX" is not equal to 0.0 and the value is a double ?

The parameters (lenght, width and height) are Type or Instance ?

 

Smiley Wink

 



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks for answering!

 

I'm absolutely sure the value of "dataSet.XXX" is a double and not null, it's more like 400000... These're not problems, I think.

The parameters are of an Instance. By the way, I've tried changing it to "family.Parameters", "familySymbol.Parameters", and "familyInstance.Parameters". And I've tried set the parameters as either Type Parameters or Instance Parameters, as I said, I'm pretty sure the "foreach" sentences can find those parameters. So, I think the problems are from some place else...

 

Smiley Sad

 

0 Likes
Message 4 of 6

Charles.Piro
Advisor
Advisor
Accepted solution

wAOUHH 400000 !!!

 

Feet or meter ?

I don't if you start or not with Revit API.

Revit API, use imperial unit. when you use méthod Set(), the double is a feet.

 

Have you test your value directly in Revit without addin ? All it's ok ?

 

Smiley Wink



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 5 of 6

Anonymous
Not applicable

It's okay when I change all those parameters manually.

I've noticed the unit difference between meter and feet, and I've done the unit format before the drawing and parameter setting.

The drawing is fine, so no problems here either.

Thanks anyway!

 

Smiley Sad

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

After a week of ignoring this problem and a few days of struggling, I start to review this problem today, and, well, it turns out when my head is a little bit calmer and when I try to track the input value step by step, I found out the value supposed to be 400000 is acturally 400000000 in the program, and there comes the error...

Anyway, this turns out to be a stupid question.

Thanks for your answer and I apologize for my stupidness...

Have a good day!Smiley Tongue

0 Likes