Message 1 of 5
Obtaining References from edges in Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm (trying) to put together a Python routine that will automatically create dimensions on a square face of a generic model. i.e. the user select the face and dimensions appear...
I'm writing Python code using Dynamo.
I've got some of the code working, obtaining the edges from a user selected 3D face, this returns the 4 edges (which are Edge class objects), it should simply be a case of obtaining the edge's reference that can be used to create the dimensions.
The Edge class has a Property which should return a reference to the edge - but when I run the code, it returns Null - and I can't see why.
This is the code:
# Dynamo 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 doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument #The inputs to this node will be stored as a list in the IN variables. dataEnteringNode = IN selobject = UnwrapElement(IN[0]) # Object to select #Get user to pick a face selob = uidoc.Selection.PickObject(Selection.ObjectType.PointOnElement, "Pick something now") #Get Id of element thats picked selobid = selob.ElementId #Get element thats picked getob = doc.GetElement(selobid) #Get face thats picked getface = getob.GetGeometryObjectFromReference(selob) #Get edges of face (returns a list the first object is the list of edges) edgeloops = getface.EdgeLoops #Select the first edge dimedge1 = edgeloops[0][0] #Select the third edge (the one opposite the first) dimedge2 = edgeloops[0][2] #Obtain a reference of the first edge edgeref1 = dimedge1.Reference #Obtain a reference of the thord edge edgeref2 = dimedge2.Reference #Assign your output to the OUT variable. OUT = [selob, selobid, getob, getface, edgeloops, dimedge1, dimedge2, edgeref1, edgeref2]
If you execute it you'll see that edgeref1 and edgeref2 variables both return Null.
Any idea why?
Thanks.