增加自动删除最后一次塔位功能。

Signed-off-by: facat <facat@facat.com>
This commit is contained in:
facat 2020-05-21 09:09:08 +08:00
parent d63983fa43
commit 736b6ff2f8
1 changed files with 29 additions and 1 deletions

View File

@ -41,9 +41,21 @@ namespace PutTowerPosition
public string towerName;
}
struct Tower
{
public ObjectId point;
public ObjectId name;
}
private static List<Tower> latestTowerList = null;//记录最近一次加点的ID。
[CommandMethod("ptp", CommandFlags.Session)]
public static void PutTowerPositionCmd()
{
if (latestTowerList == null)
{
latestTowerList = new List<Tower>();
}
Gui gui = new Gui();
gui.Show();
}
@ -74,7 +86,19 @@ namespace PutTowerPosition
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
//先删除最后一次的塔位
if (latestTowerList != null)
{
foreach(Tower tower in latestTowerList)
{
DBText latestTowerName = acTrans.GetObject(tower.name, OpenMode.ForWrite) as DBText;
DBPoint latestTowerPoint = acTrans.GetObject(tower.point, OpenMode.ForWrite) as DBPoint;
latestTowerName.Erase();
latestTowerPoint.Erase();
}
latestTowerList.Clear();
}
Position[] cordinationList = calTowerXYPostion(cordDic, spanList);
foreach (Position point in cordinationList)
{
@ -92,6 +116,10 @@ namespace PutTowerPosition
dbTowerName.Height = 40;
acBlkTblRec.AppendEntity(dbTowerName);
acTrans.AddNewlyCreatedDBObject(dbTowerName,true);
Tower latestTower;
latestTower.name = dbTowerName.ObjectId;
latestTower.point = dbPoint.ObjectId;
latestTowerList.Add(latestTower);
}
acTrans.Commit();
}