Hi @Mohamed_Arshad , my goal is to aligne the start of the leader with it end, i just created a Tag without leader at the beggining then after the move part i just created it, because it was occuring a problem is this possible ?, here just a sample "
ElementMulticategoryFilter multiCatFilter = new ElementMulticategoryFilter(categories);
try
{
FilteredElementCollector linkedCollector = new FilteredElementCollector(linkedDoc, doc.ActiveView.Id)
.WherePasses(multiCatFilter).WhereElementIsNotElementType();
foreach (Element RVT_Links_Elements in linkedCollector)
{
bb = RVT_Links_Elements.get_BoundingBox(doc.ActiveView);
if (bb != null)
{
XYZ centerBounding = (bb.Min + bb.Max) / 2.0;
ref_link = new Reference(RVT_Links_Elements).CreateLinkReference(element);
// Create a new tag
IndependentTag tag = IndependentTag.Create(doc, doc.ActiveView.Id, ref_link, false, tmode, toriant, centerBounding);
// Add the tag to the list of created tags
tags.Add(tag);
}
}
}" and here is the move part "
using (Transaction transMoveTags = new Transaction(doc, "Move Tags to Center of Lines"))
{
transMoveTags.Start();
for (int i = 0; i < tags.Count; i++)
{
IndependentTag tag = tags[i];
XYZ tagCenter = GetTagCenter(tag);
// Find the closest rectangle center to the tag
XYZ nearestRectangleCenter = rectangleCenters
.OrderBy(center => center.DistanceTo(tagCenter))
.FirstOrDefault();
if (nearestRectangleCenter != null)
{
// Move the tag to the nearest rectangle center
ElementTransformUtils.MoveElement(doc, tag.Id, nearestRectangleCenter - tagCenter);
// Remove the used rectangle center from the list
rectangleCenters.Remove(nearestRectangleCenter);
}
tag.HasLeader = true; // make sure the tag has a leader
tag.LeaderEndCondition = LeaderEndCondition.Free; // allow the leader end to be moved freely
}
transMoveTags.Commit();
}"
