Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dimmension end of wall

1 REPLY 1
Reply
Message 1 of 2
sonicer
262 Views, 1 Reply

dimmension end of wall

still can't make dimmension if the wall is not paralel?

1 REPLY 1
Message 2 of 2
FAIR59
in reply to: sonicer

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.

 

wall2.PNGwall.PNG

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.

Post to forums  

Autodesk Design & Make Report