Create a Family Type Shared Parameter

Create a Family Type Shared Parameter

MikeM615
Participant Participant
1,052 Views
2 Replies
Message 1 of 3

Create a Family Type Shared Parameter

MikeM615
Participant
Participant

Good morning, 

I am attempting to create a new Family Type, Shared Parameter in python/dynamo and ran into a little snag.

 

I was able to make a Family Type, Family Parameter successfully, but when I get into making a shared parameter I cannot find anything in the API for setting the Family Type Category so when it creates the family it sets the value to -1. 

Any suggestions on where this topic may be covered I am missing, or what I am missing?


Thanks, 

family_Category = family_Type.Category
type_Group = Compare_Built_In_Parameter_Groups(type_Parameter_Group)
#family_Paramater_Type = ParameterType.FamilyType
TransactionManager.Instance.EnsureInTransaction(doc)

if type_Parameter_Names_User_Input is not None:
	type_Group = Compare_Built_In_Parameter_Groups(type_Parameter_Group)
	type_Parameter_Names_List = type_Parameter_Names_User_Input.split(delim)
	for type_Parameter_Name in type_Parameter_Names_List:
		result.Add([type_Parameter_Name,type_Group,family_Category])
		try:
			add_Parameter = doc.FamilyManager.AddParameter(type_Parameter_Name, type_Group, family_Category, False)
		except Exception as e:
			result.Add("Run Failed"+ " " + e.ToString())

 

 

if parameter_Names_User_Input is not None and parameter_Type is not None and parameter_Group is not None:
    parameter_Names_List = parameter_Names_User_Input.split(delim)
    
    for parameter_Name in parameter_Names_List:
		if parameter_Name != "":
			
			shared_Parameter_Definition = ExternalDefinitionCreationOptions(parameter_Name, parameter_Type)
			if hidden_Parameter == True:
				shared_Parameter_Definition.Visible = False
			shared_Parameter_Definition.UserModifiable = True
			#if family_Type is None:
			parameter_Group.Definitions.Create(shared_Parameter_Definition)
			#else:
				#shared_Parameter_Definition.
				#family_Category = family_Type.Category
				

 this portion of script creates this:

MikeM615_1-1685717594018.pngMikeM615_2-1685717609801.png

 

0 Likes
Accepted solutions (1)
1,053 Views
2 Replies
Replies (2)
Message 2 of 3

architect.bim
Collaborator
Collaborator
Accepted solution

Hi!

If you open some Shared Parameters file you will see that Category is already defined there. So there is no need for you to set it in your code.

architectbim_0-1685941801743.png

This Category is set when you add new Parameter to the Shared Parameters file. If you do it manually, Revit asks you to set the Category. If you do it with code, there are GetDataType and SetDataType methods in ExternalDefinitionCreationOptions class.

So just edit your Shared Parameters file to match the necessary Categories. And then use it to run your code and create Family Type Shared parameters you need in your family.


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 3 of 3

MikeM615
Participant
Participant

That makes sense, I will give that a shot, thank you very much for the suggestion!