Hi everyone,
I am new in Dynamo and Python Script, so sorry for my mistakes.
I am trying to make a Python script in Dynamo, which is based on picking points on elements and showing the coordinates of the points and also the host element.
Everything works fine until I place a pickpoint on Text note, then I simply get “Operation failed”.
Simply when “doc.GetElement()” is assigned to text note, the script is not working.
Any sugestions?
Thanks for your reply.
Maybe I explained it wrong - I meant a “text note”, not “text node”. I am speaking about classic text in Revit - it has it´s ID, so I assume it is an element.
Thank you for your help.
Unfortunately the code is still not working for me, maybe it is caused by the version of Revit or Dynamo ( I am using Revit 2018.2 and Dynamo Core 1.3.2.2480
May I ask which version of Revit and Dynamo did you use for testing?
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import Point as dsPoint
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
#points selection
selpoints = uidoc.Selection.PickObjects(Selection.ObjectType.PointOnElement, 'Select Points')
#host elements and point coordinates
prvky = []
points = []
for A in selpoints:
prvky.append(doc.GetElement(A))
pt = A.GlobalPoint
points.append(dsPoint.ByCoordinates(UnitUtils.ConvertFromInternalUnits(pt.X,UIunit),UnitUtils.ConvertFromInternalUnits(pt.Y,UIunit),UnitUtils.ConvertFromInternalUnits(pt.Z,UIunit)))
#Assign your output to the OUT variable.
OUT = [prvky, points]
Thank you for your help, it is really caused by the Revit language. If I run Revit in english, the code works fine. If i run Revit in czech (/language CSY) the code show “Operation failed”.
Is there any way how to find the reason for this, or is there any idea how to solve it?
Text note doesn’t work with other language version than English Revit in Dynamo 1.3.
This is a known bug with Dynamo 1.3. This has been corrected in Dynamo 2.0.