Change parameter value for multiple families

Hi!

I want to change the URL parameter value to nothing for all families but I can’t seem to get it right when collecting all families. The script works when conecting one family (Specifik familj) to the “Byter parameterns värde”-group. any suggestions? Im working in revit 2018.

It’s because URL is TYPE parameter, not family one, you should do something like this:

2 Likes

Thank you, that’s one step further of what i want to do. But i want dynamo to change the URL for all families without me having to pick each categorie and run the script. So I guess that some sorting needs to be done to be able to solve the problem?

Well, I’m not sure how to achieve this in dynamo but this code will do the thing:

public static void SetAllTypesURLValue(string url)
        {
            Document document = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument;
            var symbolCollector = new FilteredElementCollector(document)
               .OfClass(typeof(FamilySymbol));
            using (Transaction transaction = new Transaction(document, "SetURL"))
            {
                transaction.Start();
                foreach (FamilySymbol fs in symbolCollector)
                {
                    if(!(fs.IsActive))
                    {
                        fs.Activate();
                    }
                    if((fs.LookupParameter("URL")!=null)&&(fs.LookupParameter("URL").IsReadOnly!=true))
                    {
                        fs.LookupParameter("URL").Set(url);
                    }
                }
                transaction.Commit();
            }
        }

If you are interested in developing in Revit API i recommend this to begin with, or you can re write it in Python.

1 Like

You would have to check to see if each instance has the URL parameter first. If it does, use the instance. If it doesn’t, get the type instead. Then you can set the value for each instance or type at the same time.

You have also to check if its not read only.

Thank you, I’m a rookie when it comes to coding so I don’t really know where to apply this code :sweat_smile:

Send me your email in private message, I will send you compiled file, just import it like any other package.

1 Like

Here’s a dumb way to do it…
Very slow. But you can get a list of what has a URL field and what doesn’t with the null output.

 import clr
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

# Import ToDSType(bool) extension method
clr.AddReference('RevitNodes')
import Revit
from Revit.Elements import *
clr.ImportExtensions(Revit.Elements)

allTypes = FilteredElementCollector(doc).WhereElementIsElementType().ToElements()

OUT = allTypes