/// <summary> /// Define la transacción que prueba la zona de contacto de la compuerta /// </summary> /// <param name="doc">El documento activo.</param> /// <param name="tr">La transacción activa.</param> /// <param name="input">La entrada de la transacción.</param> /// <returns>La compuerta insertada</returns> private object TestZoneTask(Document doc, Transaction tr, object[] input) { Compuerta cmp = (Compuerta)input[0]; Point3d test_pt; Editor ed = doc.Editor; while (Selector.Point("Selecciona una zona de contacto", out test_pt, true)) { string zoneName; Point3dCollection zone; cmp.GetZone(test_pt, out zoneName, out zone); if (zoneName == String.Empty) { ed.WriteMessage("\nPunto fuera de la zona"); } else { String coords = string.Empty; zone.OfType <Point3d>().ToList().ForEach(x => coords += String.Format("\n({0:N2},{1:N2})", x.X, x.Y)); ed.WriteMessage("\nCoordenadas:{1}\nPunto dentro de la zona {0}", zoneName, coords); //ed.WriteMessage("\n{0}", zoneName); } } return(null); }
private object ConnectionTask3(Document doc, Transaction tr, object[] input) { Compuerta cmp = (Compuerta)input[0]; Input cmpFrom = (Input)input[1]; cmp.InitBox(cmp.Name); cmpFrom.InitBox(cmpFrom.Name); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Point3d pt1 = (Point3d)input[3], pt2 = (Point3d)input[2]; String zoneA; Point3dCollection zone; cmp.GetZone(pt1, out zoneA, out zone); if (((ObjectId)input[6]).IsNull) { switch (zoneA) { case "INPUTA": if (((ObjectId)input[4]).IsNull) { Drawer d = new Drawer(tr); Line lA = new Line(cmpFrom.ConnectionPoints["OUTPUT"], cmp.ConnectionPoints[zoneA]); d.Entity(lA); } else { ed.WriteMessage("Ya existe un elemento conectado a esta entrada"); } break; case "INPUTB": if (((ObjectId)input[5]).IsNull) { Drawer d = new Drawer(tr); Line lA = new Line(cmpFrom.ConnectionPoints["OUTPUT"], cmp.ConnectionPoints[zoneA]); d.Entity(lA); } else { ed.WriteMessage("Ya existe un elemento conectado a esta entrada"); } break; case "OUTPUT": ed.WriteMessage("Imposible conectar con una salida"); break; } } else { ed.WriteMessage("Imposible conectar, prueba de nuevo"); } return(null); }
private object TestCompuertaTask(Document doc, Transaction tr, object[] input) { Compuerta cmp = (Compuerta)input[0]; cmp.InitBox(); Polyline p1 = ((ObjectId)input[1]).GetObject(OpenMode.ForRead) as Polyline; Polyline p2 = ((ObjectId)input[2]).GetObject(OpenMode.ForRead) as Polyline; Point3d pt1 = (Point3d)input[3]; Point3d pt2 = (Point3d)input[4]; String zoneA, zoneB; //No nos interesa en este ejemplo las coordenadas Point3dCollection zone; cmp.GetZone(pt1, out zoneA, out zone); cmp.GetZone(pt2, out zoneB, out zone); InputValue inA = new InputValue() { Name = zoneA, Value = Pulso.GetValues(p1) }, inB = new InputValue() { Name = zoneB, Value = Pulso.GetValues(p2) }; Boolean[] result = cmp.Solve(inA, inB); Drawer d = new Drawer(tr); Point3d pt; if (Selector.Point("Selecciona el punto de inserción de la salida", out pt)) { Pulso p = new Pulso(pt, result); p.Draw(d); Line lA = new Line(p1.EndPoint, cmp.ConnectionPoints[inA.Name]), lB = new Line(p2.EndPoint, cmp.ConnectionPoints[inB.Name]), lO = new Line(pt, cmp.ConnectionPoints["OUTPUT"]); d.Entities(lA, lB, lO); cmp.SetData(tr, doc, inA.Value.LastOrDefault(), inB.Value.LastOrDefault()); } return(null); }
private object ConnectionTask(Document doc, Transaction tr, object[] input) { Compuerta cmp = (Compuerta)input[0]; cmp.InitBox(cmp.Name); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Polyline p1 = ((ObjectId)input[4]).GetObject(OpenMode.ForRead) as Polyline; Point3d pt1 = (Point3d)input[3]; String zoneA; Point3dCollection zone; cmp.GetZone(pt1, out zoneA, out zone); switch (zoneA) { case "INPUTA": if (((ObjectId)input[1]).IsNull) { Drawer d = new Drawer(tr); Line lA = new Line(p1.EndPoint, cmp.ConnectionPoints[zoneA]); d.Entity(lA); } else { ed.WriteMessage("Ya existe un elemento conectado a esta entrada"); } break; case "INPUTB": if (((ObjectId)input[2]).IsNull) { Drawer d = new Drawer(tr); Line lA = new Line(p1.EndPoint, cmp.ConnectionPoints[zoneA]); d.Entity(lA); } else { ed.WriteMessage("Ya existe un elemento conectado a esta entrada"); } break; case "OUTPUT": ed.WriteMessage("Imposible conectar con una salida"); break; } return(null); }