private VisualizationInfo generateViewpoint(Viewpoint oVP, int elemCheck) { double units = GetGunits(); VisualizationInfo v = new VisualizationInfo(); try { Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D center = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) oVP.FocalDistance = 1; if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { // **** CUSTOM VALUE FOR TEKLA **** // // otherwise = 1 // **** CUSTOM VALUE FOR TEKLA **** // double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / (up.Length * 1.25); //zoomValue = Math.Tan(oVP.HeightField / 2) * oVP.FarPlaneDistance / _feet *1.25; // MessageBox.Show(oVP.HeightField.ToString() + " " + oVP.FarPlaneDistance.ToString() + " " + zoomValue + " " + oVP.HasFocalDistance.ToString() + " " + oVP.VerticalExtentAtFocalDistance.ToString()); v.OrthogonalCamera = new OrthogonalCamera(); v.OrthogonalCamera.CameraViewPoint.X = center.X; v.OrthogonalCamera.CameraViewPoint.Y = center.Y; v.OrthogonalCamera.CameraViewPoint.Z = center.Z; v.OrthogonalCamera.CameraUpVector.X = up.X; v.OrthogonalCamera.CameraUpVector.Y = up.Y; v.OrthogonalCamera.CameraUpVector.Z = up.Z; v.OrthogonalCamera.CameraDirection.X = vi.X; v.OrthogonalCamera.CameraDirection.Y = vi.Y; v.OrthogonalCamera.CameraDirection.Z = vi.Z; v.OrthogonalCamera.ViewToWorldScale = zoomValue; } else // it is a perspective view { double f = oVP.FocalDistance; //there is an issue when using vewpoint generated from clashes //their VerticalExtentAtFocalDistance is correct but the HorizontalExtentAtFocalDistance is too small! //so results that the aspect ratio in that case is <1. In which I try to get an approximate valut of the HorizontalExtentAtFocalDistance // by multiplying the vercial by 1.35 //double hfov = (oVP.AspectRatio < 1) ? oVP.VerticalExtentAtFocalDistance * 1.23245 / 2 : oVP.HorizontalExtentAtFocalDistance / 2; //double angle = Math.Atan(hfov * (1 / f)) * 2; //double angled = (180 * angle / Math.PI); //NAVIS USES HFOV //double vfov = oVP.VerticalExtentAtFocalDistance / 2; //double fov = Math.Sqrt(hfov * hfov + vfov * vfov); //double angle = Math.Atan(fov*(1/f)) *2; //double angled = (180 * angle / Math.PI); //MessageBox.Show(angled.ToString() + " " + oVP.FarDistance + " " +f + " " + oVP.NearDistance );// + "\n zoom" + zoom); zoomValue = f; v.PerspectiveCamera = new PerspectiveCamera(); v.PerspectiveCamera.CameraViewPoint.X = center.X; v.PerspectiveCamera.CameraViewPoint.Y = center.Y; v.PerspectiveCamera.CameraViewPoint.Z = center.Z; v.PerspectiveCamera.CameraUpVector.X = up.X; v.PerspectiveCamera.CameraUpVector.Y = up.Y; v.PerspectiveCamera.CameraUpVector.Z = up.Z; v.PerspectiveCamera.CameraDirection.X = vi.X; v.PerspectiveCamera.CameraDirection.Y = vi.Y; v.PerspectiveCamera.CameraDirection.Z = vi.Z; v.PerspectiveCamera.FieldOfView = zoomValue; } if (elemCheck == 0)//visible (0) _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList<ModelItem>(); if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) { v.Components = new Classes.Component[_elementList.Count]; string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < _elementList.Count; i++) { string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); v.Components[i] = new ARUP.IssueTracker.Classes.Component(appname, "", ifcguid); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return v; }
//<summary> //Generate a VisualizationInfo of the current view //</summary> //<returns></returns> public static VisualizationInfo GenerateViewpoint(Document doc, Viewpoint viewpoint) { try { NavisUtils.GetGunits(doc); var v = new VisualizationInfo(); Vector3D vi = GetViewDirection(viewpoint); Vector3D up = GetViewUp(viewpoint); Point3D c = new Point3D(viewpoint.Position.X, viewpoint.Position.Y, viewpoint.Position.Z); double zoomValue = 1; //prepare view viewpoint = viewpoint.CreateCopy(); if (!viewpoint.HasFocalDistance) { viewpoint.FocalDistance = 1; } // it is a orthogonal view if (viewpoint.Projection == ViewpointProjection.Orthographic) { //TODO: needs checking!!! double dist = viewpoint.VerticalExtentAtFocalDistance / 2; zoomValue = 3.125 * dist / (up.Length * 1.25); v.OrthogonalCamera = new OrthogonalCamera { CameraViewPoint = { X = c.X.FromInternal(), Y = c.Y.FromInternal(), Z = c.Z.FromInternal() }, CameraUpVector = { X = up.X.FromInternal(), Y = up.Y.FromInternal(), Z = up.Z.FromInternal() }, CameraDirection = { X = vi.X.FromInternal(), Y = vi.Y.FromInternal(), Z = vi.Z.FromInternal() }, ViewToWorldScale = zoomValue.FromInternal() }; } else { zoomValue = viewpoint.FocalDistance; v.PerspectiveCamera = new PerspectiveCamera { CameraViewPoint = { X = c.X.FromInternal(), Y = c.Y.FromInternal(), Z = c.Z.FromInternal() }, CameraUpVector = { X = up.X.FromInternal(), Y = up.Y.FromInternal(), Z = up.Z.FromInternal() }, CameraDirection = { X = vi.X.FromInternal(), Y = vi.Y.FromInternal(), Z = vi.Z.FromInternal() }, FieldOfView = zoomValue }; } //COMPONENTS PART //if (elemCheck == 0)//visible (0) // _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList<ModelItem>(); //if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) //{ // v.Components = new Data.Component[_elementList.Count]; // string appname = Autodesk.Navisworks.Api.Application.Title; // for (var i = 0; i < _elementList.Count; i++) // { // string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); // v.Components[i] = new Case.IssueTracker.Data.Component(appname, "", ifcguid); // } //} return(v); } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1, "Error generating viewpoint"); } return(null); }
/// <summary> /// convert navisworks coordinates to the ones used by BCF /// </summary> /// <param name="oVP"></param> /// <returns></returns> private XDocument generateViewpoint(Viewpoint oVP) { double units = GetGunits(); Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D c = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); string type = ""; string zoom = ""; double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) { oVP.FocalDistance = 1; } if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { type = "OrthogonalCamera"; zoom = "ViewToWorldScale"; // zoomValue = oVP.VerticalExtentAtFocalDistance / 2 / _ftConversion; double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / up.Length; } else // it is a perspective view { type = "PerspectiveCamera"; zoom = "FieldOfView"; zoomValue = oVP.FocalDistance; } XDocument v = new XDocument( new XElement("VisualizationInfo", new XElement("Components"), new XElement(type, new XElement("CameraViewPoint", new XElement("X", c.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", c.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", c.Z.ToString(CultureInfo.InvariantCulture))), new XElement("CameraDirection", new XElement("X", vi.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", vi.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", vi.Z.ToString(CultureInfo.InvariantCulture))), new XElement("CameraUpVector", new XElement("X", up.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", up.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", up.Z.ToString(CultureInfo.InvariantCulture))), new XElement(zoom, zoomValue.ToString(CultureInfo.InvariantCulture))))); try { //COMPONENTS PART if (_elemCheck == 0)//visible (0) { elementList = oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList <ModelItem>(); } if (null != elementList && elementList.Any() && _elemCheck != 2) //not if none (2) { string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < elementList.Count(); i++) { string ifcguid = IfcGuid.ToIfcGuid(elementList.ElementAt(i).InstanceGuid).ToString(); v.Element("VisualizationInfo").Element("Components").Add( new XElement("Component", new XAttribute("IfcGuid", ifcguid), new XElement("OriginatingSystem", appname), new XElement("AuthoringToolId", ""))); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(v); }
private VisualizationInfo generateViewpoint(Viewpoint oVP, int elemCheck) { double units = GetGunits(); VisualizationInfo v = new VisualizationInfo(); try { Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D center = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) { oVP.FocalDistance = 1; } if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { // **** CUSTOM VALUE FOR TEKLA **** // // otherwise = 1 // **** CUSTOM VALUE FOR TEKLA **** // double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / (up.Length * 1.25); //zoomValue = Math.Tan(oVP.HeightField / 2) * oVP.FarPlaneDistance / _feet *1.25; // MessageBox.Show(oVP.HeightField.ToString() + " " + oVP.FarPlaneDistance.ToString() + " " + zoomValue + " " + oVP.HasFocalDistance.ToString() + " " + oVP.VerticalExtentAtFocalDistance.ToString()); v.OrthogonalCamera = new OrthogonalCamera(); v.OrthogonalCamera.CameraViewPoint.X = center.X; v.OrthogonalCamera.CameraViewPoint.Y = center.Y; v.OrthogonalCamera.CameraViewPoint.Z = center.Z; v.OrthogonalCamera.CameraUpVector.X = up.X; v.OrthogonalCamera.CameraUpVector.Y = up.Y; v.OrthogonalCamera.CameraUpVector.Z = up.Z; v.OrthogonalCamera.CameraDirection.X = vi.X; v.OrthogonalCamera.CameraDirection.Y = vi.Y; v.OrthogonalCamera.CameraDirection.Z = vi.Z; v.OrthogonalCamera.ViewToWorldScale = zoomValue; } else // it is a perspective view { double f = oVP.FocalDistance; //there is an issue when using vewpoint generated from clashes //their VerticalExtentAtFocalDistance is correct but the HorizontalExtentAtFocalDistance is too small! //so results that the aspect ratio in that case is <1. In which I try to get an approximate valut of the HorizontalExtentAtFocalDistance // by multiplying the vercial by 1.35 //double hfov = (oVP.AspectRatio < 1) ? oVP.VerticalExtentAtFocalDistance * 1.23245 / 2 : oVP.HorizontalExtentAtFocalDistance / 2; //double angle = Math.Atan(hfov * (1 / f)) * 2; //double angled = (180 * angle / Math.PI); //NAVIS USES HFOV //double vfov = oVP.VerticalExtentAtFocalDistance / 2; //double fov = Math.Sqrt(hfov * hfov + vfov * vfov); //double angle = Math.Atan(fov*(1/f)) *2; //double angled = (180 * angle / Math.PI); //MessageBox.Show(angled.ToString() + " " + oVP.FarDistance + " " +f + " " + oVP.NearDistance );// + "\n zoom" + zoom); zoomValue = f; v.PerspectiveCamera = new PerspectiveCamera(); v.PerspectiveCamera.CameraViewPoint.X = center.X; v.PerspectiveCamera.CameraViewPoint.Y = center.Y; v.PerspectiveCamera.CameraViewPoint.Z = center.Z; v.PerspectiveCamera.CameraUpVector.X = up.X; v.PerspectiveCamera.CameraUpVector.Y = up.Y; v.PerspectiveCamera.CameraUpVector.Z = up.Z; v.PerspectiveCamera.CameraDirection.X = vi.X; v.PerspectiveCamera.CameraDirection.Y = vi.Y; v.PerspectiveCamera.CameraDirection.Z = vi.Z; v.PerspectiveCamera.FieldOfView = zoomValue; } if (elemCheck == 0)//visible (0) { _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList <ModelItem>(); } if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) { v.Components = new Classes.Component[_elementList.Count]; string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < _elementList.Count; i++) { string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); v.Components[i] = new ARUP.IssueTracker.Classes.Component(appname, "", ifcguid); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(v); }
private VisualizationInfo generateViewpoint(Viewpoint oVP, int elemCheck) { double units = GetGunits(); VisualizationInfo v = new VisualizationInfo(); try { Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D center = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) oVP.FocalDistance = 1; if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / (up.Length * 1.25); v.OrthogonalCamera = new OrthogonalCamera(); v.OrthogonalCamera.CameraViewPoint.X = center.X; v.OrthogonalCamera.CameraViewPoint.Y = center.Y; v.OrthogonalCamera.CameraViewPoint.Z = center.Z; v.OrthogonalCamera.CameraUpVector.X = up.X; v.OrthogonalCamera.CameraUpVector.Y = up.Y; v.OrthogonalCamera.CameraUpVector.Z = up.Z; v.OrthogonalCamera.CameraDirection.X = vi.X; v.OrthogonalCamera.CameraDirection.Y = vi.Y; v.OrthogonalCamera.CameraDirection.Z = vi.Z; v.OrthogonalCamera.ViewToWorldScale = zoomValue; } else // it is a perspective view { zoomValue = oVP.FocalDistance; v.PerspectiveCamera = new PerspectiveCamera(); v.PerspectiveCamera.CameraViewPoint.X = center.X; v.PerspectiveCamera.CameraViewPoint.Y = center.Y; v.PerspectiveCamera.CameraViewPoint.Z = center.Z; v.PerspectiveCamera.CameraUpVector.X = up.X; v.PerspectiveCamera.CameraUpVector.Y = up.Y; v.PerspectiveCamera.CameraUpVector.Z = up.Z; v.PerspectiveCamera.CameraDirection.X = vi.X; v.PerspectiveCamera.CameraDirection.Y = vi.Y; v.PerspectiveCamera.CameraDirection.Z = vi.Z; v.PerspectiveCamera.FieldOfView = zoomValue; } if (elemCheck == 0)//visible (0) _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList<ModelItem>(); if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) { v.Components = new Data.Component[_elementList.Count]; string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < _elementList.Count; i++) { string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); v.Components[i] = new Case.IssueTracker.Data.Component(appname, "", ifcguid); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return v; }
//<summary> //Generate a VisualizationInfo of the current view //</summary> //<returns></returns> public static VisualizationInfo GenerateViewpoint(Document doc, Viewpoint viewpoint) { try { NavisUtils.GetGunits(doc); var v = new VisualizationInfo(); Vector3D vi = GetViewDirection(viewpoint); Vector3D up = GetViewUp(viewpoint); Point3D c = new Point3D(viewpoint.Position.X, viewpoint.Position.Y, viewpoint.Position.Z); double zoomValue = 1; //prepare view viewpoint = viewpoint.CreateCopy(); if (!viewpoint.HasFocalDistance) viewpoint.FocalDistance = 1; // it is a orthogonal view if (viewpoint.Projection == ViewpointProjection.Orthographic) { //TODO: needs checking!!! double dist = viewpoint.VerticalExtentAtFocalDistance / 2; zoomValue = 3.125 * dist / (up.Length * 1.25); v.OrthogonalCamera = new OrthogonalCamera { CameraViewPoint = { X = c.X.FromInternal(), Y = c.Y.FromInternal(), Z = c.Z.FromInternal() }, CameraUpVector = { X = up.X.FromInternal(), Y = up.Y.FromInternal(), Z = up.Z.FromInternal() }, CameraDirection = { X = vi.X.FromInternal(), Y = vi.Y.FromInternal(), Z = vi.Z.FromInternal() }, ViewToWorldScale = zoomValue.FromInternal() }; } else { zoomValue = viewpoint.FocalDistance; v.PerspectiveCamera = new PerspectiveCamera { CameraViewPoint = { X = c.X.FromInternal(), Y = c.Y.FromInternal(), Z = c.Z.FromInternal() }, CameraUpVector = { X = up.X.FromInternal(), Y = up.Y.FromInternal(), Z = up.Z.FromInternal() }, CameraDirection = { X = vi.X.FromInternal(), Y = vi.Y.FromInternal(), Z = vi.Z.FromInternal() }, FieldOfView = zoomValue }; } //COMPONENTS PART //if (elemCheck == 0)//visible (0) // _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList<ModelItem>(); //if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) //{ // v.Components = new Data.Component[_elementList.Count]; // string appname = Autodesk.Navisworks.Api.Application.Title; // for (var i = 0; i < _elementList.Count; i++) // { // string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); // v.Components[i] = new Case.IssueTracker.Data.Component(appname, "", ifcguid); // } //} return v; } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1, "Error generating viewpoint"); } return null; }
/// <summary> /// convert navisworks coordinates to the ones used by BCF /// </summary> /// <param name="oVP"></param> /// <returns></returns> private XDocument generateViewpoint(Viewpoint oVP) { double units = GetGunits(); Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D c = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); string type = ""; string zoom = ""; double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) oVP.FocalDistance = 1; if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { type = "OrthogonalCamera"; zoom = "ViewToWorldScale"; // zoomValue = oVP.VerticalExtentAtFocalDistance / 2 / _ftConversion; double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / up.Length; } else // it is a perspective view { type = "PerspectiveCamera"; zoom = "FieldOfView"; zoomValue = oVP.FocalDistance; } XDocument v = new XDocument( new XElement("VisualizationInfo", new XElement("Components"), new XElement(type, new XElement("CameraViewPoint", new XElement("X", c.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", c.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", c.Z.ToString(CultureInfo.InvariantCulture))), new XElement("CameraDirection", new XElement("X", vi.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", vi.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", vi.Z.ToString(CultureInfo.InvariantCulture))), new XElement("CameraUpVector", new XElement("X", up.X.ToString(CultureInfo.InvariantCulture)), new XElement("Y", up.Y.ToString(CultureInfo.InvariantCulture)), new XElement("Z", up.Z.ToString(CultureInfo.InvariantCulture))), new XElement(zoom, zoomValue.ToString(CultureInfo.InvariantCulture))))); try { //COMPONENTS PART if (_elemCheck == 0)//visible (0) elementList = oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList<ModelItem>(); if (null != elementList && elementList.Any() && _elemCheck != 2) //not if none (2) { string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < elementList.Count(); i++) { string ifcguid = IfcGuid.ToIfcGuid(elementList.ElementAt(i).InstanceGuid).ToString(); v.Element("VisualizationInfo").Element("Components").Add( new XElement("Component", new XAttribute("IfcGuid", ifcguid), new XElement("OriginatingSystem", appname), new XElement("AuthoringToolId", ""))); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return v; }
private VisualizationInfo generateViewpoint(Viewpoint oVP, int elemCheck) { double units = GetGunits(); VisualizationInfo v = new VisualizationInfo(); try { Vector3D vi = getViewDir(oVP); Vector3D up = getViewUp(oVP); Point3D center = new Point3D(oVP.Position.X / units, oVP.Position.Y / units, oVP.Position.Z / units); double zoomValue = 1; oVP = oVP.CreateCopy(); if (!oVP.HasFocalDistance) { oVP.FocalDistance = 1; } if (oVP.Projection == ViewpointProjection.Orthographic) //IS ORTHO { double dist = oVP.VerticalExtentAtFocalDistance / 2 / units; zoomValue = 3.125 * dist / (up.Length * 1.25); v.OrthogonalCamera = new OrthogonalCamera(); v.OrthogonalCamera.CameraViewPoint.X = center.X; v.OrthogonalCamera.CameraViewPoint.Y = center.Y; v.OrthogonalCamera.CameraViewPoint.Z = center.Z; v.OrthogonalCamera.CameraUpVector.X = up.X; v.OrthogonalCamera.CameraUpVector.Y = up.Y; v.OrthogonalCamera.CameraUpVector.Z = up.Z; v.OrthogonalCamera.CameraDirection.X = vi.X; v.OrthogonalCamera.CameraDirection.Y = vi.Y; v.OrthogonalCamera.CameraDirection.Z = vi.Z; v.OrthogonalCamera.ViewToWorldScale = zoomValue; } else // it is a perspective view { zoomValue = oVP.FocalDistance; v.PerspectiveCamera = new PerspectiveCamera(); v.PerspectiveCamera.CameraViewPoint.X = center.X; v.PerspectiveCamera.CameraViewPoint.Y = center.Y; v.PerspectiveCamera.CameraViewPoint.Z = center.Z; v.PerspectiveCamera.CameraUpVector.X = up.X; v.PerspectiveCamera.CameraUpVector.Y = up.Y; v.PerspectiveCamera.CameraUpVector.Z = up.Z; v.PerspectiveCamera.CameraDirection.X = vi.X; v.PerspectiveCamera.CameraDirection.Y = vi.Y; v.PerspectiveCamera.CameraDirection.Z = vi.Z; v.PerspectiveCamera.FieldOfView = zoomValue; } if (elemCheck == 0)//visible (0) { _elementList = _oDoc.Models.First.RootItem.DescendantsAndSelf.Where(o => o.InstanceGuid != Guid.Empty && ChechHidden(o.AncestorsAndSelf) && o.FindFirstGeometry() != null && !o.FindFirstGeometry().Item.IsHidden).ToList <ModelItem>(); } if (null != _elementList && _elementList.Any() && elemCheck != 2)//not if none (2) { v.Components = new Data.Component[_elementList.Count]; string appname = Autodesk.Navisworks.Api.Application.Title; for (var i = 0; i < _elementList.Count; i++) { string ifcguid = IfcGuid.ToIfcGuid(_elementList.ElementAt(i).InstanceGuid).ToString(); v.Components[i] = new Case.IssueTracker.Data.Component(appname, "", ifcguid); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(v); }