private void CollectProjectLocaiton() { try { ProjectLocationSet locationSet = m_doc.ProjectLocations; ProjectLocationSetIterator iter = locationSet.ForwardIterator(); while (iter.MoveNext()) { ProjectLocation location = iter.Current as ProjectLocation; ProjectLocationProperties plp = new ProjectLocationProperties(location); projectLocations.Add(plp); } comboBoxSite1.ItemsSource = null; comboBoxSite1.ItemsSource = projectLocations; comboBoxSite2.ItemsSource = null; comboBoxSite2.ItemsSource = projectLocations; if (projectLocations.Count > 0) { comboBoxSite1.SelectedIndex = 0; comboBoxSite2.SelectedIndex = 0; } } catch (Exception ex) { string message = ex.Message; } }
/// <summary> /// get view orientation if project north is rotated /// </summary> /// <param name="doc"></param> /// <returns>Angle between veiw and project</returns> public static double GetDocNorthOffset(Document doc) { ProjectLocationSet projLocationSet = doc.ProjectLocations; return(doc.ProjectLocations .Cast <ProjectLocation>() .Where(loc => loc.Name == "Internal") .Select(loc => loc.GetProjectPosition(XYZ.Zero)) .Select(position => Math.Round(Radians2Degrees(position.Angle), 3)) .FirstOrDefault()); }
/// <summary> /// duplicate a new project location /// </summary> /// <param name="locationName">old location name</param> /// <param name="newLocationName">new location name</param> public void DuplicateLocation(string locationName, string newLocationName) { ProjectLocationSet locationSet = m_application.ActiveUIDocument.Document.ProjectLocations; foreach (ProjectLocation projectLocation in locationSet) { if (projectLocation.Name == locationName || projectLocation.Name + " (current)" == locationName) { //duplicate a new project location projectLocation.Duplicate(newLocationName); break; } } }
/// <summary> /// change the current project location /// </summary> /// <param name="locationName"></param> public void ChangeCurrentLocation(string locationName) { ProjectLocationSet locations = m_application.ActiveUIDocument.Document.ProjectLocations; foreach (ProjectLocation projectLocation in locations) { //find the project location which is selected by user and //set it to the current projecte location if (projectLocation.Name == locationName) { m_application.ActiveUIDocument.Document.ActiveProjectLocation = projectLocation; m_currentLocationName = locationName; break; } } }
/// <summary> /// get the information of all the project locations associated with this project /// </summary> public void GetLocationData() { m_locationnames.Clear(); ProjectLocation currentLocation = m_application.ActiveUIDocument.Document.ActiveProjectLocation; //get the current location name m_currentLocationName = currentLocation.Name; //Retrieve all the project locations associated with this project ProjectLocationSet locations = m_application.ActiveUIDocument.Document.ProjectLocations; ProjectLocationSetIterator iter = locations.ForwardIterator(); iter.Reset(); while (iter.MoveNext()) { ProjectLocation locationTransform = iter.Current as ProjectLocation; string transformName = locationTransform.Name; m_locationnames.Add(transformName); //add the location's name to the list } }
/// <summary> /// get the offset values of the project position /// </summary> /// <param name="locationName"></param> public void GetOffset(string locationName) { ProjectLocationSet locationSet = m_application.ActiveUIDocument.Document.ProjectLocations; foreach (ProjectLocation projectLocation in locationSet) { if (projectLocation.Name == locationName || projectLocation.Name + " (current)" == locationName) { Autodesk.Revit.DB.XYZ origin = new Autodesk.Revit.DB.XYZ(0, 0, 0); //get the project position ProjectPosition pp = projectLocation.get_ProjectPosition(origin); m_angle = (pp.Angle /= Modulus); //convert to unit degree m_eastWest = pp.EastWest; //East to West offset m_northSouth = pp.NorthSouth; //north to south offset m_elevation = pp.Elevation; //Elevation above ground level break; } } this.ChangePrecision(); }
/// <summary> /// change the offset value for the project position /// </summary> /// <param name="locationName">location name</param> /// <param name="newAngle">angle from true north</param> /// <param name="newEast">East to West offset</param> /// <param name="newNorth">north to south offset</param> /// <param name="newElevation">Elevation above ground level</param> public void EditPosition(string locationName, double newAngle, double newEast, double newNorth, double newElevation) { ProjectLocationSet locationSet = m_application.ActiveUIDocument.Document.ProjectLocations; foreach (ProjectLocation location in locationSet) { if (location.Name == locationName || location.Name + " (current)" == locationName) { //get the project position Autodesk.Revit.DB.XYZ origin = new Autodesk.Revit.DB.XYZ(0, 0, 0); ProjectPosition projectPosition = location.get_ProjectPosition(origin); //change the offset value of the project position projectPosition.Angle = newAngle * Modulus; //convert the unit projectPosition.EastWest = newEast; projectPosition.NorthSouth = newNorth; projectPosition.Elevation = newElevation; //set the value of the project position location.set_ProjectPosition(origin, projectPosition); } } }