Set a shared project parameter remains not assigned

Set a shared project parameter remains not assigned

newbieng
Contributor Contributor
1,076 Views
2 Replies
Message 1 of 3

Set a shared project parameter remains not assigned

newbieng
Contributor
Contributor

Hi,

I'm encountering a problem setting the value of a shared project parameter.

I added a shared project parameter using SharedParameters.RawCreateProjectFromExistingSharedParameter(), now I want to set its value. 

 

The code runs without any issue (debugging the code it finds the parameter and appearently set it), but the parameter value in revit remains not assigned ... any idea to solve this issue? If I try the same code in a revit macro, everything works fine and the value is set. Here is my code, the parameter type is double.

 

using (Transaction t = new Transaction(myDoc, "setParameter"))
{
	t.Start();
        Element myPanel = myDoc.GetElement(panelId);
        Panel myPan = myPanel as Panel;
        //Parameter myParameter= myPan.LookupParameter("myParameterName");
        var pa = myPan.GetParameters("myParameterName");
                    
        var myParameter= pa.First();
        myParameter.Set(11);
        t.Commit();
}

 

 

Thanks!

0 Likes
1,077 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor

If it is a shared parameter I suggest you use it's GUID to get and set it.

Message 3 of 3

newbieng
Contributor
Contributor

Your suggestion was useful, anyway I found out an error in my code: it was a transaction not properly committed that caused my issue (the sample I posted was a general snippet of the code, and as it is here, it works fine even if it's better to use GUID!).

 

Thanks guys

0 Likes