Problem finding and accessing beam parameters

Problem finding and accessing beam parameters

Myrtaro
Explorer Explorer
455 Views
3 Replies
Message 1 of 4

Problem finding and accessing beam parameters

Myrtaro
Explorer
Explorer

Hello guys.

First of all, thanks to you for the help in advance. I'm quite new (and newbie) with the Revit API and with Revit itself. I don't know if this has been asked before, but I cannot find it. if that's the case, just adress me to that post.

I'm working with the RevitAPI for structural purposes. My goal is to check if a concrete beam meets its requeriments (following Spanish regulations, since I'm Spanish) and if don't, change the size of the section. For this I will need to take the values of width and height of the bem witch are represented by "b" and "h" in the family type "Concrete beam" but if I itterate through the diferent parameters (using Parameter.StorageType) I cannot find them. I'm assuming that those are Family Parameters and that's the reason why they're not there.

And now, the question. How can I acces those parameters?

Also, I will need to change the number and size of rebars for reinforcement and I have really no idea. Any suggestions would be welcome. I'm thinking maybe that the solution may be something related to define a new family with Shared Parameters and then edit them, what do you think?

Thank you all in advance!

Myrtaro.

0 Likes
456 Views
3 Replies
Replies (3)
Message 2 of 4

Charles.Piro
Advisor
Advisor

Hi,

 

In a family, can add parameters and when you create them, you must choose if it's a Type or an Instance.

If it'an Instance, you can go like this:

FamilyInstance famInst =  elemnt as FamilyInstance;
foreach(Parameter para in famInst.Parameters)
{
//Your Code
}

 

Or, ifit's a Type, you can go like this :

FamilyInstance famInst =  elemnt as FamilyInstance;
foreach(Parameter para in famInst.Symbol.Parameters)
{
//Your Code
}

Smiley Wink

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 4

Myrtaro
Explorer
Explorer

Thank you so much for your response Charles.Piro. It has been a great help, but I'm still havin some issues.

I want to know which parameter is each value annd assign it to the corresponding place in the checking algorithm. So I've been trying this variation of your code:

FamilyInstance famInst = ele as FamilyInstance;
Guid D1guid = new Guid("5caba040-0c37-4021-b49d-28f9f254b68a");
double D1 = famInst.get_Parameter(D1guid).AsDouble();
TaskDialog.Show("Revit", D1guid.ToString());
TaskDialog.Show("Revit", famInst.get_Parameter(D1guid).AsString());
TaskDialog.Show("Revit", D1.ToString());

 

Since I defined all the pàrameters used in the family in a Shared Parameters file I thought that a good way to know wich one is it is to use the GUID of each parameter. The TaskDialog are only there to ensure if the values stored are the right ones and there is the problem, they pop with the next vakues:
1-Shows the right GUID

2-Pops in blank

3-Shows a value of 0

 

I also tried the same method with the "foreach" code that you suggested and adding a TaskDialog in a similar way, but the message box pops blank.

 

So I think I'm still missing something ... any ideas what I'm doing wrong?

 

Thank you for your help.

0 Likes
Message 4 of 4

Charles.Piro
Advisor
Advisor

Hi,

 

here is an exemple, how to get information from a parameter (Type) from its number Guid :

public void exemple()
		{
			const string strGuid = "1a37c627-da68-4966-9633-7be9fde4da4a";
			Guid _guid = new Guid(strGuid);
			
			Reference refsel = Selection.PickObject(ObjectType.Element,"Select Element");
			Element elmnt = Document.GetElement(refsel.ElementId);
			FamilyInstance fammInst = elmnt as FamilyInstance;
			string strParaName = fammInst.Symbol.get_Parameter(_guid).Definition.Name;
			string strValue = fammInst.Symbol.get_Parameter(_guid).AsValueString();
			string strStorage = fammInst.Symbol.get_Parameter(_guid).StorageType.ToString();
			TaskDialog.Show("revit",strParaName + " - " + strValue + " - " + strStorage);
		}

 

For Instance Parameter, delete "Symbol" :

 

public void exemple()
		{
			const string strGuid = "1a37c627-da68-4966-9633-7be9fde4da4a";
			Guid _guid = new Guid(strGuid);
			
			Reference refsel = Selection.PickObject(ObjectType.Element,"Select Element");
			Element elmnt = Document.GetElement(refsel.ElementId);
			FamilyInstance fammInst = elmnt as FamilyInstance;
			string strParaName = fammInst.Symbol.get_Parameter(_guid).Definition.Name;
			string strValue = fammInst.get_Parameter(_guid).AsValueString();
			string strStorage = fammInst.get_Parameter(_guid).StorageType.ToString();
			TaskDialog.Show("revit",strParaName + " - " + strValue + " - " + strStorage);
		}

 

Smiley Wink

 



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes