Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Setting Yes/No parameters value through API

Anonymous

Setting Yes/No parameters value through API

Anonymous
Not applicable

Hello! Im trying to import values from an Excel file into my Revit Project. This is the way I am setting the parameters right now but it doesnt do anything to the Yes/No box.

 

   Parameter p = e.get_Parameter(new Guid("1c8055b5-7eb4-4aba-9da7-91f0255a84d5"));
                    using (Transaction t = new Transaction(doc, "parameter"))
                    {
                        t.Start("param");
                        p.Set(0);
                        t.Commit();
                    }

Shouldnt the 0 unselect the Yes/No box? Or do I have this mixed up with something else. 

 

Let me know if you need any clarification.

 

0 Likes
Reply
3,666 Views
5 Replies
Replies (5)

stever66
Advisor
Advisor

Is your shared parameter set for "User modifiable" in the shared parameters file?

 

And  what is "e"?  An element in the model, or a family type?  Since shared parameters are set for each family type, e should contain a family type, not a family instance.  But I'm assuming you have this part right if its working for shared parameters that are a text type.

 

I don't see anything wrong with the "p.Set(0);" or "p.Set(1);".   That is working for me for yes/no instance parameters.  

 

 

 

 

0 Likes

Anonymous
Not applicable

Hello! Thanks for the reply. I ended up figuring it out, I just rewrote the whole method that part of the code was in and it ended up working. Thanks again for your help!

0 Likes

stever66
Advisor
Advisor

I had a heck of a time getting a sample of that code to work too.  The yes/no parameter wouldn't change.  So I tried with a couple of different text parameters.

 

Still no change.  I kept scratching my head on why something so simple wouldn't work.

 

Finally realized I had left out one line of code:   t.Commit():

 

Without that line, nothing in the model changes 🙂

 

 

 

0 Likes

Anonymous
Not applicable

Hahahah I did the exact same thing, took me an hour to figure that one out the hard way.

0 Likes

gdavis479JP
Contributor
Contributor

How about you post your fixed code please.