Revit API Dimension Site Property Lines

I’m looking into ways of Dimension Site Property Lines programmatic way using combination of Dynamo and python. The purpose of this exercise is to automate string of dimension from the property line to a known detail lines in multiple area plan views.

I have modified the following python code originated by @Einar_Raknes:


#Original code from @Einar_Raknes
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Converting input from Dynamo to Revit
if isinstance(IN[0], list):
	lines = []
	for i in IN[0]:
		lines.append(UnwrapElement(i))
else:
	lines.append(UnwrapElement)
	
_dimLocation = UnwrapElement(IN[1]).GeometryCurve

#Create a list of element Reference for dimension string
refLines = ReferenceArray()
	
for i in lines:
	refLines.Append(i.GeometryCurve.Reference)

#Create the dimension in a transaction

TransactionManager.Instance.EnsureInTransaction(doc)

dim = doc.Create.NewDimension(doc.ActiveView,_dimLocation, refLines)

TransactionManager.Instance.TransactionTaskDone()


OUT = lines,refLines,dim

The Python code works as I needed it with detail line works. But here is the issue.

  1. The python script requires an Element reference array (Line 29: refLines = ReferenceArray() )
  2. The Property Line element contains Subelements which are lines.

For script to work I need to get the each Subelement of the Property Line Reference. Has any one come across how to get the Element. Reference from a Property lines.?

The closest I got to getting this Element Reference is by using the node “Element.ElementCurveReference”:

But ElementCurveReference is not the same as the Reference needed for the dimension Array.

Thanks in advance.

Since I last post this (a few hours ago). I have attempted another method to get the Property Line Reference to be used with the ReferenceArray() to be used in creating the dimension string.

The method I tried is by deleting the Property line Temporary to attempt to get each element in the property line. Hoping that one of the element is what I need to complete the dimension string.

I have filtered out the ModelCurve which makes-up the Property line Segments see below:

image

At this point I got excited “Finally someting I can get a Reference!”.
Below is the script I used in attempt to get the Property Line Reference.


#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/

#modified by Christopher Escobido

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

elt = []
for i in IN[0]:
	elt.append(UnwrapElement(i).Id)

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

t1 = SubTransaction(doc)
t1.Start()

elm_del = []
cantdelete=[]
for item in elt:
	try:
		deleted = doc.Delete(item)
	except:
		cantdelete.append(item)
t1.RollBack()

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

for ids in deleted:
	items = doc.GetElement(ids)
	itemsName = items.GetType().ToString()
	if (items.GetType().ToString()) == 'Autodesk.Revit.DB.ModelLine':
		elm_del.append(items)
	#elm_del.append(itemsName)

_elmReferene = []

for items in elm_del:
	_elmReferene.append(items.GeometryCurve.Reference)

#Outputs Model lines and its line Reference

OUT=cantdelete,elm_del,_elmReferene

The next thing I did is add the Reference I got from the ModelLines to the ReferenceArray() which I hope will complete the task of dimension the Property Lines. (“Hooray”)

.
.
.
.

Run the Script thinking it would create the dimension string. Here is what appeared:

One Segment of the dimension string appeared but the segment to the Red line (Property line Element) is missing. ???

What went wrong.?

Turned out nothing went wrong the dimension was created. BUT it only appears when I edit the Property line in sketch mode (see below):

Lesson learned, The ModelLine embedded into the Property Line was not the reference I needed.

Any suggestion would help. Thanks in Advance.