hi,
similar like placing the grid extents outside the crop region, is that possible to place the tags(Room/Space) outside the crop region.
@c.poupin
Tag alignment based on Crop Region 1.3.0.dyn (27.6 KB)
hi,
similar like placing the grid extents outside the crop region, is that possible to place the tags(Room/Space) outside the crop region.
@c.poupin
Tag alignment based on Crop Region 1.3.0.dyn (27.6 KB)
Hello
have you an example (screenshot result)?
even it requires in left and right direction also.
from the center point it should scatter to the nearest crop boundary.
Hello @dhilipseshan ,
try this variant
the script processes all roomtags in active View, the offset distance must be entered manually
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
def moveTgtoCrop(boundLines, rtag):
ptTag = rtag.Location.Point
lstInter = []
for lineBound in boundLines:
interResult = lineBound.Project(ptTag)
lstInter.append(interResult)
lstInter.sort(key = lambda x : ptTag.DistanceTo(x.XYZPoint))
firsttInterResult = lstInter[0]
rtag.TagHeadPosition = firsttInterResult.XYZPoint
#move location to update TagHeadPosition
rtag.Location.Move(XYZ(0.001,0.001,0))
def getBoundLines(bbx, Zvalue, offsetCrop = 1):
lstPt = []
lstLine = []
lstPt.append(XYZ(bbx.Min.X, bbx.Min.Y, Zvalue))
lstPt.append(XYZ(bbx.Max.X, bbx.Min.Y, Zvalue))
lstPt.append(XYZ(bbx.Max.X, bbx.Max.Y, Zvalue))
lstPt.append(XYZ(bbx.Min.X, bbx.Max.Y, Zvalue))
for idx, pt in enumerate(lstPt):
if idx == 0:
lstLine.append(Line.CreateBound(lstPt[- 1], pt))
else:
lstLine.append(Line.CreateBound(lstPt[idx - 1], pt))
polycuDS = DS.PolyCurve.ByJoinedCurves([x.ToProtoType() for x in lstLine])
polycuDS = polycuDS.Offset(offsetCrop)
rvtLines = [x.ToRevitType() for x in polycuDS.Explode()]
return rvtLines
offsetCrop = IN[0]
activView = doc.ActiveView
cropBox = activView.CropBox
viewRange = activView.GetViewRange()
cutOffset = viewRange.GetOffset(PlanViewPlane.CutPlane)
fecRoomTg = FilteredElementCollector(doc, activView.Id).OfCategory(BuiltInCategory.OST_RoomTags).ToElements()
boundLines = getBoundLines(cropBox, cutOffset, offsetCrop)
TransactionManager.Instance.EnsureInTransaction(doc)
for rtag in fecRoomTg:
moveTgtoCrop(boundLines, rtag)
TransactionManager.Instance.TransactionTaskDone()
OUT = fecRoomTg
Hi @c.poupin ,
looks amazing.
This works perfect for top and bottom leaders.
I used same for space tag also.Tag based on crop region-python.dyn (8.2 KB)
for top and bottom leader comes straight
but in left and right it doesn’t coming straight as shown in sample image.
Hello
I’m not sure it’s possible to fix the offset between the leader line and the baseline of a tag
ok thank you so much for your precious time.