public static void Draw(DxfModel dxf, DLocation DLocation) { Point3D v1 = new Point3D(DLocation.X - 0.5d, DLocation.Y - 1.0d, DLocation.Z); Point3D v2 = new Point3D(DLocation.X + 0.5d, DLocation.Y + 1.0d, DLocation.Z); DxfLine DxfLine12 = new DxfLine(v1, v2); dxf.Entities.Add(DxfLine12); }
public static void Draw(DxfModel dxf, DLocation DLocation) { Point3D v1 = new Point3D(DLocation.X - 2.0d, DLocation.Y + 4.0d, DLocation.Z); Point3D v2 = new Point3D(DLocation.X + 2.0d, DLocation.Y + 4.0d, DLocation.Z); Point3D v0=new Point3D(DLocation.X,DLocation.Y,DLocation.Z); DxfLine DxfLine10 = new DxfLine(v0, v1); dxf.Entities.Add(DxfLine10); DxfLine DxfLine20 = new DxfLine(v0, v2); dxf.Entities.Add(DxfLine20); }
public static void Draw(DxfModel dxf, DLocation DLocation,List<string> configurations) { Point3D confStrPoint3D = new Point3D(DLocation.X + 5.0d, DLocation.Y - 5.0d, DLocation.Z); DxfText DxfText1 = new DxfText("CONFIGURATION: NOTE: Assembly drawing for overall dimesions, actual door size and handle position may vary", confStrPoint3D, 2.0d); //DxfText1.Layer.Color.Index = 8; dxf.Entities.Add(DxfText1); for (int i = 0; i < configurations.Count(); i++) { Point3D confPoint3D = new Point3D(DLocation.X+10.0d, DLocation.Y - 5.0d * (i + 2), DLocation.Z); DxfText DxfText = new DxfText(configurations[i], confPoint3D, 2.0d); dxf.Entities.Add(DxfText); } }
/// <summary> /// 风向绘制 /// </summary> /// <param name="dxf"></param> /// <param name="DLocation"></param> /// <param name="isRight"></param> public static void Draw(DxfModel dxf, DLocation DLocation, bool isRight) { double factor = 0.5f; Point3D v1 = new Point3D(); Point3D v2 = new Point3D(); Point3D v3 = new Point3D(); Point3D v4 = new Point3D(); Point3D v5 = new Point3D(); Point3D v6 = new Point3D(); Point3D v7 = new Point3D(); if (isRight) { v1 = new Point3D(10*factor + DLocation.X, DLocation.Y, DLocation.Z); v2 = new Point3D(DLocation.X, DLocation.Y + 10 * factor, DLocation.Z); v3 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 10 * factor, DLocation.Z); v4 = new Point3D(DLocation.X + 20 * factor, DLocation.Y + 15 * factor, DLocation.Z); v5 = new Point3D(DLocation.X, DLocation.Y + 20 * factor, DLocation.Z); v6 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 20 * factor, DLocation.Z); v7 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 30 * factor, DLocation.Z); } else { v1 = new Point3D(10 * factor + DLocation.X, DLocation.Y, DLocation.Z); v2 = new Point3D(DLocation.X + 20 * factor, DLocation.Y + 10 * factor, DLocation.Z); v3 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 10 * factor, DLocation.Z); v4 = new Point3D(DLocation.X, DLocation.Y + 15 * factor, DLocation.Z); v5 = new Point3D(DLocation.X + 20 * factor, DLocation.Y + 20 * factor, DLocation.Z); v6 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 20 * factor, DLocation.Z); v7 = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 30 * factor, DLocation.Z); } DxfLine DxfLine23 = new DxfLine(v2, v3); dxf.Entities.Add(DxfLine23); DxfLine DxfLine56 = new DxfLine(v5, v6); dxf.Entities.Add(DxfLine56); DxfLine DxfLine14 = new DxfLine(v1, v4); dxf.Entities.Add(DxfLine14); DxfLine DxfLine74 = new DxfLine(v7, v4); dxf.Entities.Add(DxfLine74); DxfLine DxfLine25 = new DxfLine(v2, v5); dxf.Entities.Add(DxfLine25); DxfLine DxfLine71 = new DxfLine(v7, v1); dxf.Entities.Add(DxfLine71); }
//画标注 public static void writeDimension(DxfModel doc,DLocation firstDLocation,DLocation secondDLocation,double DxfTextHeight,double DxfTextWidth,double dimensionHeight,string dimensionDirection) { DxfDimension.Aligned dimension = new DxfDimension.Aligned(doc.DefaultDimensionStyle); dimension.ExtensionLine1StartPoint = new Point3D(firstDLocation.X, firstDLocation.Y, firstDLocation.Z); dimension.ExtensionLine2StartPoint = new Point3D(secondDLocation.X, secondDLocation.Y, secondDLocation.Z); if (dimensionDirection.Equals("top")) dimension.DimensionLineLocation = new Point3D((firstDLocation.X + secondDLocation.X) / 2, firstDLocation.Y + dimensionHeight, firstDLocation.Z); else if (dimensionDirection.Equals("bottom")) dimension.DimensionLineLocation = new Point3D((firstDLocation.X + secondDLocation.X) / 2, firstDLocation.Y - dimensionHeight, firstDLocation.Z); else if (dimensionDirection.Equals("left")) dimension.DimensionLineLocation = new Point3D(firstDLocation.X - dimensionHeight, (firstDLocation.Y + secondDLocation.Y) / 2, firstDLocation.Z); else if (dimensionDirection.Equals("right")) dimension.DimensionLineLocation = new Point3D(firstDLocation.X + dimensionHeight, (firstDLocation.Y + secondDLocation.Y) / 2, firstDLocation.Z); dimension.DimensionStyleOverrides.TextHeight = 1d; dimension.DimensionStyleOverrides.ArrowSize = 1d; dimension.Text = getDimensionText(dimension); doc.Entities.Add(dimension); }
//画单门,包括下栅栏,包括2个左门闩,2个右把手 public static void writeBottoFanSingleDoor(DxfModel dxf, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space, double barHeight, double barWidth, string upOrDownLayer) { //画两个门闩 writeDoorBarRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); double downLeftX=DLocation.X+outer_mid_space-barWidth/2+(outer_in_space-outer_mid_space)/2; double downLeftY=DLocation.Y + height / 4; writeRepresentDoorBarRectangle(dxf, new DLocation(downLeftX,downLeftY , DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); double upLeftX = downLeftX; double upLeftY = DLocation.Y + 3 * height / 4 - barHeight; writeRepresentDoorBarRectangle(dxf, new DLocation(upLeftX,upLeftY , DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); //画门把手 Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + height / 4, DLocation.Z)); //画门把手 Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + height / 4, DLocation.Z)); //下面位置栅栏 Fan.Draw(dxf, new Point3D(DLocation.X + width / 6, DLocation.Y + height / 7, DLocation.Z), new Point3D(DLocation.X + width * 4 / 5, DLocation.Y + height / 7, DLocation.Z), 0); }
/// <summary> /// 绘制垂直风向箭头 /// </summary> /// <param name="dxf"></param> /// <param name="DLocation"></param> public static void DrawVerticalWind(DxfModel dxf,DLocation DLocation) { double factor = 0.5f; Point3D v1 = new Point3D(); Point3D v2 = new Point3D(); Point3D v3 = new Point3D(); Point3D v4 = new Point3D(); Point3D v5 = new Point3D(); Point3D v6 = new Point3D(); Point3D v7 = new Point3D(); v1 = new Point3D(DLocation.X, DLocation.Y, DLocation.Z); v2 = new Point3D(DLocation.X+10*factor, DLocation.Y, DLocation.Z); v3 = new Point3D(DLocation.X - 10 * factor, DLocation.Y + 10 * factor, DLocation.Z); v4 = new Point3D(DLocation.X, DLocation.Y + 10 * factor, DLocation.Z); v5 = new Point3D(DLocation.X+10*factor, DLocation.Y + 10* factor, DLocation.Z); v6 = new Point3D(DLocation.X + 20 * factor, DLocation.Y + 10 * factor, DLocation.Z); v7 = new Point3D(DLocation.X +5 * factor, DLocation.Y + 20 * factor, DLocation.Z); DxfLine DxfLine23 = new DxfLine(v1, v2); dxf.Entities.Add(DxfLine23); DxfLine DxfLine56 = new DxfLine(v3, v6); dxf.Entities.Add(DxfLine56); DxfLine DxfLine14 = new DxfLine(v1, v4); dxf.Entities.Add(DxfLine14); DxfLine DxfLine74 = new DxfLine(v2, v5); dxf.Entities.Add(DxfLine74); DxfLine DxfLine25 = new DxfLine(v3, v7); dxf.Entities.Add(DxfLine25); DxfLine DxfLine71 = new DxfLine(v6, v7); dxf.Entities.Add(DxfLine71); }
/// <summary> /// 获取entity右下角坐标(已经计算好的,实体组件计算) /// </summary> /// <param name="pList"></param> /// <param name="relativeStartLocation"></param> /// <returns></returns> public static DLocation getNextStartLocation(List<Point3D> pList) { double minY = Double.MaxValue; double minX = Double.MinValue; DLocation nextStartLocation=new DLocation(); for (int i = 0; i < pList.Count;i++ ) { if(minY>=pList[i].Y){ minY = pList[i].Y; if (minX <= pList[i].X) { minX = pList[i].X; nextStartLocation.X = pList[i].X; nextStartLocation.Y = pList[i].Y; nextStartLocation.Z = pList[i].Z; } } } return nextStartLocation; }
/// <summary> /// 计算最后一个元素右上角坐标 /// </summary> /// <param name="pList"></param> /// <returns></returns> public static DLocation getRightTopLocation(List<Point3D> pList) { double minY = Double.MinValue; double minX = Double.MinValue; DLocation rightTopLocation = new DLocation(); for (int i = 0; i < pList.Count; i++) { if (minY <= pList[i].Y) { minY = pList[i].Y; if (minX <= pList[i].X) { minX = pList[i].X; rightTopLocation.X = pList[i].X; rightTopLocation.Y = pList[i].Y; rightTopLocation.Z = pList[i].Z; } } } return rightTopLocation; }
/// <summary> /// 获得Frame的左下角坐标 /// </summary> /// <param name="sourceModel"></param> /// <returns></returns> public static DLocation getFrameLeftDownLocation(DxfModel sourceModel) { DLocation dLocation = new DLocation(0, 0, 0); foreach(DxfEntity entity in sourceModel.Entities) { if (entity.EntityType.Equals("LWPOLYLINE")) { DxfLwPolyline dxfLwPolyline=(DxfLwPolyline)entity; DxfLwPolyline.VertexCollection vc = dxfLwPolyline.Vertices; for (int i = 0; i < vc.Count;i++ ) { if (i == 0) { dLocation.X = vc[i].Position.X; dLocation.Y = vc[i].Position.Y; } if(dLocation.X>=vc[i].Position.X&&dLocation.Y>=vc[i].Position.Y){ dLocation.X = vc[i].Position.X; dLocation.Y = vc[i].Position.Y; } } break; } } return dLocation; }
/// <summary> /// 获得最大的X坐标是为了做标注使用 /// </summary> /// <param name="pList"></param> /// <returns></returns> public static DLocation getLargestXLocation(List<Point3D> pList) { double minX = Double.MinValue; DLocation largeLocation = new DLocation(); for (int i = 0; i < pList.Count; i++) { if (minX <= pList[i].X) { minX = pList[i].X; largeLocation.X = pList[i].X; largeLocation.Y = pList[i].Y; largeLocation.Z = pList[i].Z; } } return largeLocation; }
/// <summary> /// 单门有两门闩,和俩个把手的 /// </summary> /// <param name="doc"></param> /// <param name="DLocation"></param> /// <param name="DxfText"></param> /// <param name="height"></param> /// <param name="width"></param> /// <param name="outer_mid_space"></param> /// <param name="outer_in_space"></param> /// <param name="barHeight"></param> /// <param name="barWidth"></param> public static void writeWholeSingleTwoBarAndTwoCirle(DxfModel doc, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space,double barHeight,double barWidth) { DxfLine outerLeftDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 - width / 14, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width / 2 - width / 14, DLocation.Y + height - outer_mid_space, DLocation.Z)); DxfLine inLeftDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 - width / 14 + 0.5f, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + width / 2 - width / 14 + 0.5f, DLocation.Y + height - outer_in_space, DLocation.Z)); DxfLine inDownRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + height / 4, DLocation.Z)); DxfLine inMidRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); DxfLine inUpRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + 3 * height / 4, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14, DLocation.Y + height - outer_in_space, DLocation.Z)); DxfLine outerDownRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + height / 4, DLocation.Z)); DxfLine outerMidRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); DxfLine outerUpRightDxfLine = new DxfLine(new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + 3 * height / 4, DLocation.Z), new Point3D(DLocation.X + width / 2 + width / 14 + 0.5f, DLocation.Y + height - outer_in_space, DLocation.Z)); doc.Entities.Add(outerLeftDxfLine); doc.Entities.Add(inLeftDxfLine); //左边的门闩小矩形 double downLeftX = DLocation.X + outer_mid_space - barWidth / 2 + (outer_in_space - outer_mid_space) / 2; double downLeftY = DLocation.Y + height / 4; writeRepresentDoorBarRectangle(doc, new DLocation(downLeftX, downLeftY, DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); double upLeftX = downLeftX; double upLeftY = DLocation.Y + 3 * height / 4 - barHeight; writeRepresentDoorBarRectangle(doc, new DLocation(upLeftX, upLeftY, DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); //两个个小圈 //底部 writeCirle(doc, new DLocation(DLocation.X + width-2*outer_in_space, DLocation.Y + 2 * outer_in_space, DLocation.Z), (outer_in_space - outer_mid_space) / 2); //顶部 writeCirle(doc, new DLocation(DLocation.X + width-2*outer_in_space, DLocation.Y + height - 2 * outer_in_space, DLocation.Z), (outer_in_space - outer_mid_space) / 2); //画门把手 Handle.Draw(doc, new DLocation(DLocation.X + width / 4+outer_mid_space/2, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); Handle.Draw(doc, new DLocation(DLocation.X + width / 4 + outer_mid_space/2, DLocation.Y + height / 4, DLocation.Z)); writeDoorBarRectangle(doc, DLocation, DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); }
private static DLocation topViewRightLocation; //下一个坐标 #endregion Fields #region Methods /// <summary> /// 获取计算好的entity /// </summary> /// <param name="entity"></param> /// <param name="location"></param> /// <param name="relativeStartLocation"></param> /// <returns></returns> public static DxfEntity getCaculateLocationEntity(DxfEntity entity,DLocation location,DLocation relativeStartLocation) { switch (entity.EntityType){ case "LINE": { DxfLine dxfLine = (DxfLine)entity; double lineLenght = dxfLine.End.X - dxfLine.Start.X; double lineHeight=dxfLine.End.Y-dxfLine.Start.Y; dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X, dxfLine.Start.Y - relativeStartLocation.Y + location.Y, location.Z); dxfLine.End = new Point3D(dxfLine.Start.X+lineLenght,dxfLine.Start.Y+lineHeight,location.Z); //只需要将Line的坐标加入,每个图形底部都存在Line if (Math.Round(dxfLine.Start.Y*10)/10 == Math.Round(dxfLine.End.Y*10)/10||Math.Round(dxfLine.Start.X*10)/10==Math.Round(dxfLine.End.X*10)/10) { positionList.Add(dxfLine.Start); positionList.Add(dxfLine.End); } return dxfLine; }; case "ARC": { DxfArc dxfArc = (DxfArc)entity; int flag = 0; if (dxfArc.Center.X < 0) { flag = 1; } dxfArc.Center = new Point3D(Math.Abs(dxfArc.Center.X)-relativeStartLocation.X+location.X,dxfArc.Center.Y-relativeStartLocation.Y+location.Y,dxfArc.Center.Z); if (flag == 1) { dxfArc.Center = new Point3D(0 - dxfArc.Center.X, dxfArc.Center.Y, dxfArc.Center.Z); } return dxfArc; }; case "CIRCLE": { DxfCircle dxfCircle =(DxfCircle)entity; dxfCircle.Center = new Point3D(dxfCircle.Center.X-relativeStartLocation.X+location.X,dxfCircle.Center.Y-relativeStartLocation.Y+location.Y,dxfCircle.Center.Z); return dxfCircle; } case "POINT": { DxfPoint dxfPoint = (DxfPoint)entity; dxfPoint.Position = new Point3D(dxfPoint.Position.X - relativeStartLocation.X + location.X, dxfPoint.Position.Y - relativeStartLocation.Y + location.Y, dxfPoint.Position.Z); return dxfPoint; } case "TEXT": { DxfText dxfText =(DxfText)entity; dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X-relativeStartLocation.X+location.X,dxfText.AlignmentPoint1.Y-relativeStartLocation.Y+location.Y,dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; return dxfText; } case "ELLIPSE": { DxfEllipse dxfEllipse = (DxfEllipse)entity; dxfEllipse.Center = new Point3D(dxfEllipse.Center.X - relativeStartLocation.X + location.X, dxfEllipse.Center.Y - relativeStartLocation.Y + location.Y, dxfEllipse.Center.Z); return dxfEllipse; } case "LWPOLYLINE": { DxfLwPolyline dxfLwPolyLine = (DxfLwPolyline)entity; int len = dxfLwPolyLine.Vertices.Count; for (int i = 0; i < len; i++) { dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y); } return dxfLwPolyLine; } case "DIMENSION": { DxfDimension.Aligned dxfDimension =(DxfDimension.Aligned)entity; DxfDimension.Aligned tempDemsion = new DxfDimension.Aligned(testModel.DefaultDimensionStyle); dxfDimension.ExtensionLine1StartPoint = new Point3D(dxfDimension.ExtensionLine1StartPoint.X-relativeStartLocation.X+location.X,dxfDimension.ExtensionLine1StartPoint.Y-relativeStartLocation.Y+location.Y,location.Z); dxfDimension.ExtensionLine2StartPoint = new Point3D(dxfDimension.ExtensionLine2StartPoint.X-relativeStartLocation.X+location.X,dxfDimension.ExtensionLine2StartPoint.Y-relativeStartLocation.Y+location.Y,location.Z); // dxfDimension.DimensionLineLocation = new Point3D(dxfDimension.DimensionLineLocation.X-relativeStartLocation.X+location.X,dxfDimension.DimensionLineLocation.Y-relativeStartLocation.Y+location.Y,dxfDimension.DimensionLineLocation.Z); tempDemsion.ExtensionLine1StartPoint = dxfDimension.ExtensionLine1StartPoint; tempDemsion.ExtensionLine2StartPoint = dxfDimension.ExtensionLine2StartPoint; tempDemsion.Color = dxfDimension.Color; tempDemsion.DimensionStyleOverrides.TextHeight = 56d; tempDemsion.DimensionStyleOverrides.ArrowSize = 20d; if (Math.Round(dxfDimension.ExtensionLine1StartPoint.X * 100) / 100 == Math.Round(dxfDimension.ExtensionLine2StartPoint.X * 100) / 100) { tempDemsion.Text = "" + Convert.ToInt32(Math.Abs(dxfDimension.ExtensionLine1StartPoint.Y - dxfDimension.ExtensionLine2StartPoint.Y) + 0.5); } else { tempDemsion.Text = "" + Convert.ToInt32(Math.Abs(dxfDimension.ExtensionLine1StartPoint.X - dxfDimension.ExtensionLine2StartPoint.X) + 0.5); } tempDemsion.DimensionLineLocation = new Point3D(dxfDimension.DimensionLineLocation.X - relativeStartLocation.X + location.X, dxfDimension.DimensionLineLocation.Y - relativeStartLocation.Y + location.Y, dxfDimension.DimensionLineLocation.Z); return tempDemsion; } case "INSERT": { DxfInsert dxfInsert = (DxfInsert)entity; //可行,但是存在很多点点 dxfInsert.InsertionPoint = new Point3D(dxfInsert.InsertionPoint.X - relativeStartLocation.X + location.X, dxfInsert.InsertionPoint.Y - relativeStartLocation.Y + location.Y, dxfInsert.InsertionPoint.Z); return dxfInsert; } case "HATCH": { DxfHatch dxfHatch = (DxfHatch)entity; int len = dxfHatch.BoundaryPaths.Count; for (int i = 0; i < len; i++) { int len1 = dxfHatch.BoundaryPaths[i].Edges.Count; for (int j = 0; j < len1;j++ ) { DxfHatch.BoundaryPath.LineEdge lineEdge = (DxfHatch.BoundaryPath.LineEdge)dxfHatch.BoundaryPaths[i].Edges[j]; lineEdge.Start = new Point2D(lineEdge.Start.X-relativeStartLocation.X+location.X,lineEdge.Start.Y-relativeStartLocation.Y+location.Y); lineEdge.End = new Point2D(lineEdge.End.X-relativeStartLocation.X+location.X,lineEdge.End.Y-relativeStartLocation.Y+location.Y); } } return dxfHatch; } default:return entity; } }
public static void puzzle(List<string> dxfFileNameList,List<string> dxfTopViewList,List<TextValue> valueList,string frameName) { DxfModel targetModel=new DxfModel(); testModel = targetModel; targetModel.TextStyles.Add(textStyle); CloneContext cloneContext = new CloneContext(targetModel, ReferenceResolutionType.CloneMissing); for (int i = 0; i < dxfFileNameList.Count;i++ ) { DxfModel sourceModel = DxfReader.Read(dxfFileNameList[i]); //第一个图形作为初始 if (i == 0) { //拼到一个图纸中后,Entity应该参照那个的左下角坐标 location = getRelativeStartLocation(sourceModel); //源图纸中Entity的左下角坐标 relativeStartLocation = getRelativeStartLocation(sourceModel); //保存第一个算好的左下角坐标 firstDimensionLocation = location; foreach (DxfEntity entity in sourceModel.Entities) { DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext); clonedEntity = getCaculateLocationEntity(clonedEntity, location, relativeStartLocation); targetModel.Entities.Add(clonedEntity); } rightLocation = getNextStartLocation(positionList); //记录最后一点坐标 lastDimensionLocation = rightLocation; //清空坐标位置链表 positionList.RemoveAll(name => { return true;}); //花标注 DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle); dxfDimension.ExtensionLine1StartPoint = new Point3D(location.X, location.Y, location.Z); dxfDimension.ExtensionLine2StartPoint = new Point3D(rightLocation.X, rightLocation.Y, rightLocation.Z); dxfDimension.DimensionStyleOverrides.TextHeight = 56d; dxfDimension.DimensionStyleOverrides.ArrowSize = 56d; dxfDimension.Text = getDimensionText(dxfDimension); // dxfDimension.DimensionLineLocation = new Point3D((location.X+rightLocation.X)/2,location.Y-8,location.Z); targetModel.Entities.Add(dxfDimension); } else { location = rightLocation; relativeStartLocation = getRelativeStartLocation(sourceModel); foreach (DxfEntity entity in sourceModel.Entities) { DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext); clonedEntity = getCaculateLocationEntity(clonedEntity, location, relativeStartLocation); targetModel.Entities.Add(clonedEntity); } rightLocation = getNextStartLocation(positionList); lastDimensionLocation = rightLocation; //计算最后一个元素右上角坐标 if (i == dxfFileNameList.Count - 1) { rightTopDimensionLocation = getRightTopLocation(positionList); largestLocation = getLargestXLocation(positionList); } positionList.RemoveAll(name => { return true; }); //花标注 DxfDimension.Aligned dxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle); dxfDimension.ExtensionLine1StartPoint = new Point3D(location.X, location.Y, location.Z); dxfDimension.ExtensionLine2StartPoint = new Point3D(rightLocation.X, rightLocation.Y, rightLocation.Z); dxfDimension.DimensionStyleOverrides.TextHeight = 56d; dxfDimension.DimensionStyleOverrides.ArrowSize = 56d; dxfDimension.Text = getDimensionText(dxfDimension); targetModel.Entities.Add(dxfDimension); } } DxfDimension.Aligned wholeDxfDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle); wholeDxfDimension.ExtensionLine1StartPoint = new Point3D(firstDimensionLocation.X, firstDimensionLocation.Y, firstDimensionLocation.Z); wholeDxfDimension.ExtensionLine2StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z); wholeDxfDimension.DimensionStyleOverrides.TextHeight = 56d; wholeDxfDimension.DimensionStyleOverrides.ArrowSize = 56d; wholeDxfDimension.Text = getDimensionText(wholeDxfDimension); wholeDxfDimension.DimensionLineLocation = new Point3D(firstDimensionLocation.X+lastDimensionLocation.X,firstDimensionLocation.Y-1000,firstDimensionLocation.Z); targetModel.Entities.Add(wholeDxfDimension); DxfDimension.Aligned rightDimension = new DxfDimension.Aligned(targetModel.DefaultDimensionStyle); rightDimension.ExtensionLine1StartPoint = new Point3D(lastDimensionLocation.X, lastDimensionLocation.Y, lastDimensionLocation.Z); rightDimension.ExtensionLine2StartPoint = new Point3D(rightTopDimensionLocation.X, rightTopDimensionLocation.Y, rightTopDimensionLocation.Z); rightDimension.DimensionStyleOverrides.TextHeight = 56d; rightDimension.DimensionStyleOverrides.ArrowSize = 56d; rightDimension.Text = getDimensionText(rightDimension); rightDimension.DimensionLineLocation = new Point3D(largestLocation.X + 200, firstDimensionLocation.Y, firstDimensionLocation.Z); targetModel.Entities.Add(rightDimension); //绘制俯视图 for (int i = 0; i < dxfTopViewList.Count;i++ ) { DxfModel topViewSourceModel = new DxfModel(); topViewSourceModel = DxfReader.Read(dxfTopViewList[i]); if (i == 0) { topViewLocation = new DLocation(firstDimensionLocation.X, rightTopDimensionLocation.Y + RelativeDistance.yTopViewDistance, firstDimensionLocation.Z); topViewRelativeLocation = getTopViewRelativeStartLocation(topViewSourceModel); } else { topViewLocation = topViewRightLocation; DxfModel filterModel = getFilterBottomNotLineDxfModel(topViewSourceModel); topViewRelativeLocation = getTopViewRelativeStartLocation(filterModel); } foreach(DxfEntity entity in topViewSourceModel.Entities) { DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext); clonedEntity = getCaculateLocationEntity(clonedEntity, topViewLocation, topViewRelativeLocation); targetModel.Entities.Add(clonedEntity); } topViewRightLocation = getTopViewNextStartLocation(positionList); positionList.RemoveAll(name=>{return true;}); } // 复制frame框体 DxfModel sourceFrameModel = new DxfModel(); sourceFrameModel = DxfReader.Read(frameName); DLocation frameLeftDownLocation = getFrameLeftDownLocation(sourceFrameModel); frameLastLineX = getFrameLastVerticalLineX(sourceFrameModel); Point2D frameRightPoint2D = getFrameRightPoint(sourceFrameModel); //这里求的是宽度比较,因为Frame的最后位置还没确定,不能单纯的考个别点进行位置大小比较 if ((largestLocation.X-firstDimensionLocation.X+RelativeDistance.xDistance)>= (frameRightPoint2D.X-frameLeftDownLocation.X)) { RelativeDistance.increaseWidth = (largestLocation.X - firstDimensionLocation.X + RelativeDistance.xDistance) - (frameRightPoint2D.X - frameLeftDownLocation.X) + RelativeDistance.xDistance; } else { RelativeDistance.increaseWidth = 0; } foreach (DxfEntity entity in sourceFrameModel.Entities) { DxfEntity clonedEntity = (DxfEntity)entity.Clone(cloneContext); clonedEntity = getFrameEntity(clonedEntity, firstDimensionLocation, frameLeftDownLocation, RelativeDistance.increaseWidth); targetModel.Entities.Add(clonedEntity); } //传递表单数据值 foreach(TextValue textValue in textValueList){ foreach(TextValue transFormValue in valueList){ if (textValue.text.Equals(transFormValue.text)) { DxfText dxfText = new DxfText(); dxfText.Text = transFormValue.value; dxfText.Height = textValue.height; dxfText.Thickness = 0.5d; dxfText.AlignmentPoint1 = new Point3D(textValue.valuePosition.X, textValue.valuePosition.Y, textValue.valuePosition.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; targetModel.Entities.Add(dxfText); } } } cloneContext.ResolveReferences(); DxfWriter.Write("cloneTest.dxf", targetModel); }
//画单门有门闩的矩形框 public static void writeDoorBarRectangle(DxfModel doc, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space,double barHeight,double barWidth) { //最外围矩形 writeOuterDoorRectangle(doc, DLocation, height, width); //中间矩形 DxfLine midBottomDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z)); DxfLine midDownLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height / 4, DLocation.Z)); DxfLine midMidLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); DxfLine midUpLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + 3*height / 4, DLocation.Z), new Point3D(DLocation.X + outer_mid_space, DLocation.Y +height-outer_mid_space, DLocation.Z)); DxfLine midTopDxfLine = new DxfLine(new Point3D(DLocation.X + outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z)); DxfLine midRightDxfLine = new DxfLine(new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + height - outer_mid_space, DLocation.Z), new Point3D(DLocation.X + width - outer_mid_space, DLocation.Y + outer_mid_space, DLocation.Z)); doc.Entities.Add(midBottomDxfLine); doc.Entities.Add(midDownLeftDxfLine); doc.Entities.Add(midMidLeftDxfLine); doc.Entities.Add(midUpLeftDxfLine); doc.Entities.Add(midTopDxfLine); doc.Entities.Add(midRightDxfLine); //内部矩形 DxfLine inBottomDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + outer_in_space, DLocation.Z)); DxfLine inDownLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + outer_in_space, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + height/4, DLocation.Z)); DxfLine inmidLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + height / 4 + barHeight, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + 3*height/4 - barHeight, DLocation.Z)); DxfLine inUpLeftDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + 3*height / 4, DLocation.Z), new Point3D(DLocation.X + outer_in_space, DLocation.Y + height-outer_in_space, DLocation.Z)); DxfLine inTopDxfLine = new DxfLine(new Point3D(DLocation.X + outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z)); DxfLine inRightDxfLine = new DxfLine(new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + height - outer_in_space, DLocation.Z), new Point3D(DLocation.X + width - outer_in_space, DLocation.Y + outer_in_space, DLocation.Z)); doc.Entities.Add(inBottomDxfLine); doc.Entities.Add(inDownLeftDxfLine); doc.Entities.Add(inmidLeftDxfLine); doc.Entities.Add(inUpLeftDxfLine); doc.Entities.Add(inTopDxfLine); doc.Entities.Add(inRightDxfLine); //门中文字 double DxfTextHeight = DoorInitHeightAndWidth.DxfTextHeight; for (int i = 0; i < DxfText.Length; i++) { DxfText doorRectangleDxfText = new DxfText(DxfText[i], new Point3D(DLocation.X + width / 3, DLocation.Y + 3 * height / 4 - i * DxfTextHeight, DLocation.Z), DxfTextHeight); doc.Entities.Add(doorRectangleDxfText); } }
public void Draw(DxfModel dxf, DLocation DLocation, double boxWidth, double boxHeight, List<PictureBoxInfo> pictureBoxInfoList,int coolingType) { DataManager dataManager=new DataManager(); //boxWidth = dataManager.getTotalWidth(pictureBoxInfoList); //得到框架信息 var boxEntity = dataCenter.BoxEntity; DLocation = new DLocation(DLocation.X - 120d, DLocation.Y + boxEntity.TopViewHeight + 80.0d + boxEntity.UpHeight + boxEntity.DownHeight, 0); boxWidth = boxEntity.Width + 240.0d; boxHeight = boxEntity.TopViewHeight + boxEntity.UpHeight + boxEntity.DownHeight + 160.0d; /****************************************************************************/ //绘制最外框 /****************************************************************************/ Point3D v1 = new Point3D(DLocation.X, DLocation.Y, DLocation.Z); Point3D v2 = new Point3D(DLocation.X, DLocation.Y - boxHeight, DLocation.Z); Point3D v3 = new Point3D(DLocation.X + boxWidth, DLocation.Y - boxHeight, DLocation.Z); Point3D v4 = new Point3D(DLocation.X + boxWidth, DLocation.Y, DLocation.Z); //DxfLinePointer.Draw(dxf, DLocation); //Slash.Draw(dxf,new DLocation(v2.X,v2.Y,v2.Z)); //Fan.Draw(dxf, v2,v1,2); DxfLine DxfLine12 = new DxfLine(v1, v2); dxf.Entities.Add(DxfLine12); DxfLine DxfLine23 = new DxfLine(v2, v3); dxf.Entities.Add(DxfLine23); DxfLine DxfLine34 = new DxfLine(v3, v4); dxf.Entities.Add(DxfLine34); DxfLine DxfLine14 = new DxfLine(v1, v4); dxf.Entities.Add(DxfLine14); /****************************************************************************/ //绘制左上角的配置信息 /****************************************************************************/ Configuration.Draw(dxf, new DLocation(v1.X, v1.Y), dataCenter.Configurations); /****************************************************************************/ //绘制左下角的节信息 /****************************************************************************/ Section.Draw(dxf, new DLocation(v2.X, v2.Y), dataCenter.SectionEntity); /****************************************************************************/ //绘制底部的订单信息 /****************************************************************************/ Order.Draw(dxf, new DLocation(v2.X, v2.Y), boxWidth, dataCenter.OrderEntity); //俯视图左下角的坐标点 DLocation v5 = new DLocation(DLocation.X + 120.0d, DLocation.Y - boxEntity.TopViewHeight - 50.0d, DLocation.Z); /****************************************************************************/ //绘制俯视图 /****************************************************************************/ //AssembleTopView.assembleTopView(pictureBoxInfoList, dxf, // v5, null, 50.0d, 18.0d, 2.0d, 2.86f, 2.0d, 2.0d); AssembleTopView.assembleTopView(pictureBoxInfoList, dxf, v5, dataCenter.topViewConfigure); //正视图左下角的坐标点 DLocation v6 = new DLocation(DLocation.X + 120.0d, DLocation.Y - boxEntity.TopViewHeight - 80.0d - boxEntity.UpHeight - boxEntity.DownHeight, DLocation.Z); /****************************************************************************/ //绘制正视图 /****************************************************************************/ AssembleDetailMechine.assembleDetailMechine(pictureBoxInfoList, dxf,v6, dataCenter.detailMechineConfigure, coolingType); //正视图两边的风向箭头位置 //存在第一层 DLocation v7 = new DLocation(DLocation.X + 70.0d, DLocation.Y - 90.0d-boxEntity.TopViewHeight-boxEntity.UpHeight-boxEntity.DownHeight/2, DLocation.Z); DLocation v8 = new DLocation(DLocation.X + boxWidth - 50.0d, DLocation.Y - 90.0d - boxEntity.TopViewHeight - boxEntity.UpHeight - boxEntity.DownHeight / 2, DLocation.Z); /****************************************************************************/ //绘制正视图两边的风向箭头 /****************************************************************************/ //判断是否存在两层,记录两层第一个元素的位置 int upFirstElemnet = AssembleDetailMechine.isTwoLayers(pictureBoxInfoList); Wind.Draw(dxf, v7, boxEntity.IsLeft); if (upFirstElemnet == -1) { if (pictureBoxInfoList.ElementAt(pictureBoxInfoList.Count - 1).name.Equals("SFC") || pictureBoxInfoList.ElementAt(pictureBoxInfoList.Count - 1).name.Equals("SDD")) { PictureBoxInfo tempPictureBoxInfo = pictureBoxInfoList.ElementAt(pictureBoxInfoList.Count - 1); List<AirFlowUpDimension> airFlowList = AirFlowUpDimensionConfigure.getAirFlowList(); foreach (var airFlowDimension in airFlowList) { if (tempPictureBoxInfo.coolingType.Equals(airFlowDimension.coolingType) && tempPictureBoxInfo.name.Equals(airFlowDimension.imageName)) { Wind.DrawVerticalWind(dxf, new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension*1.3, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height * 1.3, tempPictureBoxInfo.DLocation.Z)); //这里多写了一个标注,其实不应该写在这里应该写在AssembleDetailMechine中,只是这里写方便,但不符原则 DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); } } } else { Wind.Draw(dxf, v8, boxEntity.IsLeft); } } else { if (pictureBoxInfoList.ElementAt(upFirstElemnet-1).name.Equals("SFC") || pictureBoxInfoList.ElementAt(upFirstElemnet-1).name.Equals("SDD")) { PictureBoxInfo tempPictureBoxInfo = pictureBoxInfoList.ElementAt(upFirstElemnet - 1); List<AirFlowUpDimension> airFlowList = AirFlowUpDimensionConfigure.getAirFlowList(); foreach (var airFlowDimension in airFlowList) { if (tempPictureBoxInfo.coolingType.Equals(airFlowDimension.coolingType) && tempPictureBoxInfo.name.Equals(airFlowDimension.imageName)) { Wind.DrawVerticalWind(dxf, new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension*1.3, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height * 1.3, tempPictureBoxInfo.DLocation.Z)); //这里多写了一个标注,其实不应该写在这里应该写在AssembleDetailMechine中,只是这里写方便,但不符原则 DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); } } } else { Wind.Draw(dxf, v8, boxEntity.IsLeft); } } //如果存在第二层 if (boxEntity.UpHeight != 0) { DLocation v9 = new DLocation(DLocation.X + 70.0d, DLocation.Y - 90.0d - boxEntity.TopViewHeight - boxEntity.UpHeight / 2, DLocation.Z); DLocation v10 = new DLocation(DLocation.X + boxWidth - 50.0d, DLocation.Y - 90.0d - boxEntity.TopViewHeight - boxEntity.UpHeight / 2, DLocation.Z); if (pictureBoxInfoList.ElementAt(upFirstElemnet).name.Equals("PEC") || pictureBoxInfoList.ElementAt(upFirstElemnet).name.Equals("EDD")) { PictureBoxInfo tempPictureBoxInfo = pictureBoxInfoList.ElementAt(upFirstElemnet); List<AirFlowUpDimension> airFlowList = AirFlowUpDimensionConfigure.getAirFlowList(); foreach (var airFlowDimension in airFlowList) { if (tempPictureBoxInfo.coolingType.Equals(airFlowDimension.coolingType) && tempPictureBoxInfo.name.Equals(airFlowDimension.imageName)) { Wind.DrawVerticalWind(dxf, new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension*1.3, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height * 1.3, tempPictureBoxInfo.DLocation.Z)); //这里多写了一个标注,其实不应该写在这里应该写在AssembleDetailMechine中,只是这里写方便,但不符原则 DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); DoorRectangle.writeDimension(dxf, new DLocation(tempPictureBoxInfo.DLocation.X+airFlowDimension.topLeftDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), new DLocation(tempPictureBoxInfo.DLocation.X + airFlowDimension.topLeftDimension+airFlowDimension.topRightDimension, tempPictureBoxInfo.DLocation.Y + tempPictureBoxInfo.height, tempPictureBoxInfo.DLocation.Z), 16, 1, 3, "top"); } } } else { Wind.Draw(dxf, v9, !boxEntity.IsLeft); } Wind.Draw(dxf, v10, !boxEntity.IsLeft); } }
public DetailMechineConfigure getDetailMechineCnfigure(List<PictureBoxInfo> pictureBoxNameList, DxfModel dxf, DLocation DLocation) { return new DetailMechineConfigure(pictureBoxNameList, new string[] { "hello", "world", "helloworld" }, 44.0d, 18, 2.0d, 2.86f, 2.0d, 2.0d); }
public static void assembleTopView(List<PictureBoxInfo> imageNameList, DxfModel dxf, DLocation DLocation, TopViewConfigure tvc) { int upFirstElement = AssembleDetailMechine.isTwoLayers(imageNameList); if (upFirstElement!= -1) { List<PictureBoxInfo> oneImageNameList = new List<PictureBoxInfo>(); List<PictureBoxInfo> twoImageNameList = new List<PictureBoxInfo>(); for (int i = 0, len = imageNameList.Count; i < len; i++) { if (i == 0) { //if (imageNameList.ElementAt(i).name.Equals("HRA")) //{ // //这里的virtralPictrueBox和realPictureBox中设置的Y坐标只是为后面onelist和twolist判断是其作用,其他没什么实质作用 // PictureBoxInfo virtualPictureBox = new PictureBoxInfo(); // virtualPictureBox.name = "virtualHRA"; // //主要为了记录虚拟的框的坐标,为了画dxf是提供依据 // //virtualPictureBox.DLocation = new DLocation(imageNameList.ElementAt(i).DLocation.X, imageNameList.ElementAt(i).DLocation.Y + 113 + 4, imageNameList.ElementAt(i).DLocation.Z); // virtualPictureBox.DLocation = new DLocation(imageNameList.ElementAt(i).DLocation.X, imageNameList.ElementAt(i).DLocation.Y, imageNameList.ElementAt(i).DLocation.Z); // oneImageNameList.Add(virtualPictureBox); // PictureBoxInfo realPictureBox = new PictureBoxInfo(); // realPictureBox.name = imageNameList.ElementAt(i).name; // realPictureBox.DLocation = new DLocation(imageNameList.ElementAt(i).DLocation.X, imageNameList.ElementAt(i).DLocation.Y + 113 + 4, imageNameList.ElementAt(i).DLocation.Z); // twoImageNameList.Add(realPictureBox); //} //else //{ oneImageNameList.Add(imageNameList.ElementAt(i)); //} } else { if (oneImageNameList.ElementAt(0).DLocation.Y == imageNameList.ElementAt(i).DLocation.Y) { //if (imageNameList.ElementAt(i).name.Equals("HRA")) //{ // PictureBoxInfo virtualPictureBox = new PictureBoxInfo(); // virtualPictureBox.name = "virtualHRA"; // virtualPictureBox.DLocation = new DLocation(imageNameList.ElementAt(i).DLocation.X, imageNameList.ElementAt(i).DLocation.Y + 113 + 4, imageNameList.ElementAt(i).DLocation.Z); // oneImageNameList.Add(virtualPictureBox); // twoImageNameList.Add(imageNameList.ElementAt(i)); //} //else //{ oneImageNameList.Add(imageNameList.ElementAt(i)); //} } else { //if (imageNameList.ElementAt(i).name.Equals("HRA")) //{ // PictureBoxInfo virtualPictureBox = new PictureBoxInfo(); // virtualPictureBox.name = "virtualHRA"; // virtualPictureBox.DLocation = new DLocation(imageNameList.ElementAt(i).DLocation.X, imageNameList.ElementAt(i).DLocation.Y + 113 + 4, imageNameList.ElementAt(i).DLocation.Z); // twoImageNameList.Add(virtualPictureBox); // oneImageNameList.Add(imageNameList.ElementAt(i)); //} //else //{ twoImageNameList.Add(imageNameList.ElementAt(i)); //} } } } if (oneImageNameList.ElementAt(0).DLocation.Y> twoImageNameList.ElementAt(0).DLocation.Y) { //第一层 assembleTopView(oneImageNameList, dxf, DLocation, tvc.DxfText, tvc.height, tvc.width, tvc.outer_mid_space, tvc.outer_in_space, tvc.barHeight, tvc.barWidth,-1); //DLocation为oneImageNamelist第一个元素的坐标 assembleTopView(twoImageNameList, dxf,new DLocation(twoImageNameList.ElementAt(0).DLocation.X,DLocation.Y,DLocation.Z), tvc.DxfText, tvc.height, tvc.width, tvc.outer_mid_space, tvc.outer_in_space, tvc.barHeight, tvc.barWidth,upFirstElement); } else { //第一层 assembleTopView(twoImageNameList, dxf, DLocation, tvc.DxfText, tvc.height, tvc.width, tvc.outer_mid_space, tvc.outer_in_space, tvc.barHeight, tvc.barWidth,-1); assembleTopView(oneImageNameList, dxf, DLocation, tvc.DxfText, tvc.height, tvc.width, tvc.outer_mid_space, tvc.outer_in_space, tvc.barHeight, tvc.barWidth, upFirstElement); } } else { assembleTopView(imageNameList, dxf, DLocation, tvc.DxfText, tvc.height, tvc.width, tvc.outer_mid_space, tvc.outer_in_space, tvc.barHeight, tvc.barWidth); } }
public static void assembleTopView(List<PictureBoxInfo> imageNameList, DxfModel dxf, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space, double barHeight, double barWidth,int upFirstElement=-1) { List<DLocation> storeDLocationList = new List<DLocation>(); for (int i = 0; i < imageNameList.Count; i++) { string imageName = imageNameList.ElementAt(i).name; int coolingType=imageNameList.ElementAt(i).coolingType; height = imageNameList.ElementAt(i).topViewHeight; width = imageNameList.ElementAt(i).width; if (upFirstElement == -1) { if (imageName.Equals("FTA") || imageName.Equals("FTC") || imageName.Equals("FTF") || imageName.Equals("FTH")||imageName.Equals("FTE")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("MBA") || imageName.Equals("MBB") || imageName.Equals("MBC") || imageName.Equals("MBD") || imageName.Equals("MBE") || imageName.Equals("MBF") || imageName.Equals("MBG") || imageName.Equals("MBH") || imageName.Equals("MBI") || imageName.Equals("MBJ") || imageName.Equals("MBK")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); ; DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("PHA") || imageName.Equals("PHB") || imageName.Equals("PHC") || imageName.Equals("PHD")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); ; DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("HRA")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("virtualHRA")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("CLB") || imageName.Equals("CLC") || imageName.Equals("CLF") || imageName.Equals("CLG") || imageName.Equals("CLI") || imageName.Equals("CLM")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("PEA") || imageName.Equals("PEC") || imageName.Equals("RFA") || imageName.Equals("SFA") || imageName.Equals("SFC") || imageName.Equals("SFD") || imageName.Equals("SDB") || imageName.Equals("SDD") || imageName.Equals("EDB") || imageName.Equals("RDB")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); //俯视图封口向上时 if (i ==imageNameList.Count-1) { if (imageName.Equals("SFC") || imageName.Equals("SDD")) { List<AirFlowUpDimension> airFlowList=AirFlowUpDimensionConfigure.getAirFlowList(); AirFlowUpDimension currentAirFlowDimension = new AirFlowUpDimension(); foreach (var airFlowDimension in airFlowList) { if (coolingType.Equals(airFlowDimension.coolingType) && imageName.Equals(airFlowDimension.imageName)) { currentAirFlowDimension = airFlowDimension; DLocation airFlowDLocation=new DLocation(currentDLocation.X+currentAirFlowDimension.topLeftDimension,currentDLocation.Y+currentAirFlowDimension.rightDownDimension,currentDLocation.Z); DoorRectangle.writeOuterDoorRectangle(dxf,airFlowDLocation,currentAirFlowDimension.rightUpDimension,currentAirFlowDimension.topRightDimension); //画标注上边 DoorRectangle.writeDimension(dxf, new DLocation(currentDLocation.X, currentDLocation.Y + currentAirFlowDimension.rightUpDimension + currentAirFlowDimension.rightDownDimension, currentDLocation.Z), new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension, currentDLocation.Y + airFlowDimension.rightDownDimension+airFlowDimension.rightUpDimension, currentDLocation.Z), 16f, 1f, 5, "top"); DoorRectangle.writeDimension(dxf, new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension, currentDLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, currentDLocation.Z), new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension+airFlowDimension.topRightDimension, currentDLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, currentDLocation.Z), 16f, 1f, 5, "top"); //画右边标注 DoorRectangle.writeDimension(dxf, new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension+airFlowDimension.topRightDimension, currentDLocation.Y, currentDLocation.Z), new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, currentDLocation.Y + airFlowDimension.rightDownDimension, currentDLocation.Z), 16f, 1f, 3, "right"); DoorRectangle.writeDimension(dxf, new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, currentDLocation.Y+airFlowDimension.rightDownDimension, currentDLocation.Z), new DLocation(currentDLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, currentDLocation.Y + airFlowDimension.rightDownDimension+airFlowDimension.rightUpDimension, currentDLocation.Z), 16f, 1f, 3, "right"); continue; } } } } } } else if (imageName.Equals("BBA") || imageName.Equals("BBB") || imageName.Equals("BBC") || imageName.Equals("BBD") || imageName.Equals("BBE") || imageName.Equals("BBF")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } else if (imageName.Equals("TRA") || imageName.Equals("TRB") || imageName.Equals("TRC") || imageName.Equals("TRD") || imageName.Equals("TRE") || imageName.Equals("TRF")) { if (i == 0) { DoorRectangle.writeTopViewRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); storeDLocationList.Add(DLocation); } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeTopViewRectangle(dxf, currentDLocation, DxfText, height, width, outer_mid_space, outer_in_space); } } } else { if (i == 0) { DoorRectangle.writeOuterDoorRectangle(dxf, DLocation, height, width); storeDLocationList.Add(DLocation); //处理向上的风口问题 if (imageName.Equals("PEC") || imageName.Equals("EDD")) { List<AirFlowUpDimension> airFlowList = AirFlowUpDimensionConfigure.getAirFlowList(); AirFlowUpDimension currentAirFlowDimension = new AirFlowUpDimension(); foreach (var airFlowDimension in airFlowList) { if (coolingType.Equals(airFlowDimension.coolingType) && imageName.Equals(airFlowDimension.imageName)) { currentAirFlowDimension = airFlowDimension; DLocation airFlowDLocation = new DLocation(DLocation.X + currentAirFlowDimension.topLeftDimension, DLocation.Y + currentAirFlowDimension.rightDownDimension, DLocation.Z); DoorRectangle.writeOuterDoorRectangle(dxf, airFlowDLocation, currentAirFlowDimension.rightUpDimension, currentAirFlowDimension.topRightDimension); //画标注上边 DoorRectangle.writeDimension(dxf, new DLocation(DLocation.X, DLocation.Y + currentAirFlowDimension.rightUpDimension + currentAirFlowDimension.rightDownDimension, DLocation.Z), new DLocation(DLocation.X + airFlowDimension.topLeftDimension, DLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, DLocation.Z), 16f, 1f, 5, "top"); DoorRectangle.writeDimension(dxf, new DLocation(DLocation.X + airFlowDimension.topLeftDimension, DLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, DLocation.Z), new DLocation(DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, DLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, DLocation.Z), 16f, 1f, 5, "top"); //画右边标注 DoorRectangle.writeDimension(dxf, new DLocation(DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, DLocation.Y, DLocation.Z), new DLocation(DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, DLocation.Y + airFlowDimension.rightDownDimension, DLocation.Z), 16f, 1f, 3, "right"); DoorRectangle.writeDimension(dxf, new DLocation(DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, DLocation.Y + airFlowDimension.rightDownDimension, DLocation.Z), new DLocation(DLocation.X + airFlowDimension.topLeftDimension + airFlowDimension.topRightDimension, DLocation.Y + airFlowDimension.rightDownDimension + airFlowDimension.rightUpDimension, DLocation.Z), 16f, 1f, 3, "right"); continue; } } } } else { DLocation currentDLocation = storeDLocationList.ElementAt(i); DoorRectangle.writeOuterDoorRectangle(dxf, currentDLocation, height, width); } } storeDLocationList.Add(new DLocation(storeDLocationList.ElementAt(i).X + width, storeDLocationList.ElementAt(i).Y, storeDLocationList.ElementAt(i).Z)); } //第一层 if (upFirstElement == -1) { //画标注 PictureBoxInfo firstPictureInfo = imageNameList.ElementAt(0); DLocation firstDLocation = storeDLocationList.ElementAt(0); DoorRectangle.writeDimension(dxf, new DLocation(firstDLocation.X, firstDLocation.Y - outer_in_space, firstDLocation.Z), firstDLocation, 16f, 1f, 5, "left"); DoorRectangle.writeDimension(dxf, firstDLocation, new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewFirstDistance, firstDLocation.Z), 16f, 1f, 8, "left"); DoorRectangle.writeDimension(dxf, new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewFirstDistance, firstDLocation.Z), new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewSecondDistance, firstDLocation.Z), 16f, 1f, 8, "left"); //top DLocation lastDLocation = storeDLocationList.ElementAt(storeDLocationList.Count - 1); DoorRectangle.writeDimension(dxf, new DLocation(firstDLocation.X, firstDLocation.Y + height, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + height, firstDLocation.Z), 16f, 1f, 10, "top"); //right PictureBoxInfo lastPictureInfo = imageNameList.ElementAt(imageNameList.Count - 1); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewFirstDistance, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewSecondDistance, firstDLocation.Z), 16f, 1f, 5f, "right"); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewFirstDistance, firstDLocation.Z), 16f, 1f, 5f, "right"); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + height, firstDLocation.Z), 16f, 1f, 10f, "right"); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y - BaseRail.baseRail, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y, firstDLocation.Z), 16f, 1f, 10f, "right"); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y - BaseRail.baseRail, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + height + outer_in_space, firstDLocation.Z), 16f, 1f, 14f, "right"); } //第二层 else { //画标注 PictureBoxInfo firstPictureInfo = imageNameList.ElementAt(0); DLocation firstDLocation = storeDLocationList.ElementAt(0); DoorRectangle.writeDimension(dxf, firstDLocation, new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewFirstDistance, firstDLocation.Z), 16f, 1f, 8, "left"); DoorRectangle.writeDimension(dxf, new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewFirstDistance, firstDLocation.Z), new DLocation(firstDLocation.X, firstDLocation.Y + firstPictureInfo.topViewSecondDistance, firstDLocation.Z), 16f, 1f, 8, "left"); //right DLocation lastDLocation = storeDLocationList.ElementAt(storeDLocationList.Count - 1); PictureBoxInfo lastPictureInfo = imageNameList.ElementAt(imageNameList.Count - 1); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewFirstDistance, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewSecondDistance, firstDLocation.Z), 16f, 1f, 5f, "right"); DoorRectangle.writeDimension(dxf, new DLocation(lastDLocation.X, lastDLocation.Y, firstDLocation.Z), new DLocation(lastDLocation.X, lastDLocation.Y + lastPictureInfo.topViewFirstDistance, firstDLocation.Z), 16f, 1f, 5f, "right"); } }
/// <summary> /// 门把手绘制 /// </summary> /// <param name="dxf"></param> /// <param name="DLocation"></param> public static void Draw(DxfModel dxf, DLocation DLocation) { double factor = 0.05f; double distance = 30; //底部小圆的圆心 Point3D sDxfCircle = new Point3D(DLocation.X + 10 * factor, DLocation.Y, DLocation.Z); //上部同心圆圆心 Point3D bDxfCircle = new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance*factor, DLocation.Z); double alpha = Math.Asin(3 / distance); double beta = Math.Acos(0.8); Point3D v1 = new Point3D( DLocation.X + 10 * factor - double.Parse((5 * factor * Math.Cos(alpha)).ToString()), DLocation.Y + 5 * factor - double.Parse((5 * factor * Math.Sin(alpha)).ToString()), DLocation.Z); Point3D v2 = new Point3D( DLocation.X + 10 * factor + double.Parse((5 * factor * Math.Cos(alpha)).ToString()), DLocation.Y + 5 * factor - double.Parse((5 * factor * Math.Sin(alpha)).ToString()), DLocation.Z); Point3D v4 = new Point3D( DLocation.X + 10 * factor -double.Parse((8*factor* Math.Cos(alpha)).ToString()), DLocation.Y + 5 * factor + distance * factor - double.Parse((8 * factor * Math.Sin(alpha)).ToString()), DLocation.Z ); Point3D v5 = new Point3D( DLocation.X + 10 * factor + double.Parse((8*factor*Math.Cos(alpha)).ToString()), DLocation.Y + 5 * factor + distance * factor - double.Parse((8 * factor * Math.Sin(alpha)).ToString()), DLocation.Z ); DxfLine DxfLine14 = new DxfLine(v1, v4); dxf.Entities.Add(DxfLine14); DxfLine DxfLine25 = new DxfLine(v2, v5); dxf.Entities.Add(DxfLine25); //DxfArc DxfArc DxfArc = new DxfArc( new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor, DLocation.Z), 5 * factor, Convert.ToInt32(180 + alpha * 180 / Math.PI), Convert.ToInt32(360 - alpha * 180 / Math.PI)); dxf.Entities.Add(DxfArc); //DxfArcup DxfArc DxfArcup = new DxfArc( new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance * factor, DLocation.Z), 8 * factor, Convert.ToInt32(-alpha * 180 / Math.PI), Convert.ToInt32(180 + alpha * 180 / Math.PI)); dxf.Entities.Add(DxfArcup); //DxfArcround DxfArc DxfArcround = new DxfArc( new Point3D(DLocation.X + 10 * factor, DLocation.Y + 5 * factor + distance * factor, DLocation.Z), 10 * factor, Convert.ToInt32(-(alpha +beta) * 180 / Math.PI), Convert.ToInt32(180 + (alpha +beta) * 180 / Math.PI)); dxf.Entities.Add(DxfArcround); //DxfCircle Point3D centerWCS = new Point3D(DLocation.X+10*factor, DLocation.Y+5*factor+distance*factor, DLocation.Z); DxfCircle DxfCircle = new DxfCircle((Point3D)centerWCS, 7 * factor); dxf.Entities.Add(DxfCircle); //上部同心圆圆心 Point3D t1 = new Point3D( DLocation.X + 8 * factor, DLocation.Y + 5 * factor + (distance - 7) * factor * 0.7f, DLocation.Z); Point3D t2 = new Point3D( DLocation.X + 8 * factor, DLocation.Y + 5 * factor + (distance - 7) * factor * 0.5f, DLocation.Z); Point3D t3 = new Point3D( DLocation.X + 8 * factor, DLocation.Y + 5 * factor + (distance - 7) * factor * 0.3f, DLocation.Z); Point3D t4 = new Point3D( DLocation.X + 8 * factor, DLocation.Y + 5 * factor + (distance - 7) * factor * 0.1f, DLocation.Z); //DxfText DxfText DxfText1 = new DxfText("A", t1, 0.2f); dxf.Entities.Add(DxfText1); //DxfText DxfText DxfText2 = new DxfText("A", t2, 0.2f); dxf.Entities.Add(DxfText2); //DxfText DxfText DxfText3 = new DxfText("O", t3, 0.2f); dxf.Entities.Add(DxfText3); //DxfText DxfText DxfText4 = new DxfText("N", t4, 0.2f); dxf.Entities.Add(DxfText4); }
/// <summary> /// 计算俯视图下一个坐标使用 /// </summary> /// <param name="pList"></param> /// <returns></returns> public static DLocation getTopViewNextStartLocation(List<Point3D> pList) { double minY = Double.MaxValue; double minX = Double.MinValue; DLocation nextStartLocation = new DLocation(); for (int i = 0; i < pList.Count; i++) { if (Math.Round(minY*10000)/10000 >= Math.Round(pList[i].Y*10000)/10000) { if (Math.Round(minX*10000/10000) <=Math.Round(pList[i].X*10000)/10000) { minY = pList[i].Y; minX = pList[i].X; nextStartLocation.X = pList[i].X; nextStartLocation.Y = pList[i].Y; nextStartLocation.Z = pList[i].Z; } } } return nextStartLocation; }
//画完整的带支架的设备矩形框 public static void writeWholeMachine(DxfModel dxf, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space, double barHeight, double barWidth,string upOrDownLayer) { writeDoorRectangle(dxf,DLocation,DxfText,height,width,outer_mid_space,outer_in_space); //画小支架 if (upOrDownLayer.Equals("downLayer")) { //左下角 writeOuterDoorRectangle(dxf, new DLocation(DLocation.X, DLocation.Y - outer_in_space, DLocation.Z), outer_in_space, outer_in_space - outer_mid_space); //右下角 writeOuterDoorRectangle(dxf, new DLocation(DLocation.X + width + outer_mid_space - outer_in_space, DLocation.Y - outer_in_space, DLocation.Z), outer_in_space, outer_in_space - outer_mid_space); } }
/// <summary> /// 负责计算俯视图的函数 /// </summary> /// <param name="sourceModel"></param> /// <returns></returns> public static DLocation getTopViewRelativeStartLocation(DxfModel sourceModel) { DLocation relativeStartLocation = new DLocation(); double minX = Double.MaxValue; double minY = Double.MaxValue; foreach (DxfEntity entity in sourceModel.Entities) { switch (entity.EntityType) { case "LINE": { DxfLine dxfLine = (DxfLine)entity; if (Math.Round(dxfLine.Start.Y*10000)/10000 == Math.Round(dxfLine.End.Y*10000)/10000) { if (Math.Round(minX*10000)/10000 >= Math.Round(dxfLine.Start.X*10000)/10000) { if (Math.Round(minY*10000)/10000 >= Math.Round(dxfLine.Start.Y*10000)/10000) { minY = dxfLine.Start.Y; minX = dxfLine.Start.X; relativeStartLocation.X = dxfLine.Start.X; relativeStartLocation.Y = dxfLine.Start.Y; relativeStartLocation.Z = dxfLine.Start.Z; } } } //消除画图人员错误绘制 if (Math.Round(dxfLine.Start.Y * 10000) / 10000 == Math.Round(dxfLine.End.Y * 10000) / 10000) { if (Math.Round(minX * 10000) / 10000 >= Math.Round(dxfLine.End.X * 10000) / 10000) { if (Math.Round(minY * 10000) / 10000 >= Math.Round(dxfLine.End.Y * 10000) / 10000) { minX = dxfLine.End.X; minY = dxfLine.End.Y; relativeStartLocation.X = dxfLine.End.X; relativeStartLocation.Y = dxfLine.End.Y; relativeStartLocation.Z = dxfLine.End.Z; } } } }; continue; } } return relativeStartLocation; }
/// <summary> /// 圆圈 /// </summary> /// <param name="doc"></param> /// <param name="DLocation"></param> /// <param name="radius"></param> public static void writeCirle(DxfModel doc, DLocation DLocation,double radius) { DxfCircle dxfCirle = new DxfCircle(new Point3D(DLocation.X, DLocation.Y, DLocation.Z), radius); doc.Entities.Add(dxfCirle); }
//画完整的一个单门(门闩,把手,支架) /// <summary> /// fta等,sfd,pea,pec,rfa /// </summary> /// <param name="dxf"></param> /// <param name="DLocation"></param> /// <param name="DxfText"></param> /// <param name="height"></param> /// <param name="width"></param> /// <param name="outer_mid_space"></param> /// <param name="outer_in_space"></param> /// <param name="barHeight"></param> /// <param name="barWidth"></param> /// <param name="upOrDownLayer"></param> public static void writeWholeSingleDoor(DxfModel dxf, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space, double barHeight, double barWidth,string upOrDownLayer) { writeDoorBarRectangle(dxf, DLocation, DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); double downLeftX=DLocation.X+outer_mid_space-barWidth/2+(outer_in_space-outer_mid_space)/2; double downLeftY=DLocation.Y + height / 4; writeRepresentDoorBarRectangle(dxf, new DLocation(downLeftX,downLeftY , DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); double upLeftX = downLeftX; double upLeftY = DLocation.Y + 3 * height / 4 - barHeight; writeRepresentDoorBarRectangle(dxf, new DLocation(upLeftX,upLeftY , DLocation.Z), DxfText, height, width, outer_mid_space, outer_in_space, barHeight, barWidth); //画小支架 if (upOrDownLayer.Equals("downLayer")) { //左下角 writeOuterDoorRectangle(dxf, new DLocation(DLocation.X, DLocation.Y - outer_in_space, DLocation.Z), outer_in_space, outer_in_space - outer_mid_space); //右下角 writeOuterDoorRectangle(dxf, new DLocation(DLocation.X + width + outer_mid_space - outer_in_space, DLocation.Y - outer_in_space, DLocation.Z), outer_in_space, outer_in_space - outer_mid_space); } //画门把手 Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + 3 * height / 4 - barHeight, DLocation.Z)); Handle.Draw(dxf, new DLocation(DLocation.X + 3 * width / 4, DLocation.Y + height / 4, DLocation.Z)); }
/// <summary> /// 单独用来处理frame的函数 /// </summary> /// <param name="entity"></param> /// <param name="location"></param> /// <param name="relativeStartLocation"></param> /// <returns></returns> public static DxfEntity getFrameEntity(DxfEntity entity, DLocation location, DLocation relativeStartLocation,double increaseWidth) { switch (entity.EntityType) { case "LINE": { DxfLine dxfLine = (DxfLine)entity; double lineLenght = dxfLine.End.X - dxfLine.Start.X; double lineHeight = dxfLine.End.Y - dxfLine.Start.Y; if (Math.Round(dxfLine.Start.Y * 1000) / 1000 == Math.Round(dxfLine.End.Y * 1000) / 1000) { //消除绘图人员的语法错误 if (dxfLine.Start.X > dxfLine.End.X) { dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance + increaseWidth, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z); dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z); } else { dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z); dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght+increaseWidth, dxfLine.Start.Y + lineHeight, location.Z); } } else { if (Math.Round(dxfLine.Start.X * 10) / 10 == Math.Round(frameLastLineX * 10) / 10) { double tempX = dxfLine.Start.X; dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth/2, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z); //因为此处的dxfLine.Start.x==dxfLineEnd.x所以不需要+increaseWidth dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z); } else { dxfLine.Start = new Point3D(dxfLine.Start.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLine.Start.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfLine.ZAxis.Z); dxfLine.End = new Point3D(dxfLine.Start.X + lineLenght, dxfLine.Start.Y + lineHeight, location.Z); } } return dxfLine; }; case "TEXT": { DxfText dxfText = (DxfText)entity; //解决乱码问题 dxfText.Style = textStyle; TextValue textValue = new TextValue(); if (dxfText.Text.Equals("产品代码:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X,dxfText.AlignmentPoint1.Y,dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X+4*RelativeDistance.width,textValue.textPosition.Y,textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("项目名称:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("设备描述:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("买方:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 2 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("订单号:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 3 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("买方联系人:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 5 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("易龙销售:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 4 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("软件序列号:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 5 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("系列号:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 3 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else if (dxfText.Text.Equals("时间:")) { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance + increaseWidth / 2, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; textValue.text = dxfText.Text; textValue.height = dxfText.Height; textValue.textPosition = new DLocation(dxfText.AlignmentPoint1.X, dxfText.AlignmentPoint1.Y, dxfText.AlignmentPoint1.Z); textValue.valuePosition = new DLocation(textValue.textPosition.X + 2 * RelativeDistance.width, textValue.textPosition.Y, textValue.textPosition.Z); textValueList.Add(textValue); } else { dxfText.AlignmentPoint1 = new Point3D(dxfText.AlignmentPoint1.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfText.AlignmentPoint1.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfText.AlignmentPoint1.Z); dxfText.AlignmentPoint2 = dxfText.AlignmentPoint1; } return dxfText; } case "ELLIPSE": { DxfEllipse dxfEllipse = (DxfEllipse)entity; dxfEllipse.Center = new Point3D(dxfEllipse.Center.X - relativeStartLocation.X + location.X-RelativeDistance.xDistance, dxfEllipse.Center.Y - relativeStartLocation.Y + location.Y-RelativeDistance.yDistance, dxfEllipse.Center.Z); return dxfEllipse; } case "LWPOLYLINE": { DxfLwPolyline dxfLwPolyLine = (DxfLwPolyline)entity; int len = dxfLwPolyLine.Vertices.Count; //获得Frame最右边的X值 Point2D rightPoint2d = getFrameRightX(dxfLwPolyLine.Vertices); for (int i = 0; i < len; i++) { if (isPolyLinePoint(rightPoint2d, dxfLwPolyLine.Vertices[i].Position)) { dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance); } else { dxfLwPolyLine.Vertices[i].Position = new Point2D(dxfLwPolyLine.Vertices[i].Position.X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfLwPolyLine.Vertices[i].Position.Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance); } } return dxfLwPolyLine; } case "SOLID": { DxfSolid dxfSolid = (DxfSolid)entity; int len = dxfSolid.Points.Count; for (int i = 0; i < len;i++ ) { //可能会出问题 if(i==1||i==3) dxfSolid.Points[i] = new Point3D(dxfSolid.Points[i].X - relativeStartLocation.X + location.X - RelativeDistance.xDistance+increaseWidth, dxfSolid.Points[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSolid.Points[i].Z); else dxfSolid.Points[i] = new Point3D(dxfSolid.Points[i].X - relativeStartLocation.X + location.X - RelativeDistance.xDistance, dxfSolid.Points[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSolid.Points[i].Z); } return dxfSolid; } case "SPLINE": { DxfSpline dxfSpline = (DxfSpline)entity; int len=dxfSpline.ControlPoints.Count; for (int i = 0; i < len;i++ ) { dxfSpline.ControlPoints[i] = new Point3D(dxfSpline.ControlPoints[i].X - relativeStartLocation.X + location.X- RelativeDistance.xDistance, dxfSpline.ControlPoints[i].Y - relativeStartLocation.Y + location.Y - RelativeDistance.yDistance, dxfSpline.ControlPoints[i].Z); } return dxfSpline; } default: return entity; } }
public TopViewConfigure getTopViewConfigure(List<PictureBoxInfo> pictureBoxNameList, DxfModel dxf, DLocation DLocation) { return new TopViewConfigure(pictureBoxNameList, dxf, null, 50.0d, 18.0d, 2.0d, 2.86f, 2.0d, 2.0d); }
/// <summary> /// 画phb类型的,单门只含有两个cirle的完整门窗,clm也是这个类型 /// </summary> /// <param name="doc"></param> /// <param name="DLocation"></param> /// <param name="DxfText"></param> /// <param name="height"></param> /// <param name="width"></param> /// <param name="outer_mid_space"></param> /// <param name="outer_in_space"></param> public static void writeWholeSingleDoorTwoCirle(DxfModel doc, DLocation DLocation, string[] DxfText, double height, double width, double outer_mid_space, double outer_in_space) { writeDoorRectangle(doc, DLocation, DxfText, height, width, outer_mid_space, outer_in_space); //两个个小圈 //底部 writeCirle(doc, new DLocation(DLocation.X + width * 3 / 4, DLocation.Y + 2 * outer_in_space, DLocation.Z), (outer_in_space - outer_mid_space) / 2); //顶部 writeCirle(doc, new DLocation(DLocation.X + width / 2, DLocation.Y + height - 2 * outer_in_space, DLocation.Z), (outer_in_space - outer_mid_space) / 2); }
/// <summary> /// 绘制订单信息块 /// </summary> /// <param name="dxf"></param> /// <param name="DLocation"></param> /// <param name="boxWidth"></param> /// <param name="configurations"></param> public static void Draw(DxfModel dxf, DLocation DLocation,double boxWidth, OrderEntity orderEntity) { double factor = 0.6f; Point3D v1 = new Point3D(DLocation.X,DLocation.Y,DLocation.Z); Point3D v2 = new Point3D(DLocation.X + boxWidth, DLocation.Y, DLocation.Z); Point3D v3 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 40.0d * factor, DLocation.Z); Point3D v4 = new Point3D(DLocation.X, DLocation.Y + 40.0d * factor, DLocation.Z); Point3D v5 = new Point3D(DLocation.X, DLocation.Y + 10.0d * factor, DLocation.Z); Point3D v6 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 10.0d * factor, DLocation.Z); Point3D v7 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y + 10.0d * factor, DLocation.Z); Point3D v8 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 10.0d * factor, DLocation.Z); Point3D v9 = new Point3D(DLocation.X + boxWidth * 7 / 8, DLocation.Y + 10.0d * factor, DLocation.Z); Point3D v10 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 20.0d * factor, DLocation.Z); Point3D v11 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y + 20.0d * factor, DLocation.Z); Point3D v12 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 20.0d * factor, DLocation.Z); Point3D v13 = new Point3D(DLocation.X + boxWidth * 7 / 8, DLocation.Y + 20.0d * factor, DLocation.Z); Point3D v14 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 20.0d * factor, DLocation.Z); Point3D v15 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y + 40.0d * factor, DLocation.Z); Point3D v16 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y + 40.0d * factor, DLocation.Z); Point3D v17 = new Point3D(DLocation.X + boxWidth / 4, DLocation.Y, DLocation.Z); Point3D v18 = new Point3D(DLocation.X + boxWidth / 2, DLocation.Y, DLocation.Z); Point3D v19 = new Point3D(DLocation.X + boxWidth * 3 / 4, DLocation.Y, DLocation.Z); Point3D v20 = new Point3D(DLocation.X + boxWidth, DLocation.Y + 10.0d * factor, DLocation.Z); //横向四道 DxfLine DxfLine12 = new DxfLine(v1, v2); dxf.Entities.Add(DxfLine12); DxfLine DxfLine520 = new DxfLine(v5, v20); dxf.Entities.Add(DxfLine520); DxfLine DxfLine1014 = new DxfLine(v10, v14); dxf.Entities.Add(DxfLine1014); DxfLine DxfLine43 = new DxfLine(v4, v3); dxf.Entities.Add(DxfLine43); //纵向6道 DxfLine DxfLine41 = new DxfLine(v4, v1); dxf.Entities.Add(DxfLine41); DxfLine DxfLine1517 = new DxfLine(v15, v17); dxf.Entities.Add(DxfLine1517); DxfLine DxfLine1118 = new DxfLine(v11, v18); dxf.Entities.Add(DxfLine1118); DxfLine DxfLine1619 = new DxfLine(v16, v19); dxf.Entities.Add(DxfLine1619); DxfLine DxfLine139 = new DxfLine(v13, v9); dxf.Entities.Add(DxfLine139); DxfLine DxfLine32= new DxfLine(v3, v2); dxf.Entities.Add(DxfLine32); //文字 Point3D vt1 = new Point3D(v1.X + 1.0d, v1.Y + 2.5f, v1.Z); DxfText t1 = new DxfText("Celebrity 1.0.0", vt1, 2.0d); dxf.Entities.Add(t1); Point3D vt2 = new Point3D(v17.X + 1.0d, v17.Y + 2.5f, v1.Z); DxfText t2 = new DxfText("PREPARER: "+orderEntity.Preparer, vt2, 2.0d); dxf.Entities.Add(t2); Point3D vt3 = new Point3D(v18.X + 1.0d, v18.Y + 2.5f, v1.Z); DxfText t3 = new DxfText("ENGINEER: "+orderEntity.Engineer, vt3, 2.0d); dxf.Entities.Add(t3); Point3D vt4 = new Point3D(v19.X + 1.0d, v19.Y + 2.5f, v1.Z); DxfText t4 = new DxfText("SHIP ORDER NO: "+orderEntity.ShipOrderNo, vt4, 2.0d); dxf.Entities.Add(t4); Point3D vt5 = new Point3D(v4.X + 1.0d, v10.Y + 2.5f, v1.Z); DxfText t5= new DxfText(" AAON COIL PRODUCTS inc.", vt5, 3.0d); dxf.Entities.Add(t5); Point3D vt6 = new Point3D(v5.X + 1.0d, v5.Y + 2.5f, v1.Z); DxfText t6 = new DxfText("LONGVIEW TEXAS", vt6, 2.0d); dxf.Entities.Add(t6); Point3D vt7 = new Point3D(v6.X + 1.0d, v6.Y + 2.5f, v1.Z); DxfText t7 = new DxfText("PURCHASER: " + orderEntity.Purchaser, vt7, 2.0d); dxf.Entities.Add(t7); Point3D vt8 = new Point3D(v7.X + 1.0d, v7.Y + 2.5f, v1.Z); DxfText t8 = new DxfText("PURCHASE ORDER: " + orderEntity.PurchaseOrder, vt8, 2.0d); dxf.Entities.Add(t8); Point3D vt9 = new Point3D(v8.X + 1.0d, v8.Y + 2.5f, v1.Z); DxfText t9 = new DxfText("SERIAL NO: " + orderEntity.SeriaNo, vt9, 2.0d); dxf.Entities.Add(t9); Point3D vt10 = new Point3D(v9.X + 1.0d, v9.Y + 2.5f, v1.Z); DxfText t10 = new DxfText("DATE: "+DateTime.Now.ToShortDateString(), vt10, 2.0d); dxf.Entities.Add(t10); Point3D vt11 = new Point3D(v15.X + 1.0d, v15.Y - 7.5f, v1.Z); DxfText t11 = new DxfText("JOB NAME:", vt11, 2.0d); dxf.Entities.Add(t11); Point3D vt12 = new Point3D(v10.X + 10.0d, v10.Y + 2.5f, v1.Z); DxfText t12 = new DxfText(orderEntity.JobName, vt12, 2.0d); dxf.Entities.Add(t12); Point3D vt13 = new Point3D(v16.X + 1.0d, v16.Y - 7.5f, v1.Z); DxfText t13 = new DxfText("UNIT TAG:", vt13, 2.0d); dxf.Entities.Add(t13); Point3D vt14 = new Point3D(v12.X + 20.0d, v12.Y + 2.5f, v1.Z); DxfText t14 = new DxfText(orderEntity.UnitTag, vt14, 2.0d); dxf.Entities.Add(t14); }
/// <summary> /// 过滤掉不符合条件的底部部分,是底部为平整的直线实体,方便计算最左边的顶点 /// </summary> /// <param name="sourceModel"></param> /// <returns></returns> public static DxfModel getFilterBottomNotLineDxfModel(DxfModel sourceModel) { DLocation relativeStartLocation = new DLocation(); double minX = Double.MaxValue; foreach (DxfEntity entity in sourceModel.Entities) { switch (entity.EntityType) { case "LINE": { DxfLine dxfLine = (DxfLine)entity; if (Math.Round(dxfLine.Start.Y * 10000) / 10000 == Math.Round(dxfLine.End.Y * 10000) / 10000) { if (Math.Round(minX * 10000) / 10000 >= Math.Round(dxfLine.Start.X * 10000) / 10000) { minX = dxfLine.Start.X; } } //消除画图人员错误绘制 if (Math.Round(dxfLine.Start.Y * 10000) / 10000 == Math.Round(dxfLine.End.Y * 10000) / 10000) { if (Math.Round(minX * 10000) / 10000 >= Math.Round(dxfLine.End.X * 10000) / 10000) { minX = dxfLine.End.X; } } }; continue; } } //将符合条件的entity加入到DxfModel中 DxfModel filterModel = new DxfModel(); foreach(DxfEntity entity in sourceModel.Entities) { switch(entity.EntityType) { case "LINE": { DxfLine dxfLine = (DxfLine)entity; //程序员绘画不规则造成 if (Math.Round(dxfLine.Start.X * 10000) / 10000 == Math.Round(minX*10000)/10000||Math.Round(dxfLine.End.X*10000)/10000==Math.Round(minX*10000)/10000) { filterModel.Entities.Add(dxfLine); } }continue; } } return filterModel; }