diff --git a/PutTowerPosition/cmd.cs b/PutTowerPosition/cmd.cs index da3db12..61dc2f2 100644 --- a/PutTowerPosition/cmd.cs +++ b/PutTowerPosition/cmd.cs @@ -93,8 +93,15 @@ namespace PutTowerPosition { DBText latestTowerName = acTrans.GetObject(tower.name, OpenMode.ForWrite) as DBText; DBPoint latestTowerPoint = acTrans.GetObject(tower.point, OpenMode.ForWrite) as DBPoint; - latestTowerName.Erase(); - latestTowerPoint.Erase(); + if (latestTowerName != null) + { + latestTowerName.Erase(); + } + if (latestTowerPoint != null) + { + latestTowerPoint.Erase(); + } + } latestTowerList.Clear(); @@ -308,7 +315,10 @@ namespace PutTowerPosition } string norm_line; norm_line = Regex.Replace(line, @"\s+", ","); - norm_line = norm_line.Substring(1); + if (norm_line.StartsWith(",")) + { + norm_line = norm_line.Substring(1); + } string[] sep = norm_line.Split(','); string towerName = sep[0]; if (has_tower.ContainsKey(towerName))