/// <summary> /// initialize cities /// </summary> /// <param name="cities"></param> /// <returns></returns> private bool InitCities(CitySet cities) { if (null == cities) { return(false); } //add all element of CitySet cities to List m_cities CitySetIterator iter = cities.ForwardIterator(); iter.Reset(); for (; iter.MoveNext();) { City city = iter.Current as City; if (null == city) { continue; } m_citiesName.Add(city.Name); m_citiesInfo.Add(new CityInfo(city.Latitude, city.Longitude, city.TimeZone, city.Name)); } //sort list according to first char of element m_citiesName.Sort(); return(true); }
void SetSiteLocationToCity(Document doc) { CitySet cities = doc.Application.Cities; int nCount = cities.Size; try { CitySetIterator item = cities.ForwardIterator(); while (item != null) { item.MoveNext(); City city = item.Current as City; if (city.Name.Contains("中国") || city.Name.Contains("China")) { Transaction transaction = new Transaction(doc, "Create Wall"); transaction.Start(); ProjectLocation projectLocation = doc.ActiveProjectLocation; //SiteLocation site = projectLocation.SiteLocation; // 2017 SiteLocation site = projectLocation.GetSiteLocation(); // 2018 // site.PlaceName = city.Name; site.Latitude = city.Latitude; // latitude information site.Longitude = city.Longitude; // longitude information site.TimeZone = city.TimeZone; // TimeZone information transaction.Commit(); break; } } } catch (Exception ret) { Debug.Print(ret.Message); } }
/// <summary> /// initialize cities /// </summary> /// <param name="cities"></param> /// <returns></returns> private bool InitCities(CitySet cities) { if (null == cities) { return false; } //add all element of CitySet cities to List m_cities CitySetIterator iter = cities.ForwardIterator(); iter.Reset(); for (; iter.MoveNext(); ) { City city= iter.Current as City; if (null == city) { continue; } m_citiesName.Add(city.Name); m_citiesInfo.Add(new CityInfo(city.Latitude, city.Longitude, city.TimeZone, city.Name)); } //sort list according to first char of element m_citiesName.Sort(); return true; }