Type to instance

Dear Dynamo community,
I have a question, i want to get instance parameters from these types is it possible?
i want to use the normal Revit nodes i want to aavoid packages as much as i can.
Best regards.

image

1 Like

Hi,

The typical workflow would be to get an instance element and parameters from there…

Otherwise it gets a bit more awkward, perhaps I am forgetting an easier way…

If you don’t have any placed instances, you could place one, get the parameters, then delete it.

If you are comfortable in Python you can use a filtered element collector to get the type and then pull parameters from there, checking if they are ‘isInstance’.

Hope that helps,

Mark

1 Like

it didn’t get me the instance parameters

TBH with you i don’t know anything about python.

I think this is what you’re after:

2 Likes

As most people have shown you in solutions a type will not correlate to a single instance, in fact it may not correlate to any instances if none are placed in the project. Whilst an instance has a type, a type will usually have many instances with their own respective instance parameters.

If you’re trying to snoop the parameters available to the family, an alternative method could be to get the type’s family, programatically open/read/close the family document and return all parameter names. I have nodes in Crumple which can do this that use Python.

1 Like

Hey,

This is an example, I place then delete.

I don’t think it works in Dynamo unless you can use a roll back… Someone will correct me if I’m wrong…

Warning : Super Slow!

Background opening is still valid as Gavin says, I think that would also be super slow :slight_smile:

import clr

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

import Revit
clr.ImportExtensions(Revit.Elements)

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument
structuralType =  Structure.StructuralType.NonStructural

# Get all window types
window_collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsElementType().ToElements()

#get any level
level = [FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).ToElements()][0][0]
#make a point anywhere
point = XYZ(1,0,0)

# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)
window_params = []
for type in window_collector:
    type.Activate()        
    window_fam = doc.Create.NewFamilyInstance(point, type, level, structuralType)
    parameters = window_fam.Parameters
    param_info = []
    for parameter in parameters:
        param_info.append([parameter.Definition.Name, parameter.AsValueString()])    
    window_params.append([window_fam.Name, param_info])
    doc.Delete(window_fam.Id)#

# Commit the transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = window_params
1 Like

Best bet will be a rollback here, as that will be faster. That said I don’t see why we want to do this - when faced with such an issue it is almost always a sign that you are going at the problem in the wrong direction.

1 Like