Community
the "endpoint" reference of a wall has ElementReferenceType.REFERENCE_TYPE_SURFACE,
so the dimension has to be parallel to the wall.
You can however dimension the Edges of the wall with a dimension non-parallel to the wall.
Here is some code that works in planviews:
ReferenceArray refArr = new ReferenceArray(); List<GeometryObject> geoObjects = GetGeometryObjects(_wall); foreach (GeometryObject obj in geoObjects) { Solid solid = obj as Solid; if (solid == null) continue; foreach (Face _face in solid.Faces) { if (Math.Abs(_face.ComputeNormal(new UV(0, 0)).Z) < 0.0001) { foreach (EdgeArray _edgeArr in _face.EdgeLoops) foreach( Edge _edge in _edgeArr) { XYZ direction = _edge.ComputeDerivatives(0).BasisX.Normalize(); if (direction.IsAlmostEqualTo(XYZ.BasisZ) || direction.IsAlmostEqualTo(XYZ.BasisZ.Negate())) { refArr.Append(_edge.Reference); if (_edge.Reference == null) continue; } } } if (refArr.Size > 1) break; } if (refArr.Size > 1) break; } XYZ dimDirection = new XYZ(1, 1, 0); LocationCurve lc = _wall.Location as LocationCurve; XYZ startPoint = lc.Curve.GetEndPoint(0); using (Transaction t = new Transaction(document, "dimension_wallEnd")) { t.Start(); // create dummy line to "lock" the direction of dimensionline DetailCurve dummy = document.Create.NewDetailCurve(document.ActiveView, Line.CreateBound(startPoint, startPoint.Add(dimDirection.CrossProduct(XYZ.BasisZ)))); refArr.Append(dummy.GeometryCurve.Reference); Dimension dim = document.Create.NewDimension(document.ActiveView, Line.CreateBound(XYZ.Zero, dimDirection), refArr); sb.AppendFormatLine("{0}", dim.Id); document.Delete(dummy.Id); t.Commit(); }
Can't find what you're looking for? Ask the community or share your knowledge.