/*Draw Mline*/ public static void DrawMLine(MLine xPoly, Canvas mainCanvas) { System.Windows.Shapes.Polyline wPoly = new System.Windows.Shapes.Polyline(); Vector2 vectTrans = new Vector2(); var i = 0; foreach (netDxf.Entities.MLineVertex xVertex in xPoly.Vertexes) { Vector2 vect = xVertex.Location; if (i > 0 && xPoly.Justification == netDxf.Entities.MLineJustification.Top) { Vector2 vect2 = vect - xPoly.Vertexes[i - 1].Location; vectTrans.X = vect2.Y; vectTrans.Y = vect2.X; vectTrans.Normalize(); vectTrans = Vector2.Multiply(vectTrans, xPoly.Scale / 2); } System.Windows.Point myPt = TypeConverter.Vertex2ToPoint(vect); myPt.Y = mainCanvas.Height - myPt.Y; wPoly.Points.Add(myPt); i++; } TranslateTransform translateTransform1 = new TranslateTransform(vectTrans.X, vectTrans.Y); wPoly.RenderTransform = translateTransform1; if (xPoly.IsClosed == true) wPoly.Points.Add(wPoly.Points[0]); TypeConverter.Entity2Shape(xPoly, wPoly); wPoly.StrokeThickness = xPoly.Scale; mainCanvas.Children.Add(wPoly); }
public void drawLine() { for (int i=0; i<graphicPoints.Length-1; i++) { MLine line1=new MLine(graphicPoints[i],graphicPoints[i+1],_transParent.transform,"line"); } MLine line=new MLine(graphicPoints[graphicPoints.Length-1],graphicPoints[0],_transParent.transform,"line"); }
public override void Build(CadDocumentBuilder builder) { base.Build(builder); MLine mLine = this.CadObject as MLine; if (builder.TryGetCadObject <MLStyle>(this.MLineStyleHandle, out MLStyle style)) { mLine.MLStyle = style; } }
public override void drawSymmetric () { GameObject horizSymm = new GameObject ("horizSymm"); horizSymm.tag = "reflectObj"; float dy = (point1.y - point2.y) / 8; for (int i=0; i<8; i++) { Vector3 ps=new Vector3(point1.x,point2.y+dy*i,point1.z); Vector3 pe=new Vector3(point1.x,point2.y+dy*i+dy-dy/7,point1.z); MLine line = new MLine (ps,pe,horizSymm.transform,"horiz"); line.obj.tag="symLine"; GameObject.Destroy(line.obj.GetComponent<dragLine>()); } }
public TestSuppleForm() { InitializeComponent(); this.m_board = new MBorad(); this.m_board.Dock = DockStyle.Fill; this.m_board.Location = new Point(0, 0); this.m_board.Name = "cBoard"; this.m_board.BackColor = Color.Black; //this.board.Click += Board_Click; //this.board.DoubleClick += Board_DoubleClick; //this.board.MouseWheel += Board_MouseWheel; this.Controls.Add(m_board); //四周的线条 lineUp = new MLine(); lineUp.FirstPoint = new POINT(this.Location.X + 10, this.Location.Y + 10); lineUp.SecondPoint = new POINT(this.Location.X + this.Width - 20, this.Location.Y + 10); lineUp.LineColor = 255; lineUp.Width = 1; lineLeft = new MLine(); lineLeft.FirstPoint = new POINT(this.Location.X + 10, this.Location.Y + 10); lineLeft.SecondPoint = new POINT(this.Location.X + 10, this.Location.Y + this.Height - 20); lineLeft.LineColor = 255; lineLeft.Width = 1; lineBottom = new MLine(); lineBottom.FirstPoint = new POINT(this.Location.X + 10, this.Location.Y + this.Height - 20); lineBottom.SecondPoint = new POINT(this.Location.X + this.Width - 20, this.Location.Y + this.Height - 20); lineBottom.LineColor = 255; lineBottom.Width = 1; lineRight = new MLine(); lineRight.FirstPoint = new POINT(this.Location.X + this.Width - 20, this.Location.Y + 10); lineRight.SecondPoint = new POINT(this.Location.X + this.Width - 20, this.Location.Y + this.Height - 20); lineRight.LineColor = 255; lineRight.Width = 1; m_board.AddControl(lineUp); m_board.AddControl(lineLeft); m_board.AddControl(lineBottom); m_board.AddControl(lineRight); this.m_board.Draw();//调用所有容器内的Onpaint重绘-MLine }
private CodeValuePair HandleMLine() { var codeValue = GetPair(); var mLine = new MLine(); var segment = new VertexSegment(); while (!Ended) { switch (codeValue.Code) { case 0: MLines.Add(mLine); return(codeValue); case 11: segment.Coordinate.X = codeValue.GetDouble(); break; case 21: segment.Coordinate.Y = codeValue.GetDouble(); break; case 31: segment.Coordinate.Z = codeValue.GetDouble(); mLine.Vertices.Add(segment); segment = new VertexSegment(); break; default: mLine.ParseCode(codeValue); break; } codeValue = GetPair(); } return(codeValue); }
private async void UpdateLine(MLine line) { ShapeOptionsLine.Visibility = Visibility.Visible; ShapeOptionsLineLabel.Visibility = Visibility.Visible; double sx, sy, ex, ey; try { sx = double.Parse(StartLocationXEdit.Text); sy = double.Parse(StartLocationYEdit.Text); ex = double.Parse(EndLocationXEdit.Text); ey = double.Parse(EndLocationYEdit.Text); } catch (Exception) { await InvalidValuesFormatDialog(); return; } line.StartLocation = new Point(sx, sy); line.EndLocation = new Point(ex, ey); }
public void pointTgraphic() { if (Input.GetMouseButtonDown (0) && graphicPoints.Count == 0) { Vector3 pos=Camera.main.ScreenToWorldPoint(Input.mousePosition); pos.z=10; pos=snapPoint(pos); graphicPoints.Add(pos); // creatmGraphic _graphic=new creatmGraphic(); // mGraphic=_graphic; // _graphic.InitGraphic(pos); // graphicTrans=_graphic._transParent.transform; graphicTrans=new GameObject("tempGraphic").transform; GameObject start=GameObject.Instantiate(pointPrefab); start.transform.position=pos; // start.name=_graphic._transName+"point0"; start.transform.parent=graphicTrans; clickCount=0; } if (Input.GetMouseButtonDown (0) && graphicPoints.Count>0&&clickCount>0){ Vector3 pos=Camera.main.ScreenToWorldPoint(Input.mousePosition); pos.z=10; pos=snapPoint(pos); if(graphicPoints[graphicPoints.Count-1]!=pos) { MLine line=new MLine(graphicPoints[graphicPoints.Count-1],pos,Color.black,graphicTrans); graphicPoints.Add(pos); GameObject point=GameObject.Instantiate(pointPrefab); point.transform.position=pos; // point.name=mGraphic._transName+"point"+clickCount.ToString(); point.transform.parent=graphicTrans; } if(graphicPoints[0]==pos) { // MLine line=new MLine(graphicPoints[graphicPoints.Count-1],pos,Color.black,graphicTrans); Destroy(GameObject.Find("tempGraphic")); mGraphic=new creatmGraphic(); mGraphic.InitGraphic(mGraphic.getcenter(graphicPoints)); mGraphic.drawGraphic(graphicPoints); mGraphic.creatLine(graphicPoints); mGraphic.creatPoint(graphicPoints); mGraphic._transParent.GetComponent<graphicMes>().setPointMes(graphicPoints); graphicPoints=new List<Vector3>(); //change state; state=Clickstate.oprateGraphic; } } clickCount++; }
public void linelenth() { if (Input.GetMouseButtonDown (0) && clickCount == 0) { lenthPos[0]=Camera.main.ScreenToWorldPoint(Input.mousePosition); lenthPos[0].z=10; lenthPos[0]=snapPoint(lenthPos[0]); GameObject start=GameObject.Instantiate(pointPrefab); start.transform.position=lenthPos[0]; start.name="lenthstart"; } if(Input.GetMouseButtonDown (0) && clickCount == 1) { lenthPos[1]=Camera.main.ScreenToWorldPoint(Input.mousePosition); lenthPos[1].z=10; lenthPos[1]=snapPoint(lenthPos[1]); Destroy(GameObject.Find("lenthstart")); } if(clickCount==1) { Vector3 center=new Vector3(); if(lenthPos[1].x!=lenthPos[0].x&&lenthPos[1].y!=lenthPos[0].y) { GameObject.Find("UI_Canvas").GetComponent<UISingleton>().setbtnMes("只可標示水平長度或垂直長度"); } else { lenth=(Mathf.RoundToInt(Vector3.Distance(lenthPos[0],lenthPos[1])/fgz_width)).ToString()+"cm"; MLine linelenth=new MLine(lenthPos[0],lenthPos[1],GameObject.Find("linelenth").transform,"linelenthobj"); if(lenthPos[0].x!=lenthPos[1].x) { Vector3 temp=lenthPos[0]; if(lenthPos[0].x>lenthPos[1].x) { lenthPos[0]=lenthPos[1]; lenthPos[1]=temp; } center=new Vector3(lenthPos[0].x+Vector3.Distance(lenthPos[0],lenthPos[1])/2,lenthPos[0].y+0.3f,lenthPos[0].z); for(int i=0;i<5;i++) { MLine linejt1=new MLine(lenthPos[0],new Vector3(lenthPos[0].x+0.2f,lenthPos[0].y+0.04f*i),linelenth.obj.transform,"jiantou"); MLine linejt2=new MLine(lenthPos[0],new Vector3(lenthPos[0].x+0.2f,lenthPos[0].y+0.04f*(-i)),linelenth.obj.transform,"jiantou"); MLine linejt3=new MLine(lenthPos[1],new Vector3(lenthPos[1].x-0.2f,lenthPos[1].y+0.04f*i),linelenth.obj.transform,"jiantou"); MLine linejt4=new MLine(lenthPos[1],new Vector3(lenthPos[1].x-0.2f,lenthPos[1].y+0.04f*(-i)),linelenth.obj.transform,"jiantou"); } } if(lenthPos[0].y!=lenthPos[1].y) { Vector3 temp=lenthPos[0]; if(lenthPos[0].y>lenthPos[1].y) { lenthPos[0]=lenthPos[1]; lenthPos[1]=temp; } center=new Vector3(lenthPos[0].x+0.5f,lenthPos[0].y+Vector3.Distance(lenthPos[0],lenthPos[1])/2,lenthPos[0].z); for(int i=0;i<5;i++) { MLine linejt1=new MLine(lenthPos[0],new Vector3(lenthPos[0].x+0.04f*i,lenthPos[0].y+0.2f),linelenth.obj.transform,"jiantou"); MLine linejt2=new MLine(lenthPos[0],new Vector3(lenthPos[0].x+0.04f*(-i),lenthPos[0].y+0.2f),linelenth.obj.transform,"jiantou"); MLine linejt3=new MLine(lenthPos[1],new Vector3(lenthPos[1].x+0.04f*i,lenthPos[1].y-0.2f),linelenth.obj.transform,"jiantou"); MLine linejt4=new MLine(lenthPos[1],new Vector3(lenthPos[1].x+0.04f*(-i),lenthPos[1].y-0.2f),linelenth.obj.transform,"jiantou"); } } GameObject shuzi=Instantiate(lenthshow); shuzi.transform.position=center; shuzi.transform.parent=linelenth.obj.transform; shuzi.GetComponent<TextMesh>().text=lenth; } lenthPos=new Vector3[2]; //change state; state=Clickstate.oprateGraphic; } clickCount = (clickCount>0)?0:1; }
public override void drawSymmetric() { GameObject horizSymm= new GameObject ("LD_RUSymm"); float dx = (point2.x - point1.x) / 12; for (int i=0; i<12; i++) { Vector3 ps=new Vector3(trigles[0].x+dx*i,trigles[3].y+dx*i,point1.z); Vector3 pe=new Vector3(trigles[0].x+dx*i+dx-dx/10,trigles[3].y+dx*i+dx-dx/10,point1.z); MLine line = new MLine (ps,pe,horizSymm.transform,"LD_RU"); GameObject.Destroy(line.obj.GetComponent<dragLine>()); } }
internal void SetLine(GameObject pathObject, Material mat) { line = new MLine(pathObject); line.SetMaterial(mat); line.sortingOrder = Statics.LineSortingOrder; }
public override void drawSymmetric () { GameObject horizSymm= new GameObject ("verticalSymm"); float dx = (point2.x - point1.x) / 8; for (int i=0; i<8; i++) { Vector3 ps=new Vector3(point1.x+dx*i,point2.y,point1.z); Vector3 pe=new Vector3(point1.x+dx*i+dx-dx/7,point2.y,point1.z); MLine line = new MLine (ps,pe,horizSymm.transform,"vertical"); GameObject.Destroy(line.obj.GetComponent<dragLine>()); } }
void setTwoLine(GameObject _point1,GameObject _point2) { Destroy (GameObject.Find ("line" + _point1.name)); Destroy (GameObject.Find ("line" + _point2.name)); MLine line1 = new MLine (points[0], points[1],_point1.transform); MLine line2 = new MLine (points[0], points[1],_point2.transform); }
internal bool RemoveEntity(EntityObject entity, bool isBlockEntity) { if (entity == null) { return(false); } if (entity.Handle == null) { return(false); } if (entity.Reactor != null) { return(false); } if (!this.AddedObjects.ContainsKey(entity.Handle)) { return(false); } // the entities that are part of a block do not belong to any of the entities lists but to the block definition // and they will not be removed from the drawing database bool removed; switch (entity.Type) { case EntityType.Arc: removed = this.arcs.Remove((Arc)entity); break; case EntityType.Circle: removed = this.circles.Remove((Circle)entity); break; case EntityType.Dimension: Dimension dimension = (Dimension)entity; removed = this.dimensions.Remove(dimension); if (removed || isBlockEntity) { this.dimStyles.References[dimension.Style.Name].Remove(entity); this.blocks.References[dimension.Block.Name].Remove(entity); } break; case EntityType.Ellipse: removed = this.ellipses.Remove((Ellipse)entity); break; case EntityType.Face3D: removed = this.faces3d.Remove((Face3d)entity); break; case EntityType.Spline: removed = this.splines.Remove((Spline)entity); break; case EntityType.Hatch: removed = this.hatches.Remove((Hatch)entity); break; case EntityType.Insert: Insert insert = (Insert)entity; removed = this.inserts.Remove(insert); if (removed || isBlockEntity) { this.blocks.References[insert.Block.Name].Remove(entity); foreach (Attribute att in insert.Attributes.Values) { this.layers.References[att.Layer.Name].Remove(att); this.lineTypes.References[att.LineType.Name].Remove(att); this.textStyles.References[att.Style.Name].Remove(att); } } break; case EntityType.LightWeightPolyline: removed = this.lwPolylines.Remove((LwPolyline)entity); break; case EntityType.Line: removed = this.lines.Remove((Line)entity); break; case EntityType.Point: removed = this.points.Remove((Point)entity); break; case EntityType.PolyfaceMesh: removed = this.polyfaceMeshes.Remove((PolyfaceMesh)entity); break; case EntityType.Polyline: removed = this.polylines.Remove((Polyline)entity); break; case EntityType.Solid: removed = this.solids.Remove((Solid)entity); break; case EntityType.Mesh: removed = this.meshes.Remove((Mesh)entity); break; case EntityType.Text: Text text = (Text)entity; this.textStyles.References[text.Style.Name].Remove(entity); removed = this.texts.Remove(text); break; case EntityType.MText: MText mText = (MText)entity; this.textStyles.References[mText.Style.Name].Remove(entity); removed = this.mTexts.Remove(mText); break; case EntityType.Image: Image image = (Image)entity; removed = this.images.Remove(image); if (removed || isBlockEntity) { this.imageDefs.References[image.Definition.Name].Remove(image); image.Definition.Reactors.Remove(image.Handle); } break; case EntityType.MLine: MLine mline = (MLine)entity; removed = this.mLines.Remove(mline); if (removed || isBlockEntity) { this.mlineStyles.References[mline.Style.Name].Remove(entity); } break; case EntityType.Ray: removed = this.rays.Remove((Ray)entity); break; case EntityType.XLine: removed = this.xlines.Remove((XLine)entity); break; case EntityType.Viewport: Viewport viewport = (Viewport)entity; removed = this.viewports.Remove(viewport); // delete the viewport boundary entity in case there is one if (removed && viewport.ClippingBoundary != null) { viewport.ClippingBoundary.Reactor = null; RemoveEntity(viewport.ClippingBoundary); } break; case EntityType.AttributeDefinition: AttributeDefinition attDef = (AttributeDefinition)entity; this.textStyles.References[attDef.Style.Name].Remove(entity); removed = this.attributeDefinitions.Remove(attDef); break; case EntityType.Attribute: throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of another entity", "entityObject"); default: throw new ArgumentException("The entity " + entity.Type + " is not implemented or unknown"); } if (removed || isBlockEntity) { // entities that belong to a block definition are not associated with a Layout. if (!isBlockEntity) { this.layouts.References[entity.Owner.Record.Layout.Name].Remove(entity); } this.layers.References[entity.Layer.Name].Remove(entity); this.lineTypes.References[entity.LineType.Name].Remove(entity); foreach (string appReg in entity.XData.AppIds) { this.appRegistries.References[appReg].Remove(entity); } this.AddedObjects.Remove(entity.Handle); entity.Owner = null; } return(removed); }
IEnumerator drawConnector(bool space) { Debug.Log("Start Checking Paths"); var connectorObject = new GameObject("ConnectionTest between " + path1.pathNumber + " and " + path2.pathNumber); connector = new MLine(connectorObject); connector.SetMaterial(level.pathMat); connector.sortingOrder = Statics.LineSortingOrder + 1; width = Statics.lineThickness / 2f; connector.width = width; connector.SetColor(Color.red); connector.SetLocalPosition(0, path1.GetPosition(0)); connector.SetLocalPosition(1, path2.GetPosition(0)); dot1 = Instantiate(level.dotPrefab); dot1.transform.position = path1.GetPosition(0); dot1.GetComponent <SpriteRenderer> ().color = connector.GetColor(); GameObject.Destroy(dot1.GetComponentInChildren <TrailRenderer> ()); dot1.GetComponent <SpriteRenderer> ().sortingOrder = connector.sortingOrder; dot1.transform.localScale = width * 2 * Vector3.one; dot2 = Instantiate(level.dotPrefab); dot2.transform.position = path2.GetPosition(0); dot2.GetComponent <SpriteRenderer> ().color = connector.GetColor(); GameObject.Destroy(dot2.GetComponentInChildren <TrailRenderer> ()); dot2.GetComponent <SpriteRenderer> ().sortingOrder = connector.sortingOrder; dot2.transform.localScale = width * 2 * Vector3.one; var maxDistance = 1f; var speed = 10f; var meanTime = 1f / speed; var timeForStep1 = meanTime; var timeForStep2 = meanTime; if (space == false) { if (path1.Count < path2.Count) { timeForStep2 = ((float)path1.Count / path2.Count) * timeForStep1; } else { timeForStep1 = ((float)path2.Count / path1.Count) * timeForStep2; } } Debug.Log(path1.Count * timeForStep1 + " vs. " + path2.Count * timeForStep2); Debug.Log(timeForStep1 + " vs. " + timeForStep2); var timeGone1 = 0f; var timeGone2 = 0f; var i = 1; var j = 1; while (i < path1.Count - 1 || j < path2.Count - 1) { if (i < path1.Count - 1 && connector.GetLocalPosition(0) == path1.GetPosition(i)) { i++; timeGone1 = timeGone1 - timeForStep1; } if (j < path2.Count - 1 && connector.GetLocalPosition(1) == path2.GetPosition(j)) { j++; timeGone2 = timeGone2 - timeForStep2; } timeGone1 += Time.deltaTime; timeGone2 += Time.deltaTime; // var t = GetPercentage (path1, i) - GetPercentage (path2, j); // timeForStep1 = 1f / (speed + Mathf.Lerp (-speed, speed, 0.5f - t / 2)); // timeForStep2 = 1f / (speed + Mathf.Lerp (-speed, speed, 0.5f + t / 2)); // Debug.Log ("t = " + t + ", factor= " + (0.5f - t / 2) + ", lerp = " + Mathf.Lerp (-speed, speed, 0.5f - t / 2) + ", timeForStep1-meantime = " + (timeForStep1 - meanTime)); connector.SetLocalPosition(0, Vector3.Lerp(path1.GetPosition(i - 1), path1.GetPosition(i), timeGone1 / timeForStep1)); connector.SetLocalPosition(1, Vector3.Lerp(path2.GetPosition(j - 1), path2.GetPosition(j), timeGone2 / timeForStep2)); connector.width = width * (1 - Vector3.Distance(connector.GetLocalPosition(0), connector.GetLocalPosition(1)) / (maxDistance * 1.1f)); connector.SetMesh(); dot1.transform.position = connector.GetLocalPosition(0); dot2.transform.position = connector.GetLocalPosition(1); if (Vector3.Distance(dot1.transform.position, dot2.transform.position) > maxDistance) { StartCoroutine(ShrinkConnector(3f)); yield return(new WaitForSeconds(5)); Destroy(connectorObject); Destroy(dot1); Destroy(dot2); yield break; } yield return(null); } if (isHomotopic) { level.ShowHintCanvas(); LevelData.showHint("The paths are homotopic!"); yield return(new WaitForSeconds(5)); level.HideHintCanvas(); } yield break; }
public static void Process(MLine isoLine) => Messenger.Default.Send(new MLineMessage() { Value = isoLine.Value });
public override void reflectPlane (LinkList pointStr) { reflectPos=new Vector3[pointStr.Length()]; base.setPointStr(pointStr); base.setPointPos (); for (int i=0; i<allPointPos.Length; i++) { float x=allPointPos[i].x+(point1.x-allPointPos[i].x)*2; reflectPos[i]=new Vector3(x,allPointPos[i].y,allPointPos[i].z); } GameObject refPlane = new GameObject ("horizPlane"); refPlane.tag = "reflectObj"; for (int i=0; i<reflectPos.Length-1; i++) { MLine line = new MLine (reflectPos[i],reflectPos[i+1],refPlane.transform,"reflectline"); GameObject.Destroy(line.obj.GetComponent<dragLine>()); line.obj.tag="refLine"; } }
public void drawDragLine() { destroyDragLine (); if (points.Count == 1) { MLine line1 = new MLine (link1, points[0], link1.transform); line1.setColor(GameControl.getColor); MLine line2 = new MLine ( points[0],link2, points[0].transform); line2.setColor(GameControl.getColor); } if (points.Count == 2) { MLine line1 = new MLine (link1, points[1], link1.transform); line1.setColor(GameControl.getColor); line1.obj.AddComponent<LinePoints> ().setLinePoint (link1.name, points [1].name); MLine line2 = new MLine (points[1],link2, link2.transform); line2.setColor(GameControl.getColor); line2.obj.AddComponent<LinePoints> ().setLinePoint (points [1].name,link2.name ); } temp1 = 0; temp2 = 0; }
void DestroylineDrag() { if(hasPlane) Destroy (GameObject.Find(GameControl.GameControlInstance.getPlaneName(changeDragPoint(DragNailName)))); Is_drag = false; //fuyuan if (points.Count == 1) { destroyDragLine(); MLine lineOri=new MLine(link1,link2,link1.transform); lineOri.setColor(GameControl.getColor); lineOri.obj.AddComponent<LinePoints> ().setLinePoint (link1.name,link2.name); } //add links if (points.Count == 2) { points[1].GetComponent<Renderer>().material.color=Color.red; if(points[1].GetComponent<AddNailPoint>()==null) points[1].AddComponent<AddNailPoint>(); // GameControl.nailControl.mPoints.Remove(GameControl.mLinks); //// GameControl.nailControl.mColor.Remove(GameControl.getColor); GameControl.nailControl.mPoints.RemoveAt(getNailIndex); GameControl.nailControl.mColor.RemoveAt(getNailIndex); for(int i=1;i<GameControl.mLinks.Length();i++) { if(GameControl.mLinks.get_Listnode(i).Equals(link1.name)&&GameControl.mLinks.get_Listnode(i+1).Equals(link2.name)) { GameControl.mLinks.Insert(i,points[1].name); } } GameControl.nailControl.mPoints.Add(GameControl.mLinks); GameControl.nailControl.mColor.Add(GameControl.getColor); } GameControl.GameControlInstance.setNailing (); lineIndexs.Clear (); pointLinks.Clear (); Destroy(GameObject.Find("dragObj")); Destroy (line); points.Clear (); // GameControl.mLinks = new VectorList.LinkList (); GameControl.mLinks = GameControl.nailControl.mPoints[GameControl.nailControl.mPoints.Count-1]; }
protected void setFirstLine(GameObject _point1,GameObject _point2) { setColor (); MLine line1 = new MLine (_point1,_point2, _point1.transform); line1.setColor (GameControl.getColor); MLine line2 = new MLine (_point2,_point1, _point2.transform); line2.setColor (GameControl.getColor); addCompent (_point1); addCompent (_point2); line1.obj.AddComponent<LinePoints> ().setLinePoint (_point1.name, _point2.name); line2.obj.AddComponent<LinePoints> ().setLinePoint (_point2.name, _point1.name); GameControl.mLines=new List<Line> (); GameControl.mLinks=new LinkList(); GameControl.GameControlInstance.addLinePoint (_point1.name, _point2.name); GameControl.GameControlInstance.addLinePoint (_point2.name, _point1.name); GameControl.mLinks.Insert (0,_point1.name); GameControl.mLinks.Insert (1,_point2.name); GameControl.mLinks.Insert (2,_point1.name); GameControl.nailControl.mPoints.Add (GameControl.mLinks); GameControl.nailControl.mColor.Add (GameControl.getColor); GameControl.GameControlInstance.setNailing (); }
IEnumerator cutGraphic() { if (Input.GetMouseButtonDown (0) && clickCount == 0){ changelControl (); if(changeObj) { updateListPos(); parentList=new List<Vector3>(); for(int i=0;i<ControlObj.GetComponent<graphicMes>().graphicPointsMes.Count;i++) { parentList.Add(ControlObj.GetComponent<graphicMes>().graphicPointsMes[i]); } childList1=new List<Vector3>(); childList2=new List<Vector3>(); childList=new List<List<Vector3>>(); } else { clickCount=-1; } } if (isCut && Input.GetMouseButtonDown (0) && clickCount == 1){ mouseStartpos=Camera.main.ScreenToWorldPoint(Input.mousePosition); mouseStartpos.z=0; // startPos=setMousePos(Camera.main.ScreenToWorldPoint(Input.mousePosition),out startFlag); GameObject cutStart=(GameObject)Instantiate (pointPrefab,mouseStartpos,transform.rotation); cutStart.name="cutStart"; } if (isCut && Input.GetMouseButtonDown (0) && clickCount >= 2) { while(Input.GetMouseButton(0)) { if(GameObject.Find("cutline")!=null) Destroy(GameObject.Find("cutline")); mouseEndPos=Camera.main.ScreenToWorldPoint(Input.mousePosition); mouseEndPos.z=0; MLine line=new MLine(mouseStartpos,mouseEndPos,Color.black,GameObject.Find("cutStart").transform); line.obj.name="cutline"; yield return new WaitForFixedUpdate(); } if(GameObject.Find("cutline")!=null) Destroy(GameObject.Find("cutStart")); //crosspoint and crossflag cutGraphic mcut=new cutGraphic(); mcut.initCutGriphic(mouseStartpos,mouseEndPos); if(mcut.cutOperate()) { Destroy(ControlObj); yield return new WaitForFixedUpdate(); setChildgraphic(mcut.childList); setChildgraphic(mcut.originList); } clickCount=-1; //change state; state=Clickstate.oprateGraphic; } clickCount++; yield return null; }
private void PointerPressedDraw(bool rightButtonPressed, Point startPosition) { if (CurrentShapeType == ShapeType.Polygon || CurrentShapeType == ShapeType.Bezier) { DrawClickTool.IsChecked = true; SelectedTool = Tools.DrawClick; } if (SelectedTool == Tools.DrawClick) { if (CurrentShapeType == ShapeType.Polygon || CurrentShapeType == ShapeType.Bezier) { if (ClickedTimes++ >= 1) { if (rightButtonPressed) { if (ClickedTimes >= 4) { ClickedTimes = 0; var poly = PendingShape as MPolygon; if (CurrentShapeType == ShapeType.Polygon) { poly.AddSegment(poly.StartLocation); } poly.StartLocation = new Point(0, 0); poly.EndLocation = new Point(0, 0); poly.Closed = true; AddShape(); return; } else { --ClickedTimes; } } else { if (CurrentShapeType == ShapeType.Polygon || CurrentShapeType == ShapeType.Bezier) { (PendingShape as MPolygon).AddSegment(startPosition); } } this.canvasControl.Invalidate(); return; } } else { if (ClickedTimes == 0) { ClickedTimes = 1; } else { ClickedTimes = 0; AddShape(); return; } } } if (CurrentShapeType == ShapeType.Rectangle) { PendingShape = new MRectangle(startPosition, startPosition); } else if (CurrentShapeType == ShapeType.Circle) { PendingShape = new MCircle(startPosition, startPosition); } else if (CurrentShapeType == ShapeType.Line) { PendingShape = new MLine(startPosition, startPosition); } else if (CurrentShapeType == ShapeType.Polygon) { PendingShape = new MPolygon(startPosition, startPosition); } else if (CurrentShapeType == ShapeType.Bezier) { PendingShape = new MBezier(startPosition, startPosition); } PendingShape.Mode = ShapeModes.Drawing; this.canvasControl.Invalidate(); }
void drawLine(Vector3 pos1,Vector3 pos2) { MLine line = new MLine (pos1,pos2,Color.black,GameObject.Find("squeue").transform); line.setLineWidth (0.005f); }
public CadMLineTemplate(MLine mline) : base(mline) { }
internal bool AddEntity(EntityObject entity, bool isBlockEntity, bool assignHandle) { // no null entities allowed if (entity == null) { return(false); } if (!string.IsNullOrEmpty(entity.Handle)) { // check if the entity handle has been assigned if (this.AddedObjects.ContainsKey(entity.Handle)) { // if the handle is equal the entity might come from another document, check if it is exactly the same object DxfObject existing = this.AddedObjects[entity.Handle]; // if the entity is already in the document return false, do not add it again if (existing.Equals(entity)) { return(false); } } } if (assignHandle) { this.NumHandles = entity.AsignHandle(this.NumHandles); } // the entities that are part of a block do not belong to any of the entities lists but to the block definition. switch (entity.Type) { case EntityType.Arc: if (!isBlockEntity) { this.arcs.Add((Arc)entity); } break; case EntityType.Circle: if (!isBlockEntity) { this.circles.Add((Circle)entity); } break; case EntityType.Dimension: Dimension dim = (Dimension)entity; dim.Style = this.dimStyles.Add(dim.Style, assignHandle); this.dimStyles.References[dim.Style.Name].Add(dim); // create the block that represent the dimension drawing Block dimBlock = dim.Block; if (dimBlock == null) { dimBlock = dim.BuildBlock("*D" + ++this.DimensionBlocksGenerated); } dim.Block = this.blocks.Add(dimBlock); this.blocks.References[dimBlock.Name].Add(dim); if (!isBlockEntity) { this.dimensions.Add(dim); } break; case EntityType.Ellipse: if (!isBlockEntity) { this.ellipses.Add((Ellipse)entity); } break; case EntityType.Face3D: if (!isBlockEntity) { this.faces3d.Add((Face3d)entity); } break; case EntityType.Spline: if (!isBlockEntity) { this.splines.Add((Spline)entity); } break; case EntityType.Hatch: Hatch hatch = (Hatch)entity; hatch.AddPatternXData(); if (!isBlockEntity) { this.hatches.Add(hatch); } break; case EntityType.Insert: Insert insert = (Insert)entity; insert.Block = this.blocks.Add(insert.Block, assignHandle); this.blocks.References[insert.Block.Name].Add(insert); foreach (Attribute attribute in insert.Attributes.Values) { attribute.Layer = this.layers.Add(attribute.Layer, assignHandle); this.layers.References[attribute.Layer.Name].Add(attribute); attribute.LineType = this.lineTypes.Add(attribute.LineType, assignHandle); this.lineTypes.References[attribute.LineType.Name].Add(attribute); attribute.Style = this.textStyles.Add(attribute.Style, assignHandle); this.textStyles.References[attribute.Style.Name].Add(attribute); } if (!isBlockEntity) { this.inserts.Add(insert); } break; case EntityType.LightWeightPolyline: if (!isBlockEntity) { this.lwPolylines.Add((LwPolyline)entity); } break; case EntityType.Line: if (!isBlockEntity) { this.lines.Add((Line)entity); } break; case EntityType.Point: if (!isBlockEntity) { this.points.Add((Point)entity); } break; case EntityType.PolyfaceMesh: if (!isBlockEntity) { this.polyfaceMeshes.Add((PolyfaceMesh)entity); } break; case EntityType.Polyline: if (!isBlockEntity) { this.polylines.Add((Polyline)entity); } break; case EntityType.Solid: if (!isBlockEntity) { this.solids.Add((Solid)entity); } break; case EntityType.Mesh: if (!isBlockEntity) { this.meshes.Add((Mesh)entity); } break; case EntityType.Text: Text text = (Text)entity; text.Style = this.textStyles.Add(text.Style, assignHandle); this.textStyles.References[text.Style.Name].Add(text); if (!isBlockEntity) { this.texts.Add(text); } break; case EntityType.MText: MText mText = (MText)entity; mText.Style = this.textStyles.Add(mText.Style, assignHandle); this.textStyles.References[mText.Style.Name].Add(mText); if (!isBlockEntity) { this.mTexts.Add(mText); } break; case EntityType.Image: Image image = (Image)entity; image.Definition = this.imageDefs.Add(image.Definition, assignHandle); this.imageDefs.References[image.Definition.Name].Add(image); if (!image.Definition.Reactors.ContainsKey(image.Handle)) { ImageDefReactor reactor = new ImageDefReactor(image.Handle); this.NumHandles = reactor.AsignHandle(this.NumHandles); image.Definition.Reactors.Add(image.Handle, reactor); } if (!isBlockEntity) { this.images.Add(image); } break; case EntityType.MLine: MLine mline = (MLine)entity; mline.Style = this.mlineStyles.Add(mline.Style, assignHandle); this.mlineStyles.References[mline.Style.Name].Add(mline); if (!isBlockEntity) { this.mLines.Add(mline); } break; case EntityType.Ray: if (!isBlockEntity) { this.rays.Add((Ray)entity); } break; case EntityType.XLine: if (!isBlockEntity) { this.xlines.Add((XLine)entity); } break; case EntityType.Viewport: Viewport viewport = (Viewport)entity; this.AddEntity(viewport.ClippingBoundary, isBlockEntity, assignHandle); if (!isBlockEntity) { this.viewports.Add(viewport); } break; case EntityType.AttributeDefinition: AttributeDefinition attDef = (AttributeDefinition)entity; attDef.Style = this.textStyles.Add(attDef.Style, assignHandle); this.textStyles.References[attDef.Style.Name].Add(attDef); if (!isBlockEntity) { this.attributeDefinitions.Add(attDef); } break; case EntityType.Attribute: throw new ArgumentException("The entity " + entity.Type + " is only allowed as part of an insert entity.", "entity"); default: throw new ArgumentException("The entity " + entity.Type + " is not implemented or unknown."); } foreach (string appReg in entity.XData.AppIds) { entity.XData[appReg].ApplicationRegistry = this.appRegistries.Add(entity.XData[appReg].ApplicationRegistry, assignHandle); this.appRegistries.References[appReg].Add(entity); } if (!isBlockEntity) { entity.Owner = this.layouts[this.activeLayout].AssociatedBlock; this.layouts.References[this.activeLayout].Add(entity); } this.AddedObjects.Add(entity.Handle, entity); entity.Layer = this.layers.Add(entity.Layer, assignHandle); this.layers.References[entity.Layer.Name].Add(entity); entity.LineType = this.lineTypes.Add(entity.LineType, assignHandle); this.lineTypes.References[entity.LineType.Name].Add(entity); return(true); }
public void creatLine(List<Vector3> posList) { for (int i=0; i<posList.Count-1; i++) { MLine line=new MLine(posList[i],posList[i+1],Color.black,_transParent.transform); } }
void DoubleClick(string point) { if (hasPlane) Destroy (GameObject.Find(GameControl.GameControlInstance.getPlaneName(GameControl.mLinks))); GameControl.GameControlInstance.PointgetNailIndex (point); int pointIndex = GameControl.mLinks.get_Index (point); if (GameControl.mLinks.Length () > 3) { if(pointIndex==1) { Destroy(GameObject.Find("line"+point+GameControl.mLinks.get_Listnode(2))); Destroy(GameObject.Find("line"+GameControl.mLinks.get_Listnode(GameControl.mLinks.Length()-1)+point)); GameControl.nailControl.mPoints.Remove(GameControl.mLinks); GameControl.mLinks.Delete(pointIndex); GameControl.mLinks.Delete(GameControl.mLinks.Length()); GameControl.mLinks.Insert(GameControl.mLinks.Length(),GameControl.mLinks.get_Listnode(1)); string point1=GameControl.mLinks.get_Listnode(GameControl.mLinks.Length()-1); string point2=GameControl.mLinks.get_Listnode(GameControl.mLinks.Length()); MLine line=new MLine (GameObject.Find(point1),GameObject.Find(point2),GameObject.Find(point1).transform); line.obj.AddComponent<LinePoints>().setLinePoint(point1,point2); GameControl.nailControl.mPoints.Add(GameControl.mLinks); } else { string str="line"+point+GameControl.mLinks.get_Listnode(pointIndex+1); Destroy(GameObject.Find("line"+point+GameControl.mLinks.get_Listnode(pointIndex+1))); Destroy(GameObject.Find("line"+GameControl.mLinks.get_Listnode(pointIndex-1)+point)); GameControl.nailControl.mPoints.Remove(GameControl.mLinks); GameControl.mLinks.Delete(pointIndex); GameControl.nailControl.mPoints.Add(GameControl.mLinks); } if(!GameControl.GameControlInstance.IsExist(GameObject.Find( point))) Destroy(GameObject.Find(point).GetComponent<AddNailPoint>()); } if(hasPlane) { ScaningLine mScan = new ScaningLine (); mScan._color=GameControl.getColor; mScan.getPoint (GameControl.mLinks); mScan.ScanLinePolygonFill (); } if (GameControl.isReflect) { GameControl.GameControlInstance.drawReflect (GameControl.mLinks,true); } GameControl.GameControlInstance.updaLine (); GameControl.GameControlInstance.setNailing (); }
public void drawRLine(Vector3 pos1,Vector3 pos2) { List<Vector3> pointMes = new List<Vector3> (); pointMes.Add (pos1); pointMes.Add (pos2); _transName="Rline"+ GameControl.findCount (graphicStyle.right_line).ToString(); MLine line = new MLine (pos1,pos2,Color.yellow,GameControl.graphicsParent.transform); line.obj.name = _transName; _transStyle = graphicStyle.right_line; line.obj.AddComponent<graphicMes>().setMes(_transName,_transStyle); line.obj.GetComponent<graphicMes> ().setPointMes (pointMes); GameObject.Find ("linestart").transform.parent = line.obj.transform; GameObject.Find("linestart").name=_transName+"start"; GameObject.Find ("linend").transform.parent = line.obj.transform; GameObject.Find("linend").name=_transName+"nd"; }
private static void ShowDxfDocumentInformation(DxfDocument dxf) { Console.WriteLine("FILE VERSION: {0}", dxf.DrawingVariables.AcadVer); Console.WriteLine(); Console.WriteLine("FILE COMMENTS: {0}", dxf.Comments.Count); foreach (var o in dxf.Comments) { Console.WriteLine("\t{0}", o); } Console.WriteLine(); Console.WriteLine("FILE TIME:"); Console.WriteLine("\tdrawing created (UTC): {0}.{1}", dxf.DrawingVariables.TduCreate, dxf.DrawingVariables.TduCreate.Millisecond.ToString("000")); Console.WriteLine("\tdrawing last update (UTC): {0}.{1}", dxf.DrawingVariables.TduUpdate, dxf.DrawingVariables.TduUpdate.Millisecond.ToString("000")); Console.WriteLine("\tdrawing edition time: {0}", dxf.DrawingVariables.TdinDwg); Console.WriteLine(); Console.WriteLine("APPLICATION REGISTRIES: {0}", dxf.ApplicationRegistries.Count); foreach (var o in dxf.ApplicationRegistries) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ApplicationRegistries.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("LAYERS: {0}", dxf.Layers.Count); foreach (var o in dxf.Layers) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layers.GetReferences(o).Count); Debug.Assert(ReferenceEquals(o.Linetype, dxf.Linetypes[o.Linetype.Name]), "Object reference not equal."); } Console.WriteLine(); Console.WriteLine("LINE TYPES: {0}", dxf.Linetypes.Count); foreach (var o in dxf.Linetypes) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Linetypes.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("TEXT STYLES: {0}", dxf.TextStyles.Count); foreach (var o in dxf.TextStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.TextStyles.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("SHAPE STYLES: {0}", dxf.ShapeStyles.Count); foreach (var o in dxf.ShapeStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ShapeStyles.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("DIMENSION STYLES: {0}", dxf.DimensionStyles.Count); foreach (var o in dxf.DimensionStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.DimensionStyles.GetReferences(o.Name).Count); Debug.Assert(ReferenceEquals(o.TextStyle, dxf.TextStyles[o.TextStyle.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.DimLineLinetype, dxf.Linetypes[o.DimLineLinetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.ExtLine1Linetype, dxf.Linetypes[o.ExtLine1Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.ExtLine2Linetype, dxf.Linetypes[o.ExtLine2Linetype.Name]), "Object reference not equal."); if (o.DimArrow1 != null) { Debug.Assert(ReferenceEquals(o.DimArrow1, dxf.Blocks[o.DimArrow1.Name]), "Object reference not equal."); } if (o.DimArrow2 != null) { Debug.Assert(ReferenceEquals(o.DimArrow2, dxf.Blocks[o.DimArrow2.Name]), "Object reference not equal."); } } Console.WriteLine(); Console.WriteLine("MLINE STYLES: {0}", dxf.MlineStyles.Count); foreach (var o in dxf.MlineStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.MlineStyles.GetReferences(o.Name).Count); foreach (var e in o.Elements) { Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal."); } } Console.WriteLine(); Console.WriteLine("UCSs: {0}", dxf.UCSs.Count); foreach (var o in dxf.UCSs) { Console.WriteLine("\t{0}", o.Name); } Console.WriteLine(); Console.WriteLine("BLOCKS: {0}", dxf.Blocks.Count); foreach (var o in dxf.Blocks) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Blocks.GetReferences(o.Name).Count); Debug.Assert(ReferenceEquals(o.Layer, dxf.Layers[o.Layer.Name]), "Object reference not equal."); foreach (var e in o.Entities) { Debug.Assert(ReferenceEquals(e.Layer, dxf.Layers[e.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(e.Owner, dxf.Blocks[o.Name]), "Object reference not equal."); foreach (var x in e.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } Text txt = e as Text; if (txt != null) { Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal."); } MText mtxt = e as MText; if (mtxt != null) { Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal."); } Dimension dim = e as Dimension; if (dim != null) { Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal."); } MLine mline = e as MLine; if (mline != null) { Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal."); } Image img = e as Image; if (img != null) { Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal."); } Insert ins = e as Insert; if (ins != null) { Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal."); foreach (var a in ins.Attributes) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal."); } } } foreach (var a in o.AttributeDefinitions.Values) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); foreach (var x in a.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } } } Console.WriteLine(); Console.WriteLine("LAYOUTS: {0}", dxf.Layouts.Count); foreach (var o in dxf.Layouts) { Debug.Assert(ReferenceEquals(o.AssociatedBlock, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal."); Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layouts.GetReferences(o.Name).Count); List <DxfObject> entities = dxf.Layouts.GetReferences(o.Name); foreach (var e in entities) { EntityObject entity = e as EntityObject; if (entity != null) { Debug.Assert(ReferenceEquals(entity.Layer, dxf.Layers[entity.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(entity.Linetype, dxf.Linetypes[entity.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(entity.Owner, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal."); foreach (var x in entity.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } } Text txt = e as Text; if (txt != null) { Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal."); } MText mtxt = e as MText; if (mtxt != null) { Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal."); } Dimension dim = e as Dimension; if (dim != null) { Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal."); } MLine mline = e as MLine; if (mline != null) { Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal."); } Image img = e as Image; if (img != null) { Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal."); } Insert ins = e as Insert; if (ins != null) { Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal."); foreach (var a in ins.Attributes) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal."); } } } } Console.WriteLine(); Console.WriteLine("IMAGE DEFINITIONS: {0}", dxf.ImageDefinitions.Count); foreach (var o in dxf.ImageDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.ImageDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("DGN UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDgnDefinitions.Count); foreach (var o in dxf.UnderlayDgnDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.UnderlayDgnDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("DWF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDwfDefinitions.Count); foreach (var o in dxf.UnderlayDwfDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.UnderlayDwfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("PDF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayPdfDefinitions.Count); foreach (var o in dxf.UnderlayPdfDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.File, dxf.UnderlayPdfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("GROUPS: {0}", dxf.Groups.Count); foreach (var o in dxf.Groups) { Console.WriteLine("\t{0}; Entities count: {1}", o.Name, o.Entities.Count); } Console.WriteLine(); // the entities lists contain the geometry that has a graphical representation in the drawing across all layouts, // to get the entities that belongs to a specific layout you can get the references through the Layouts.GetReferences(name) // or check the EntityObject.Owner.Record.Layout property Console.WriteLine("ENTITIES:"); Console.WriteLine("\t{0}; count: {1}", EntityType.Arc, dxf.Arcs.Count()); //Console.WriteLine("\t{0}; count: {1}", EntityType.AttributeDefinition, dxf.AttributeDefinitions.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Circle, dxf.Circles.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Dimension, dxf.Dimensions.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Ellipse, dxf.Ellipses.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Face3D, dxf.Faces3d.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Hatch, dxf.Hatches.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Image, dxf.Images.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Insert, dxf.Inserts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Leader, dxf.Leaders.Count()); Console.WriteLine("\t{0}; count: {1}", "LwPolyline", dxf.LwPolylines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Line, dxf.Lines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Mesh, dxf.Meshes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.MLine, dxf.MLines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.MText, dxf.MTexts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Point, dxf.Points.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.PolyfaceMesh, dxf.PolyfaceMeshes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Polyline, dxf.Polylines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Shape, dxf.Shapes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Solid, dxf.Solids.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Spline, dxf.Splines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Text, dxf.Texts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Ray, dxf.Rays.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Underlay, dxf.Underlays.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Viewport, dxf.Viewports.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Wipeout, dxf.Wipeouts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.XLine, dxf.XLines.Count()); Console.WriteLine(); Console.WriteLine("Press a key to continue..."); Console.ReadLine(); }
public static DxfDocument Test(string file, string output = null) { // optionally you can save the information to a text file bool outputLog = !string.IsNullOrEmpty(output); TextWriter writer = null; if (outputLog) { writer = new StreamWriter(File.Create(output)); Console.SetOut(writer); } // check if the dxf actually exists FileInfo fileInfo = new FileInfo(file); if (!fileInfo.Exists) { Console.WriteLine("THE FILE {0} DOES NOT EXIST", file); Console.WriteLine(); if (outputLog) { writer.Flush(); writer.Close(); } else { Console.WriteLine("Press a key to continue..."); Console.ReadLine(); } return(null); } bool isBinary; DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file, out isBinary); // check if the file is a dxf if (dxfVersion == DxfVersion.Unknown) { Console.WriteLine("THE FILE {0} IS NOT A VALID DXF OR THE DXF DOES NOT INCLUDE VERSION INFORMATION IN THE HEADER SECTION", file); Console.WriteLine(); if (outputLog) { writer.Flush(); writer.Close(); } else { Console.WriteLine("Press a key to continue..."); Console.ReadLine(); } return(null); } // check if the dxf file version is supported if (dxfVersion < DxfVersion.AutoCad2000) { Console.WriteLine("THE FILE {0} IS NOT A SUPPORTED DXF", file); Console.WriteLine(); Console.WriteLine("FILE VERSION: {0}", dxfVersion); Console.WriteLine(); if (outputLog) { writer.Flush(); writer.Close(); } else { Console.WriteLine("Press a key to continue..."); Console.ReadLine(); } return(null); } // DxfDocument dxf = DxfDocument.Load(file, new List<string> { @".\Support" }); DxfDocument dxf = DxfDocument.Load(file); // check if there has been any problems loading the file, // this might be the case of a corrupt file or a problem in the library if (dxf == null) { Console.WriteLine("ERROR LOADING {0}", file); Console.WriteLine(); Console.WriteLine("Press a key to continue..."); Console.ReadLine(); if (outputLog) { writer.Flush(); writer.Close(); } else { Console.WriteLine("Press a key to continue..."); Console.ReadLine(); } return(null); } // the dxf has been properly loaded, let's show some information about it Console.WriteLine("FILE NAME: {0}", file); Console.WriteLine("\tbinary dxf: {0}", isBinary); Console.WriteLine(); Console.WriteLine("FILE VERSION: {0}", dxf.DrawingVariables.AcadVer); Console.WriteLine(); Console.WriteLine("FILE COMMENTS: {0}", dxf.Comments.Count); foreach (var o in dxf.Comments) { Console.WriteLine("\t{0}", o); } Console.WriteLine(); Console.WriteLine("FILE TIME:"); Console.WriteLine("\tdrawing created (UTC): {0}.{1}", dxf.DrawingVariables.TduCreate, dxf.DrawingVariables.TduCreate.Millisecond.ToString("000")); Console.WriteLine("\tdrawing last update (UTC): {0}.{1}", dxf.DrawingVariables.TduUpdate, dxf.DrawingVariables.TduUpdate.Millisecond.ToString("000")); Console.WriteLine("\tdrawing edition time: {0}", dxf.DrawingVariables.TdinDwg); Console.WriteLine(); Console.WriteLine("APPLICATION REGISTRIES: {0}", dxf.ApplicationRegistries.Count); foreach (var o in dxf.ApplicationRegistries) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ApplicationRegistries.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("LAYERS: {0}", dxf.Layers.Count); foreach (var o in dxf.Layers) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layers.GetReferences(o).Count); Debug.Assert(ReferenceEquals(o.Linetype, dxf.Linetypes[o.Linetype.Name]), "Object reference not equal."); } Console.WriteLine(); Console.WriteLine("LINE TYPES: {0}", dxf.Linetypes.Count); foreach (var o in dxf.Linetypes) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Linetypes.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("TEXT STYLES: {0}", dxf.TextStyles.Count); foreach (var o in dxf.TextStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.TextStyles.GetReferences(o.Name).Count); } Console.WriteLine(); //Console.WriteLine("SHAPE STYLES: {0}", dxf.ShapeStyles.Count); //foreach (var o in dxf.ShapeStyles) //{ // Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.ShapeStyles.GetReferences(o.Name).Count); //} //Console.WriteLine(); Console.WriteLine("DIMENSION STYLES: {0}", dxf.DimensionStyles.Count); foreach (var o in dxf.DimensionStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.DimensionStyles.GetReferences(o.Name).Count); Debug.Assert(ReferenceEquals(o.TextStyle, dxf.TextStyles[o.TextStyle.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.DimLineLinetype, dxf.Linetypes[o.DimLineLinetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.ExtLine1Linetype, dxf.Linetypes[o.ExtLine1Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(o.ExtLine2Linetype, dxf.Linetypes[o.ExtLine2Linetype.Name]), "Object reference not equal."); if (o.DimArrow1 != null) { Debug.Assert(ReferenceEquals(o.DimArrow1, dxf.Blocks[o.DimArrow1.Name]), "Object reference not equal."); } if (o.DimArrow2 != null) { Debug.Assert(ReferenceEquals(o.DimArrow2, dxf.Blocks[o.DimArrow2.Name]), "Object reference not equal."); } } Console.WriteLine(); Console.WriteLine("MLINE STYLES: {0}", dxf.MlineStyles.Count); foreach (var o in dxf.MlineStyles) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.MlineStyles.GetReferences(o.Name).Count); foreach (var e in o.Elements) { Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal."); } } Console.WriteLine(); Console.WriteLine("UCSs: {0}", dxf.UCSs.Count); foreach (var o in dxf.UCSs) { Console.WriteLine("\t{0}", o.Name); } Console.WriteLine(); Console.WriteLine("BLOCKS: {0}", dxf.Blocks.Count); foreach (var o in dxf.Blocks) { Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Blocks.GetReferences(o.Name).Count); Debug.Assert(ReferenceEquals(o.Layer, dxf.Layers[o.Layer.Name]), "Object reference not equal."); foreach (var e in o.Entities) { Debug.Assert(ReferenceEquals(e.Layer, dxf.Layers[e.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(e.Linetype, dxf.Linetypes[e.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(e.Owner, dxf.Blocks[o.Name]), "Object reference not equal."); foreach (var x in e.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } Text txt = e as Text; if (txt != null) { Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal."); } MText mtxt = e as MText; if (mtxt != null) { Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal."); } Dimension dim = e as Dimension; if (dim != null) { Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal."); } MLine mline = e as MLine; if (mline != null) { Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal."); } Image img = e as Image; if (img != null) { Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal."); } Insert ins = e as Insert; if (ins != null) { Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal."); foreach (var a in ins.Attributes) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal."); } } } foreach (var a in o.AttributeDefinitions.Values) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); foreach (var x in a.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } } } Console.WriteLine(); Console.WriteLine("LAYOUTS: {0}", dxf.Layouts.Count); foreach (var o in dxf.Layouts) { Debug.Assert(ReferenceEquals(o.AssociatedBlock, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal."); Console.WriteLine("\t{0}; References count: {1}", o.Name, dxf.Layouts.GetReferences(o.Name).Count); List <DxfObject> entities = dxf.Layouts.GetReferences(o.Name); foreach (var e in entities) { EntityObject entity = e as EntityObject; if (entity != null) { Debug.Assert(ReferenceEquals(entity.Layer, dxf.Layers[entity.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(entity.Linetype, dxf.Linetypes[entity.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(entity.Owner, dxf.Blocks[o.AssociatedBlock.Name]), "Object reference not equal."); foreach (var x in entity.XData.Values) { Debug.Assert(ReferenceEquals(x.ApplicationRegistry, dxf.ApplicationRegistries[x.ApplicationRegistry.Name]), "Object reference not equal."); } } Text txt = e as Text; if (txt != null) { Debug.Assert(ReferenceEquals(txt.Style, dxf.TextStyles[txt.Style.Name]), "Object reference not equal."); } MText mtxt = e as MText; if (mtxt != null) { Debug.Assert(ReferenceEquals(mtxt.Style, dxf.TextStyles[mtxt.Style.Name]), "Object reference not equal."); } Dimension dim = e as Dimension; if (dim != null) { Debug.Assert(ReferenceEquals(dim.Style, dxf.DimensionStyles[dim.Style.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(dim.Block, dxf.Blocks[dim.Block.Name]), "Object reference not equal."); } MLine mline = e as MLine; if (mline != null) { Debug.Assert(ReferenceEquals(mline.Style, dxf.MlineStyles[mline.Style.Name]), "Object reference not equal."); } Image img = e as Image; if (img != null) { Debug.Assert(ReferenceEquals(img.Definition, dxf.ImageDefinitions[img.Definition.Name]), "Object reference not equal."); } Insert ins = e as Insert; if (ins != null) { Debug.Assert(ReferenceEquals(ins.Block, dxf.Blocks[ins.Block.Name]), "Object reference not equal."); foreach (var a in ins.Attributes) { Debug.Assert(ReferenceEquals(a.Layer, dxf.Layers[a.Layer.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Linetype, dxf.Linetypes[a.Linetype.Name]), "Object reference not equal."); Debug.Assert(ReferenceEquals(a.Style, dxf.TextStyles[a.Style.Name]), "Object reference not equal."); } } } } Console.WriteLine(); Console.WriteLine("IMAGE DEFINITIONS: {0}", dxf.ImageDefinitions.Count); foreach (var o in dxf.ImageDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.ImageDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("DGN UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDgnDefinitions.Count); foreach (var o in dxf.UnderlayDgnDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayDgnDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("DWF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayDwfDefinitions.Count); foreach (var o in dxf.UnderlayDwfDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayDwfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("PDF UNDERLAY DEFINITIONS: {0}", dxf.UnderlayPdfDefinitions.Count); foreach (var o in dxf.UnderlayPdfDefinitions) { Console.WriteLine("\t{0}; File name: {1}; References count: {2}", o.Name, o.FileName, dxf.UnderlayPdfDefinitions.GetReferences(o.Name).Count); } Console.WriteLine(); Console.WriteLine("GROUPS: {0}", dxf.Groups.Count); foreach (var o in dxf.Groups) { Console.WriteLine("\t{0}; Entities count: {1}", o.Name, o.Entities.Count); } Console.WriteLine(); Console.WriteLine("ATTRIBUTE DEFINITIONS for the \"Model\" Layout: {0}", dxf.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions.Count); foreach (var o in dxf.Layouts[Layout.ModelSpaceName].AssociatedBlock.AttributeDefinitions) { Console.WriteLine("\tTag: {0}", o.Value.Tag); } Console.WriteLine(); // the entities lists contain the geometry that has a graphical representation in the drawing across all layouts, // to get the entities that belongs to a specific layout you can get the references through the Layouts.GetReferences(name) // or check the EntityObject.Owner.Record.Layout property Console.WriteLine("ENTITIES for the Active Layout = {0}:", dxf.ActiveLayout); Console.WriteLine("\t{0}; count: {1}", EntityType.Arc, dxf.Arcs.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Circle, dxf.Circles.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Dimension, dxf.Dimensions.Count()); foreach (var a in dxf.Dimensions) { foreach (var styleOverride in a.StyleOverrides.Values) { switch (styleOverride.Type) { case DimensionStyleOverrideType.DimLineLinetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.ExtLine1Linetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.ExtLine2Linetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.TextStyle: Debug.Assert(ReferenceEquals((TextStyle)styleOverride.Value, dxf.TextStyles[((TextStyle)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.LeaderArrow: Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.DimArrow1: if (styleOverride.Value == null) { break; } Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.DimArrow2: if (styleOverride.Value == null) { break; } Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; } } } Console.WriteLine("\t{0}; count: {1}", EntityType.Ellipse, dxf.Ellipses.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Face3D, dxf.Faces3d.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Hatch, dxf.Hatches.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Image, dxf.Images.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Insert, dxf.Inserts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Leader, dxf.Leaders.Count()); foreach (var a in dxf.Leaders) { foreach (var styleOverride in a.StyleOverrides.Values) { switch (styleOverride.Type) { case DimensionStyleOverrideType.DimLineLinetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.ExtLine1Linetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.ExtLine2Linetype: Debug.Assert(ReferenceEquals((Linetype)styleOverride.Value, dxf.Linetypes[((Linetype)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.TextStyle: Debug.Assert(ReferenceEquals((TextStyle)styleOverride.Value, dxf.TextStyles[((TextStyle)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.LeaderArrow: Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.DimArrow1: Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; case DimensionStyleOverrideType.DimArrow2: Debug.Assert(ReferenceEquals((Block)styleOverride.Value, dxf.Blocks[((Block)styleOverride.Value).Name]), "Object reference not equal."); break; } } } Console.WriteLine("\t{0}; count: {1}", EntityType.LightWeightPolyline, dxf.LwPolylines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Line, dxf.Lines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Mesh, dxf.Meshes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.MLine, dxf.MLines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.MText, dxf.MTexts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Point, dxf.Points.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.PolyfaceMesh, dxf.PolyfaceMeshes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Polyline, dxf.Polylines.Count()); // Console.WriteLine("\t{0}; count: {1}", EntityType.Shape, dxf.Shapes.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Solid, dxf.Solids.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Spline, dxf.Splines.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Text, dxf.Texts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Ray, dxf.Rays.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Underlay, dxf.Underlays.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Viewport, dxf.Viewports.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.Wipeout, dxf.Wipeouts.Count()); Console.WriteLine("\t{0}; count: {1}", EntityType.XLine, dxf.XLines.Count()); Console.WriteLine(); // the dxf version is controlled by the DrawingVariables property of the dxf document, // also a HeaderVariables instance or a DxfVersion can be passed to the constructor to initialize a new DxfDocument. // dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2018; // dxf.Save("sample 2018.dxf"); dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2013; dxf.Save("sample 2013.dxf"); dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2010; dxf.Save("sample 2010.dxf"); dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007; dxf.Save("sample 2007.dxf"); dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2004; dxf.Save("sample 2004.dxf"); dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2000; dxf.Save("sample 2000.dxf"); // saving to binary dxf dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2013; dxf.Save("binary test.dxf", true); // DxfDocument test = DxfDocument.Load("binary test.dxf", new List<string> { @".\Support" }); DxfDocument test = DxfDocument.Load("binary test.dxf"); if (outputLog) { writer.Flush(); writer.Close(); } else { Console.WriteLine("Press a key to continue..."); Console.ReadLine(); } return(dxf); }