Get top and bottom for dimensions

Get top and bottom for dimensions

larsTB09
Contributor Contributor
283 Views
1 Reply
Message 1 of 2

Get top and bottom for dimensions

larsTB09
Contributor
Contributor

Hello, 


Trying to add dimensions to section view trough API

 

1) Dimension for with has been added. But how do i get the top face and bottom face to get a height dimension?

2) is it possible to add a second layer to show the location of the family on top of the beam? if yes, how do i snap the dim line to the family instance?

 

Schermafbeelding 2023-04-30 113112.png

            var selectedBeam = uidoc
                .Selection
                .GetElementIds()
                .Select(doc.GetElement)
                .OfType<FamilyInstance>()
                .FirstOrDefault();


            var beamFaces = GetSolids(selectedBeam)
                .SelectMany(x => x.Faces.OfType<PlanarFace>())
                .ToList();

            var view = getview;

            var leftFace = beamFaces
                .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(-1 * view.RightDirection));

            var rightFace = beamFaces
                .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(view.RightDirection));

 

0 Likes
284 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni

To answer your first question, selecting top and bottom face: similar to your code for right and left face, pick the two faces whose normal vectors point up (Z direction, (0,0,1)) and down (-Z, (0,0,-1)) respectively.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open