Hello,
I'm trying to create dimensions of walls by line using ReferenceIntersector class.
Please see the attached image. I have two identical detail lines that gives different results, both of them are wrongs.
I want to get the dimensions only along the detail line.
Any suggestions what can be the problem?
def GetIntersectingElements(origin, vec):
viewTypeCollector = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
for i in viewTypeCollector:
if i.ViewFamily == ViewFamily.ThreeDimensional:
view3D = i
viewType = i
t = Transaction(doc, "Create Temporary 3D View")
t.Start()
view3D = View3D.CreateIsometric(doc, viewType.Id)
t.Commit()
wallFilter = ElementClassFilter(Wall)
refIntersector = ReferenceIntersector(wallFilter, FindReferenceTarget.Face, view3D)
referenceWithContext = refIntersector.Find( origin, vec )
refArray = ReferenceArray()
for ref in referenceWithContext:
refArray.Append(ref.GetReference())
return refArray
if not Lines_selection == []:
tGroup = TransactionGroup(doc, "Create Dimensions XY")
tGroup.Start()
for line in Lines_selection:
LineDirection = line.GeometryCurve.Direction
LineOrigin = line.GeometryCurve.Origin
StartPoint = line.GeometryCurve.GetEndPoint(0)
EndPoint = line.GeometryCurve.GetEndPoint(1)
references = GetIntersectingElements(LineOrigin, LineDirection)
t2 = Transaction(doc, "Create Dimension X")
t2.Start()
refLine = Line.CreateBound(StartPoint, EndPoint)
gridDimension = doc.Create.NewDimension(doc.ActiveView, refLine, references)
t2.Commit()
tGroup.Assimilate()
Thanks,
Yuval
Solved! Go to Solution.
Solved by RPTHOMAS108. Go to Solution.
ReferenceIntersector uses a ray which is formed of origin and direction. Your detail lines are bound lines having also origin and direction but between limits. Your detail lines are directional in terms of the order the end points were created. So your ray based on their direction may head towards bottom of your screen or up towards top, for cases noted. In either case it will not be bound between the limits of your lines.
You can only Find or FindNearest with ReferenceIntersector so you'll have to rule out the items outside the bounds of your lines when using Find.
In simple terms if either of the distances between your intersection point and the end points of the bound line are greater than the length of the bound line then the intersection can't be within the limits of the bound line. If your ray starts at end point 0 and is in the direction of line then you only have to ensure the distances of the found intersections from endpoint 0 are less than or equal to the length of the line.
Can't find what you're looking for? Ask the community or share your knowledge.