Hi, i trying to write a Dynamo Python Code to edit the Filled Region Type name in Revit.
Acording to Revit Lookup, the FilledRegionType class has a property call “Name”.
But when i try to access it thru Dynamo Python node. It say “Property Cannot Be Read”.
What is actually wrong here? Is there anyway to get or edit the Name property of the FilledRegionType class?
Try the get_Name() method - the version of Dynamo you are in (think you are missing an update) likely is failing to properly convert the .NET method to Python, but the hard coded call should exist.
Double check my spelling if it doesn’t work - change the last line to OUT = dir(t1)
1 Like
Hi
Try
import Autodesk
Before from Autodesk
edit:
python script
import sys
import clr
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
t1=doc.GetElement(ElementId(419780))
OUT = t1.get_Name(),dir(t1)
Macro C#
public void essfrt()
{
Document doc=this.Document;
UIDocument uidoc=Application.ActiveUIDocument;
//choix de filledregion
Selection choix = uidoc.Selection;
Reference choixselection = choix.PickObject(ObjectType.Element);
FilledRegion fr=doc.GetElement(choixselection) as FilledRegion;
FilledRegionType frt=doc.GetElement(fr.GetTypeId()) as FilledRegionType;
TaskDialog.Show(" essai ","Name FilledRegionType : "+frt.Name);
}
Cordially
Christian.stan
2 Likes
Hi Jacob, thanks for replying, yes that work, and i found out there is another method call set_Name() also, can be used to change the Filled Region Type Name. But these 2 method aren’t listed in the RevitApi. I wonder where they come from?
Hi Christian, thanks for replying, i’ve tried the get_Name() method. It worked!! I just wondering where this method come from since it is not listed in the RevitAPI. Or does it?
1 Like
They are in the API - name is a property, and the get_
and set_
methods are actually the Python wrapper of the .NET method that allows getting and setting the property. The direct translation (i.e. elem.Name = "new name"
to set the value or elem.Name
to get the value) is failing due to the the wrapper not mapping the call to the associated method (i.e. get_Name and set_Name respectively).
1 Like
It’s an Inheritance bug only on CPython3 / PythonNet2.5, this only concerns the getter of certain classes.
This has been fixed with PythonNet3 and IronPython3.
Some additional information can be found here.
1 Like
Hi, thanks guys for explaining the story about get not being present in the ElementType (I would have been behind on that specific aspect of things).
This PythonNet3 looks good to me.
I can’t wait for my school to make a big upgrade. Sincerely,
christian.stan
1 Like