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: 

2015 to 2016 grid line reference problem

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
desdinova
601 Views, 4 Replies

2015 to 2016 grid line reference problem

ReferenceArray thirdDimension = new ReferenceArray();

            IList<Reference> myRefs = uidoc.Selection.PickObjects(ObjectType.Element, "Pick");

            foreach(Reference r in myRefs)
            {
                Element element = doc.GetElement(r);
                Grid grid = element as Grid;
                Line gridLine = grid.Curve as Line;
                XYZ direction = gridLine.Direction;
                thirdDimension.Append(gridLine.Reference);

            }

            XYZ firstPoint = uidoc.Selection.PickPoint("Select first point");
            Line firstLine = Line.CreateBound(new XYZ(firstPoint.X + 200, firstPoint.Y, firstPoint.Z), new XYZ(firstPoint.X - 200, firstPoint.Y, firstPoint.Z));

            using (Transaction t = new Transaction(doc, "Add Dimension"))
            {
                t.Start();
               
                Dimension third = doc.Create.NewDimension(doc.ActiveView, firstLine, thirdDimension);
               
                t.Commit();
            }

Helo everyone

The code above works revit 2015 but does not work 2016 

There is no error when compling  

How can i solve this 

Thanks in advance...

4 REPLIES 4
Message 2 of 5
boostyourbim
in reply to: desdinova

In 2016 get the grid reference like this:

Reference gridRef = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in grid.get_Geometry(opt))
{
if (obj is Line)
{
Line line = obj as Line;
gridRef = line.Reference;
}
}
Message 3 of 5
desdinova
in reply to: boostyourbim

Thank you it worked.

Message 4 of 5

hi, i got the same problem with the dimensioning between grids but your solution doesn't work in my case. the reference of the line is always null.
Message 5 of 5
Scott_Wilson
in reply to: desdinova

Removing the view from the geometry options might make it work for you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community