Navisworks

Navisworks API: Working with Grids And Levels

By Naveen Kumar

In Navisworks, grids and levels are valuable tools for exploring a scene, providing spatial context for your location and the placement of objects within the environment.

You can access grids and levels through the "Grids & Levels" panel in the View tab. Now, let’s utilize the Navisworks API to work with grids and levels.

In this blog post, we will explore the following topics:

  • Turns grids on or off
  • Customizing grid line colors based on the camera’s position
  • Configuring the grid mode
  • Setting a specific display level when "Fixed" grid mode is selected

Turns grids on or off

// Access the active document in Navisworks
   Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
              
// Retrieve grid options from the Navisworks application
   GridsOptions gridOptions = Autodesk.Navisworks.Api.Application.Options.Grids;
                 
// Enable grid visibility (set to 'false' to hide the grid)
   gridOptions.Enabled = true;

// If X-ray mode is switched off, transparent gridlines hidden by objects will not be displayed.
   gridOptions.XRayMode = true;

Customizing grid line colors based on the camera’s position

// Customize grid line colors based on the camera's position
   gridOptions.AboveColor = new Color(1, 0, 0);  
   gridOptions.BelowColor = new Color(0, 1, 0);  
   gridOptions.OtherColor = new Color(1, 1, 1);      

Configuring the grid mode

// Access the Grids object from the active document
DocumentGrids docGrids = doc.Grids;

// Set the grid render mode to show both above and below grid lines
docGrids.RenderMode = GridsRenderMode.AboveAndBelow; 

Setting a specific display level when "Fixed" grid mode is selected

GridSystem gridSystem = docGrids.ActiveSystem;
// Set the grid render mode to "Fixed" and restrict grid visibility to a specific level 
// e.g., Level 3
// ensuring the grid remains fixed at that level during navigation.             
   GridLevelCollection gridLevelCollection = gridSystem.Levels;
   GridLevel requiredGridLevel = gridLevelCollection.Where(level => level.DisplayName=="Level 3").First();

// Set grid render mode to "Fixed" if Level 3 is found
   if (requiredGridLevel != null)
     { 
       docGrids.RenderMode = GridsRenderMode.Locked;
       docGrids.SetSystemLockedLevel(gridSystem, requiredGridLevel);
     }


04/05/2024

06/13/2023

10/03/2022

05/04/2022

04/06/2021

04/20/2020

07/28/2019

09/30/2018

07/01/2018

03/29/2017

October 2024

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Autodesk Blogs

Share