I've created a program to create concrete beams and columns while you are working in a project(NOT IN FAMILY EDITOR) What I would like to accomplish is if user enters an already existing size (type), I want the program to place that size instead of throwing the exception that comes if the family symbol name already exists. The program has the try/catch for that error, but is there any way to catch and then invoke the place by family instance command instead of catching the error? Please help. the programming language is C#.
Thank you in advance.
Please take a look at the Revit SDK sample CreateBeamsColumnsBraces.
That will hopefully answer your question in full.
Best regards,
Jeremy
Jeremy,
Thank you for your response. Your program lists the families already existing in the project. My program asks the user to type in their desired size, so if it already exists, i want the user to place that size. ON the contrary, if the size doesnt it exists, it creates it and allows you to place it. However the program spits out the revit.exception that the size(family symbol name) already exists and exits the program. Like I said previously, is there anyway to avoid the exception?
You avoid the exception by looking for the existing FamilySymbol first (filtering).
Use one of the Document.LoadFamilySymbol overloads in preference to loading the family and all of it's symbols via LoadFamily.
Note you also need to activate the FamilySymbol if it hasn't already been used and you want to use it (check FamilySymbol.IsActive).
Picking the right NewFamilyInstance overload to use depends on purpose of element.
RPThomas108,
thank you. I have the first part, but the family is already loaded in, and I would like to duplicate the family symbol, rename and change the parameters within a project. See code below.
FilteredElementCollector concRoundcollector = new FilteredElementCollector(doc).OfClass(typeof(Family)); foreach (Family family in concRoundcollector) { if (family.Name == familyName) { foreach (var symbolid in family.GetFamilySymbolIds()) { var symbol = doc.GetElement(symbolid) as FamilySymbol; if (symbol.Name == newFamilySymbolname)
// newFamilySymbolname is being pulled from a form { uidoc.PromptForFamilyInstancePlacement(symbol); } else { // Transaction here to duplicate family symbol, // rename, set parameters and place. If I comment out the else. it works where. The else give me the error.
Hello desantis15,
Were you able to figure this out? I am running into a similar issue. Can't seem to figure out how to create a new familyInstance from scratch, or even duplicate one then try to edit the properties.
Can't find what you're looking for? Ask the community or share your knowledge.