Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Closest Grid Point Intersection to object in User Tab

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
2470 Views, 6 Replies

Adding Closest Grid Point Intersection to object in User Tab

Hello everyone,

 

I'm using Navisworks 2014 and I'm trying to create a plugin to add to a specific/selected object the closest grid intersection point in a property user tab.

 

Although I know how to create the user tab and add properties pragmatically, I cannot find a reference to retrieve the closest grid intersection point. This should basically be what the clash detective "Grid Intersection" shows.

 

Should I use the "GridIntersection Class" to do this? And if so, where should I start?

 

Thanks!

 

 

6 REPLIES 6
Message 2 of 7
xiaodong_liang
in reply to: Anonymous

Hi,


given a referenced point, you can use GridSystem.ClosestIntersection(point) to get the closest GridIntersection which tells the postion, level, line1 and line2 of the intersection.

I guess the referenced point of "Grid Intersection" in Clash Detective is ClashResult.Center.

In your case, you could use the BoundingBox center of the object you are interested in. or BoundingBox Max or Min.

Message 3 of 7
Anonymous
in reply to: xiaodong_liang

Great! Thanks Xiaodong, I'll try it right now.
Message 4 of 7
Anonymous
in reply to: Anonymous

Xiaodong,

 

I'm having a hard time getting the intersection point data I can add to the user tab:

 

This is what I have:

 

static public Point3D GetClosestGridIntersection()
        {
             //check that selection is valid
            if (!Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.IsEmpty)
            {
                //Get bounding box of the selection
                BoundingBox3D bb3d =
                   Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems.BoundingBox();

                //get the closest grid intersection point
                GridIntersection oGridIntersection = Autodesk.Navisworks.Api.GridSystem.ClosestIntersection(bb3d.Center);
            }

                //return the vector
                return oGridIntersection;
        }

 

 I would then buidl the string I need to put in th euser tab property.

 

I get the following error message:

"Error 5 An object reference is required for the non-static field, method, or property 'Autodesk.Navisworks.Api.GridSystem.ClosestIntersection(Autodesk.Navisworks.Api.Point3D)'"

 

I'm new to C#... can someone let me know what I'm missing?

 

Thanks,

Message 5 of 7
xiaodong_liang
in reply to: Anonymous

The GridSystem class does not provide a static method to get the closest point. You need to get the current grid system and call ClosestIntersection. The following is the updated code:

 

static public Point3D GetClosestGridIntersection()
      {
          GridIntersection oGridIntersection = null; ;

          //check that selection is valid
          if (!Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.IsEmpty)
          {
              //Get bounding box of the selection
              BoundingBox3D bb3d =
                 Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems.BoundingBox();

              GridSystem oGS = Autodesk.Navisworks.Api.Application.ActiveDocument.Grids.ActiveSystem;

              //get the closest grid intersection point
              oGridIntersection = oGS.ClosestIntersection(bb3d.Center);
          }

          //return the vector
          return oGridIntersection.Position;
      }

 

Message 6 of 7
Message 7 of 7
Anonymous
in reply to: xiaodong_liang

Thanks a lot!

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report