How obtain updated Parameter Value within a public void?

How obtain updated Parameter Value within a public void?

Anonymous
Not applicable
561 Views
4 Replies
Message 1 of 5

How obtain updated Parameter Value within a public void?

Anonymous
Not applicable

Hi,everyone

I have parameter A, parameter B, and Parameter C of a element

first I need to set parameter A or B to value (Yes) or (No) as it needs.

and use the new parameter value to do  the following if statements to set Parameter C.

But somehow I can never obtain the updated parameter.

If parameter A value was set to "No" when I select the element. The value will states the same even after I set to "Yes" and get the parameter again.

Is there anyway to update the parameter value of and selected element within the code?

Thanks

 

 Parameter pA = e.get_Parameter("A");
Parameter pB = e.get_Parameter("B"); 
Parameter pC = e.get_Parameter("C");
pA.Set(0);
pb.Set(0);
Parameter npA = e.get_Parameter("A");
Parameter npB = e.get_Parameter("A");
string ParaA = npA.AsValueString(); 

If(npA == "Yes" || npB == " Yes")
{
ParaC.Set(1);
}
If(npA == "No" && npB == " No")
{
pC.Set(0);
}

 

0 Likes
Accepted solutions (1)
562 Views
4 Replies
Replies (4)
Message 2 of 5

ollikat
Collaborator
Collaborator
Accepted solution

Hi

Have you tried using the Document.Regenerate() after setting the parameters? It indeed might need that.

You can find some related topics from the Building coder site i.e. http://thebuildingcoder.typepad.com/blog/2010/06/to-regenerate-or-not-to-regenerate.html

Also there's something related in this forum also:

http://forums.autodesk.com/t5/revit-api/document-modification-transactions-parameters-etc/m-p/545850...

Hope this helps.

0 Likes
Message 3 of 5

Revitalizer
Advisor
Advisor

Hi,

 

you are comparing a Parameter object with a string.

You need to compare the Parameter's value.

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 5

Anonymous
Not applicable

This method works great

I also found another example from Jeremy:

http://thebuildingcoder.typepad.com/blog/regen/

Thanks

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi,Revitalizer

Thanks for your reply.

The new code should be:

 

doc.Regenerate(); 
Parameter npA = e.get_Parameter("A");
Parameter npB = e.get_Parameter("A");
//Convert Parameter to Value String
string ParaA = npA.AsValueString();
string ParaB = npB.ASValueString();

If( ParaA == "Yes" || ParaB == "Yes")
{
ParaC.Set(1);
}
If( ParaA == "No" && ParaB == "No")
{
pC.Set(0);
}
0 Likes