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: 

Revit 2016 unable to retrieve grid.Curve

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
331 Views, 2 Replies

Revit 2016 unable to retrieve grid.Curve

I'm trying to retrieve the curve property of a grid object in my Revit 2016 document, but somehow it's not working. When I debug my code VS tells me grid.Curve is null. But I can't figure out why. 

 

I've based my code on this example: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-...

 

foreach (Grid gridinstance in xxGrids)
{
     if (gridinstance.IsCurved)
     {
          Arc arc = gridinstance.Curve as Arc;
     }
     else
     {
          Line line = gridinstance.Curve as Line;
     }
}

xxGrids in this case is a list of Grid objects and is populated with some orthogonal grid objects. The IsCurved property of all of them is false, so I should be able to retrieve a line object based on the grid.Curve property but this is always null. 

 

When I use the snoop current selection tool I can see that the curve property is an actual line with endpoint coordinates and more. Why can't I retrieve this via code?

 

Anybody any thought on this? 

Thanks in advance..

Tags (2)
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

After some additional testing I've narrowed the problem down to the actual creation of the grid elements, in my case the grid elements are created in my code with a method which basically accepts 2 lists of XYZ's which represent the start and endpoints of the grid element: 

 

public static void CreateGridElements(Document document, List<XYZ> startPoints, List<XYZ> endPoints)
{
     if (startPoints.Count == endPoints.Count)
{
for (int i = 0; i < startPoints.Count; i++)
{
Line line = Line.CreateBound(startPoints[i], endPoints[i]);
Grid grid = Grid.Create(document, line);
}
}
}

Whenever I've created a gridelement with this method, I'm unable to retrieve the Curve property of the grid element. When I created a grid element via the normal Revit UI it does work. Is there somehow a difference between grid elements which are created through API or UI? 

Message 3 of 3
arpankumar.macwan
in reply to: Anonymous

Any update on this topic? I have same issue.

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