Family manager - change the current family type

Family manager - change the current family type

stever66
Advisor Advisor
4,371 Views
2 Replies
Message 1 of 3

Family manager - change the current family type

stever66
Advisor
Advisor

How to change the current family type in the family manager?  I need to do this so I can set a parameter?

I'm trying to write a short, simple macro that runs in the family manager, and copies one family parameter to another family parameter.  The family will have various types, so the parameter contents will vary per family type.  

 

I've got the code to read the parameter working correct, but it always writes to the same family type.  I assume this is because the "get_Parameter" includes the family type, but the "Set" parameter doesn't seem to include this.

 

I've seen the example of how to make a new type (in about a dozen places):

FamilyType newFamilyType = familyManager.NewType("2X2");

but no examples at all of how to change the current type. 

 

 

Here is part of my code:

 

famMan = doc.FamilyManager;
                    string types = "Family Types: ";
                using (Transaction t = new Transaction(doc))
                 {
                 t.Start("Change parameters");
                 
                 FamilyTypeSet familyTypes = famMan.Types;
                FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
                familyTypesItor.Reset();
                while (familyTypesItor.MoveNext())
                {
                    FamilyType familyType = familyTypesItor.Current as FamilyType;
                    types += "\n" + familyType.Name;
                    string value = familyType.AsString(famMan.get_Parameter("MANUFACTURER")); /////////THIS WORKS!!!!!!!
                    TaskDialog.Show ("Revit"value);
                    FamilyParameter familyParam = famMan.get_Parameter("MANUFACTURER 1");
                    //FamilyType newFamilyType = famMan.CurrentType(familyType.Name);   ?? wont compile - cant be used like a method?
                     
                     famMan.Set(familyParam, value);  //always sets the same type parameter
                 }
                 t.Commit();
                }

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

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

FamilyManager has CurrentType property, just set it:

famMan.CurrentType = familyType;
Message 3 of 3

stever66
Advisor
Advisor

So simple.  Awsome.  Thank-you.

 

I thought I had tried that, but I guess not.  And my basic C# programming skills still have some gaps.

 

Now I understand the error message - "can't use like a method."  A method gets arguments passed in parentheses, exactly what I was trying to do.

 

0 Likes