How create new type filled region

Hello friends! I can’t create python code for creation new type filled region. Why? I am not understanding.
Help me please.


“type” is a built-in function, so I would not use it as a variable name. The error is actually telling you that you’re trying to call NewType() directly from an object type, not an actual instance. In your open family document, you first have to retrieve its FamilyManager by accessing the document’s property by the same name. The NewType() method only accepts a single string as its argument. Most of the imports you have are actually not necessary, so I’ve reduced it to only the ones you need.

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
name = IN[0]
manager = doc.FamilyManager

TransactionManager.Instance.EnsureInTransaction(doc)
new_type = manager.NewType(name)
TransactionManager.Instance.TransactionTaskDone()

OUT = new_type

new_type_example.dyn (3.6 KB)

2 Likes

Thank you for informarion. But I have this message…

And I don’t understand one moment… This code create new type for Filling Region?

Yes, but the new error implies that you are working in a project document rather than a family document. It would require a bit more work to create a new type from within a project document.

1 Like

For project document I need FamilyManager too?

You would need to use the EditFamily() method from your project document. From there, you would get the FamilyManager. It would work something like this:

# Assume a single family instance is in IN[0]
family_instance = IN[0]
family_symbol = fam_instance.Symbol
family = fam_symbol.Family

# EditFamily method returns the family document
family_doc = doc.EditFamily(family)
manager = family_doc.FamilyManager
1 Like

Ok. I will. Thank you so much!!)

1 Like