# Reverse dimension location

**URL:** <https://forum.dynamobim.com/t/reverse-dimension-location/76793>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [May 23, 2022, 5:49am UTC](https://forum.dynamobim.com/t/reverse-dimension-location/76793 "2022-05-23T05:49:53Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [May 30, 2022, 4:46pm UTC](https://forum.dynamobim.com/t/reverse-dimension-location/76793/6 "2022-05-30T16:46:02Z")

</div>

Hello  
instead of performing a Reverse Dimensions location, you can try to group walls by nearest Curves of Cropbox  
here, an example with (IronPython)

![curveWallDimensions](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9b983b6ae09b2d11abd2df3c746afa507d9b95c4.gif)

Python code

```auto
import clr
import sys
import System
from System.Collections.Generic import List, IList, Dictionary
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
sys.path.append(pf_path + '\\IronPython 2.7\\Lib')
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)

def nearestWall(wall, line):
	"""
	Check if the input wall is nearest to the input line (and both are perpendicular)
	if the distance is less than half the cropbox --> return True to add to the group
	"""
	global currZ, midCropX, midCropY
	curveWall = wall.Location.Curve
	# pull curve on view plane
	pta, ptb = (curveWall.GetEndPoint(i) for i in range(2))
	curveWall = DB.Line.CreateBound(XYZ(pta.X, pta.Y, currZ), XYZ(ptb.X, ptb.Y, currZ))
	#
	if abs(curveWall.Direction.DotProduct(l.Direction)) < 0.1: # if wall is perpendicular to the cropbox line
		outrefClosest = clr.Reference[IList[ClosestPointsPairBetweenTwoCurves]](List[ClosestPointsPairBetweenTwoCurves]())
		curveWall.ComputeClosestPoints(line, True, True, True, outrefClosest) # compute distance between curves
		closestPoint = outrefClosest.Value[0]
		min_distance = closestPoint.Distance
		if line.Direction.IsAlmostEqualTo(XYZ.BasisX):
			return min_distance < midCropY
		else:
			return min_distance < midCropX
	return False

inputScale = IN[0]
view = doc.ActiveView
currZ = view.GenLevel.ProjectElevation
cropbox = view.CropBox
midCropX = (cropbox.Max.X - cropbox.Min.X) * 0.5 
midCropY = (cropbox.Max.Y - cropbox.Min.Y) * 0.5
#
group_walls = []
region = view.GetCropRegionShapeManager().GetCropShape()
if len(region) > 0:
	scale_curveloop = CurveLoop.CreateViaOffset(region[0], inputScale, XYZ(0,0,-1))
	for l in scale_curveloop:
		walls = FilteredElementCollector(doc, view.Id).OfClass(DB.Wall)\
												.WhereElementIsNotElementType()\
												.Where(System.Func[DB.Wall, bool](lambda w : nearestWall(w, l)))\
												.ToList()
		group_walls.append(walls)
	OUT = view, [l.ToProtoType() for l in scale_curveloop], group_walls

```

_Note_  
_another solution is to find the exterior walls and then group the other walls that are joined to each of these exterior walls_

[Dim Walls\_v3.dyn](https://forum.dynamobim.com/uploads/short-url/fiFuAt5PRakdjzvnAL7JyJg3xbn.dyn) (32.7 KB)

---

_[View the full topic](https://forum.dynamobim.com/t/reverse-dimension-location/76793)._
