Hi, I’m trying to get all of the reference points across a set of walls, intersected by a Ray, in order to create a dimension.
So far I’ve referenced the walls intersected by the ray:
refIntersector = ReferenceIntersector(wallFilter, FindReferenceTarget.Edge, view3D)
referenceWithContext = refIntersector.Find( XYZ(-100,0,0) , XYZ(100,0,0))
refArray = ReferenceArray()
for ref in referenceWithContext:
refArray.Append(ref.GetReference())
The problem is I can’t figure out how to extract or delve deeper into the references themselves. I assume the References are Edges, but I get errors when trying to get their Endpoints, or the coordinates of the XYZ being returned, for example I can get the XYZ by using GlobalPoint, but I can’t get the coordinates or the XYZ object because it “is not callable”.
for r in refArray:
p = r.GlobalPoint()
print(p)
In the end my goal is to get the edge references in order to create dimensions. It seems simple enough but I think I made it more complex than it has to be.
Any ideas on how to tackle this?
1 Like
Hi did you manage to “delve deeper into the references”? Im trying to get references from modelcurves instead of walls and append them to a referenceArray to create a new dimension , but ive failed to do so. Would you happen to know , how could I extract references from revit modelcurves? Thanks
Hi,
I think in the end I used iteration on the faces of the walls, figuring out their direction normal and extracting face.Reference
into the reference array.
also when collecting the wall geometry I used:
options.ComputeReferences = True
I guess you can also use the LocationCurve
for the wall and extract the reference from there.
Does that help?
1 Like
Hi , thanks for your answer!
I wanted to get the modelcurves references since I have several intersecting walls that are not being annotated by my current dynamo python block. Would you happen to know how to get the references from intersecting walls ? and how to anotate not just the external face of the wall but also the interior one? Here is what Ive writte so far:
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
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
line = UnwrapElement(IN[0]).GeometryCurve
#line=IN[0]
walls=UnwrapElement(IN[1])
doc = DocumentManager.Instance.CurrentDBDocument
def parallel(v1, v2):
#gets two vectors and check if parallel
return v1.CrossProduct(v2).IsAlmostEqualTo(XYZ(0, 0, 0))
opt=Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
opt.View = doc.ActiveView
faces_arr=[]
def delete_dimensions():
dimensions=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Dimensions).WhereElementIsNotElementType().ToElements()
for dimension in dimensions:
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Delete(dimension.Id)
TransactionManager.Instance.TransactionTaskDone()
def create_dimensions():
delete_dimensions()
walls_2=FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
all_lines=[]
for wall in walls_2:
elements_ref=ReferenceArray()
ln=wall.Location.Curve.CreateOffset(2,XYZ(0,0,1))
all_lines.append(ln)
for ref in wall.get_Geometry(opt):
if isinstance(ref,Solid):
for face in ref.Faces:
if parallel(face.FaceNormal, ln.GetEndPoint(1) - ln.GetEndPoint(0)):
elements_ref.Append(face.Reference)
TransactionManager.Instance.EnsureInTransaction(doc)
new_dimension=doc.Create.NewDimension(doc.ActiveView, ln, elements_ref)
TransactionManager.Instance.TransactionTaskDone()
return all_lines
OUT=create_dimensions()
Hi,
Not sure what you mean by “intersecting walls”…?
In any case I see you’re also offsetting the location curve in the Z direction… why? Maybe that’s the issue.
I think you can create a reference to the location line for the center of the wall if it was created by centerline or somehow calculate the thickness and offset your reference line by that amount.