添加塔号
This commit is contained in:
parent
a109aa6836
commit
d63983fa43
|
|
@ -33,6 +33,14 @@ namespace PutTowerPosition
|
|||
public double X;
|
||||
public double Y;
|
||||
};
|
||||
|
||||
struct Position
|
||||
{
|
||||
public double X;
|
||||
public double Y;
|
||||
public string towerName;
|
||||
}
|
||||
|
||||
[CommandMethod("ptp", CommandFlags.Session)]
|
||||
public static void PutTowerPositionCmd()
|
||||
{
|
||||
|
|
@ -66,9 +74,9 @@ namespace PutTowerPosition
|
|||
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
|
||||
|
||||
OpenMode.ForWrite) as BlockTableRecord;
|
||||
|
||||
Point2D[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
||||
foreach (Point2D point in cordinationList)
|
||||
|
||||
Position[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
||||
foreach (Position point in cordinationList)
|
||||
{
|
||||
DBPoint dbPoint = new DBPoint(new Point3d(point.Y, point.X, 0));
|
||||
dbPoint.Layer = "TW";
|
||||
|
|
@ -76,8 +84,14 @@ namespace PutTowerPosition
|
|||
acTrans.AddNewlyCreatedDBObject(dbPoint, true);
|
||||
acCurDb.Pdmode = 35;
|
||||
acCurDb.Pdsize = 15;
|
||||
|
||||
//break;
|
||||
DBText dbTowerName=new DBText();
|
||||
dbTowerName.TextString = point.towerName;
|
||||
Point3d towerNamePoint = new Point3d(point.Y + 20, point.X + 20,0);
|
||||
dbTowerName.Position = towerNamePoint;
|
||||
dbTowerName.Layer = "TW";
|
||||
dbTowerName.Height = 40;
|
||||
acBlkTblRec.AppendEntity(dbTowerName);
|
||||
acTrans.AddNewlyCreatedDBObject(dbTowerName,true);
|
||||
}
|
||||
acTrans.Commit();
|
||||
}
|
||||
|
|
@ -292,9 +306,9 @@ namespace PutTowerPosition
|
|||
return spanList;
|
||||
}
|
||||
|
||||
static Point2D[] calTowerXYPostion(Dictionary<string, double[]> cordDic, List<spanStruct> SSpan)
|
||||
static Position[] calTowerXYPostion(Dictionary<string, double[]> cordDic, List<spanStruct> SSpan)
|
||||
{
|
||||
Point2D[] cordinationList = new Point2D[SSpan.Count];
|
||||
Position[] cordinationList = new Position[SSpan.Count];
|
||||
Point2D startPoint;
|
||||
int tensionStart;//耐张段第一基塔位置
|
||||
tensionStart = 0;
|
||||
|
|
@ -302,29 +316,38 @@ namespace PutTowerPosition
|
|||
Point2D endPoint;
|
||||
while (true)
|
||||
{
|
||||
Position startPosition;
|
||||
startPoint.X = cordDic[SSpan[tensionStart].towerName][0];
|
||||
startPoint.Y = cordDic[SSpan[tensionStart].towerName][1];
|
||||
startPosition.towerName = SSpan[tensionStart].towerName;
|
||||
startPosition.X = startPoint.X;
|
||||
startPosition.Y = startPoint.Y;
|
||||
cordinationList[tensionStart] = startPosition;
|
||||
for (int i = tensionStart+1; i < SSpan.Count; i++)
|
||||
{
|
||||
string towerName;
|
||||
towerName = SSpan[i].towerName;
|
||||
if (cordDic.ContainsKey(towerName))
|
||||
string endTowerName;
|
||||
endTowerName = SSpan[i].towerName;
|
||||
if (cordDic.ContainsKey(endTowerName))
|
||||
{
|
||||
endPoint.X = cordDic[towerName][0];
|
||||
endPoint.Y = cordDic[towerName][1];
|
||||
cordinationList[tensionStart] = startPoint;
|
||||
endPoint.X = cordDic[endTowerName][0];
|
||||
endPoint.Y = cordDic[endTowerName][1];
|
||||
double mileageInTension=0;//耐张段中的里程
|
||||
for (int j = tensionStart + 1; j < i; j++)
|
||||
{
|
||||
Point2D suspensionTowerPostion;
|
||||
Position suspensionTowerPostion;
|
||||
double tensionLength;//耐张段长度
|
||||
tensionLength = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
|
||||
mileageInTension += SSpan[j].span;
|
||||
suspensionTowerPostion.X = startPoint.X + (endPoint.X - startPoint.X) / tensionLength * mileageInTension;
|
||||
suspensionTowerPostion.Y = startPoint.Y + (endPoint.Y - startPoint.Y) / tensionLength * mileageInTension;
|
||||
suspensionTowerPostion.towerName = SSpan[j].towerName;
|
||||
cordinationList[j]=suspensionTowerPostion;
|
||||
}
|
||||
cordinationList[i] = endPoint;
|
||||
Position endPosition;
|
||||
endPosition.X = endPoint.X;
|
||||
endPosition.Y = endPoint.Y;
|
||||
endPosition.towerName = endTowerName;
|
||||
cordinationList[i] = endPosition;
|
||||
tensionStart = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue