Draw Dimension using Revit API

Draw Dimension using Revit API

Anonymous
Not applicable
1,946 Views
2 Replies
Message 1 of 3

Draw Dimension using Revit API

Anonymous
Not applicable

We want to draw dimensions between sleeve (specialty equipment) and Grid lines .

but when we apply dimensions revit throw the error message "Remove References - The references of highlighted dimension are no longer parallel"

Dimension error.png

0 Likes
1,947 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

How do you create this dimensioning in the UI? The API normally only supports stuff that the UI also supports.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

Anonymous
Not applicable

 

First get Sleeve(speciality equipment) XYZ Co-ordinates
Second we get grid intersection point nearest to sleeve and then find nearest point from sleeve on the grid
Third step we get references of sleeve and grid.
Fourth one is draw line using sleeve and grid XYZ coordinates
and then draw dimensions

XYZ sleeve_xyz = null; Element elm = doc.GetElement(Sleeve_id.Id); FamilyInstance fi = elm as FamilyInstance; Autodesk.Revit.DB.Location position = elm.Location; Autodesk.Revit.DB.LocationPoint positionPoint = position as Autodesk.Revit.DB.LocationPoint; sleeve_xyz = positionPoint.Point; sleeve_xyz = new XYZ(sleeve_xyz.X, sleeve_xyz.Y, 0); Reference sleeve_ref = GetSleeveReference(fi, SpecialReferenceType.CenterLR); Grid first_grid2 = doc.GetElement(First_Grid_elemID) as Grid; Reference gridRef = null; Options opt = new Options(); opt.ComputeReferences = true; opt.IncludeNonVisibleObjects = true; opt.View = doc.ActiveView; foreach (GeometryObject obj in first_grid2.get_Geometry(opt)) { if (obj is Autodesk.Revit.DB.Line) { Autodesk.Revit.DB.Line line = obj as Autodesk.Revit.DB.Line; gridRef = line.Reference; } } XYZ gr_point2 = new XYZ(grid_intersection_point.X, sleeve_xyz.Y, 0.000000000); Autodesk.Revit.DB.Line line5 = null; line5 = Autodesk.Revit.DB.Line.CreateBound(gr_point2, sleeve_xyz); ReferenceArray refArray = new ReferenceArray(); refArray.Append(sleeve_ref); refArray.Append(gridRef); Dimension dim = doc.Create.NewDimension(doc.ActiveView, line5, refArray);


 

0 Likes