Open Blaze147 opened 6 years ago
All of my Code:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import System
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB.Document import GetElement
from Autodesk.Revit.DB.Element import GetTypeId
from Autodesk.Revit.DB.FamilyType import Name
#The inputs to this node will be stored as a list in the IN variables.
elements = UnwrapElement(IN[1])
test = []
for x in elements:
type = doc.GetElement(x.GetTypeId())
test.append(type.Name)
#Assign your output to the OUT variable.
OUT = test
This is not a bug in Dynamo or Revit but a limitation of the iron python multiple class inheritance interpretation. The problem with a family type (FamilySymbol) is that it inherits from a lot of other classes:
and if any of the intermediate classes overrides a method/property, that could introduce ambiguity. The correct way to get the name therefore is to specify which version of the name property you'd like to use:
@dimven do you have a good source or documentation for this ironPython /.net issue?
No documentation unfortunately. This is only a suspicion based on the fact that in the python syntax there is a concept of multiple inheritance, where as in dot.net/c# there generally isn't one (other than interfaces). So somewhere along the way, the inheritance possibly gets jumbled.
@Blaze147 - can you verify if this behavior still occurs when using ironPython shell - you might need to uninstall dynamo as we depend on a different version of ironPython - just curious if this is something that might have changed between ironPython versions - I did not find anything obvious in their release log though.
You can use LookupParameter method and use AsString method to get readable name.
# dynamo version - 1.3.2
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
elems = FilteredElementCollector(doc, doc.ActiveView.Id).ToElements();
type_names = []
for e in elems:
try:
type_names.append(doc.GetElement(e.GetTypeId()).LookupParameter("Type Name").AsString())
except:
pass
OUT = type_names
Dynamo version - 1.3.1.1736
Revit version - 2016/2017.2
Operating system - Windows 10
What did you do?
What did you expect to see?
What did you see instead?
BTW, I am using the correct references: