Autodesk.Revit.DB.Reference to Curve

Hello Dynamo people.

I want to create Room Boundary Lines at the location of the reference planes from a family.
In the family I named the Reference Planes "Front"and “Back”.
With Dynamo I can collect these Reference Planes from the family in the project.
Last step is to convert these (Autodesk.Revit.DB.Reference) to Curves or Lines, but i downt know how.
Can anyone help me?

Thanx in advance

import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
from Revit.Elements import *
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
elements = UnwrapElement(IN[0])
par1 = IN[1]
par2 = IN[2]
refs = list()

for el in elements:
doorrefs = list()
refin = FamilyInstance.GetReferenceByName(el, par1)
refex = FamilyInstance.GetReferenceByName(el, par2)
doorrefs.append(refin)
doorrefs.append(refex)

refs.append(doorrefs)

OUT = refs

http://www.revitapidocs.com/2018.1/536b3d7a-ec8d-29f6-5957-751468c98dd0.htm
test=Element.GetGeometryObjectFromReference(doc.GetElement(el.Id),refin)

I was trying with something like this but then if i try to convert both the reference and my test variable to dynamo geometry with .ToProtoType() I got errors…

I remembered having a similar issue but it was the opposite, convertin revit faces to references and I remember the node “RevitFaceReference.FromDynamoSurface”, but I can’t really understand its contenct (can’t find it in the API?) to try and understand what we could do to in orde to do the opposite…

Googling I found this:



I also found this:


http://www.revitapidocs.com/2018.1/b3c10008-aba6-9eee-99c9-7e05ace75796.htm
Right know I can’t cointinue to try and find out but maybe it’s a start. The NewAlignment method allows you to lock a reference to another (maybe like the lock in Revit’s UI), so maybe you could place a room line and then lock it to your references… ugh

Maybe also this
https://forums.autodesk.com/t5/revit-api-forum/geometry-returns-no-reference-for-familyinstance/td-p/6015366

I am stuck in the same area. What do we do with Autodesk.Revit.DB.Reference as output from the Python. Could anyone please guide us what we should do next?

@Jeremy_Tammik @Zach_Kron Any thoughts?

Simple. Read the docs, my friend.

doc.GetElement(Reference)

https://apidocs.co/apps/revit/2019/4d674a3e-cd18-6b3d-b1b2-247713fe3c9f.htm

2 Likes

Hey,

Away from my PC right now, I have a workflow which might be useful…

I can have more of a look tomorrow.

Cheers,

Mark

Edit: I’m thinking of the first Python in there, it converts references to curves and makes them usable in Dynamo with the ToProtoType()… there is also the ToRevitType() method as defined here…

Hello Jeremy! Thanks for the reference. I did try using the doc.GetElement(Reference) method. It simply retrieves the family instance, the parent object where the reference plane resides. I am attempting to gather the reference planes used in the family so I can use Dimension.Byelements without having to create temporary lines if that makes sense. Is it even possible to duplicate the Revit’s way of adding dimensions? By tabbing repeatedly I could get to the same references and use them for dimensions.

yes, retrieving the intenal planes and edges of the family instance sound like the right thing to do and corresponds to the ui tabbing.

You could use these References to create dimensions.
But i was looking for a way to get the geometry of these References to create a Room Boundary Line.
Anyone know how?

Hey,

(Should probably start a new thread and reference this one)

Is that because you want the boundaries to move with the curves? As if they are locked?

I’m not sure that is possible… The reference is an attribute of the geometry, not the other way round.

You can convert the boundary lines to room boundary curves, but obvs they lose the association. You could probably tweak the graph to delete and recreate the curves to keep them aligned.

Capture

Hope that helps,

Mark

Does anybody got something in relationship of this in this time? I have the same issue: I’m able to get the references from a family instance and I want to creat a room separator using them, but I’m not able to create a line or a plane from references…

OK, I think I get it:

http://www.revitapidocs.com/2018.2/fbd33f0f-2c2c-c001-8041-996bc0872b2b.htm

I have used the method SketchPlane Create(Document, Reference) for creating a plane, and then I can use that plane for creating my lines in the model. I hope it helps.

1 Like

You can also use the FamilyInstance Reference node in Genius Loci package that already includes this feature.

4 Likes

Well digging into further details I found the issue in how I was handling “refList” as python List. changing the line “refList = list()” to “refList = ReferenceArray()” solves this problem. It apparently is the value type mismatch.

With this information, can u make a python script which create Room Boundary Lines from family reference planes what mentioned above?

I was able to do something like this. Look into your original post and replace

refs = list()

to something like

refs = ReferenceArray()

Here below is a node I made for my project and I was able to get the actual references. Give it a try.

import clr
clr.AddReference(“ProtoGeometry”)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitNodes”)
import Revit

from Revit.Elements import *

clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *

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

dataEnteringNode = IN

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)

#Input
elements=UnwrapElement(IN[0])
line = UnwrapElement(IN[1]).GeometryCurve
refList = ReferenceArray()

#Get Reference Planes from Families
for i in elements:
ref = FamilyInstance.GetReferenceByName(i,“Center (Left/Right)”)
#optionsView = Options.View(doc.ActiveView)
#refType = FamilyInstanceReferenceType.CenterLeftRight
#refName = FamilyInstance.GetReferences(i,refType)
#refElem = doc.GetElement(ref)
#refID = ref.ElementId
refList.Append(ref)
#refTypeA = Reference.ConvertToStableRepresentation(ref,doc)
#refTypeB = Reference.ParseFromStableRepresentation(doc, refTypeA)
#refList.append((refTypeB))

#Create Dimensions
dimension = doc.Create.NewDimension(doc.ActiveView, line, refList)

TransactionManager.Instance.TransactionTaskDone()

OUT = dimension

1 Like