/// <summary> /// Define la transacción que dibuja las áreas de contacto de la compuerta /// No es necesario que sean visibles para realizar la prueba. /// </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 DrawZonesTask(Document doc, Transaction tr, object[] input) { Compuerta cmp = (Compuerta)input[0]; Drawer d = new Drawer(tr); cmp.InitBox(); cmp.DrawBox(d); return(d.Ids); }
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); }
public void ChecarCables() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId compId; if (Selector.Entity("Selecciona una compuerta", out compId)) { Compuerta cmp = this.Compuertas.FirstOrDefault(x => x.Value.Block.ObjectId == compId).Value; cmp.InitBox(); ObjectId cableAId = cmp.Search("INPUTA").OfType <ObjectId>().FirstOrDefault(), cableBId = cmp.Search("INPUTB").OfType <ObjectId>().FirstOrDefault(); TransactionWrapper tr = new TransactionWrapper(); tr.Run(TestConnectionTask, cmp, cableAId, cableBId); } }
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); }
public void Connect() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId inpId, outId; Point3d pt1; if (Selector.Entity("\nSelecciona un pulso", typeof(Polyline), out inpId) && Selector.Entity("Selecciona una Entrada", out outId, out pt1)) { Compuerta cmp = Commands.Compuertas.FirstOrDefault(x => x.Value.Block.ObjectId == outId).Value; cmp.InitBox(cmp.Name); ObjectId cableAId = cmp.Search("INPUTA").OfType <ObjectId>().FirstOrDefault(), cableBId = cmp.Search("INPUTB").OfType <ObjectId>().FirstOrDefault(); TransactionWrapper tr = new TransactionWrapper(); tr.Run(ConnectionTask, cmp, cableAId, cableBId, pt1, inpId); } }
public void ConnectFC() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId inpId, outId; Point3d pt1, pt2; if (Selector.Entity("\nSelecciona VCC o GND ", out inpId, out pt1) && Selector.Entity("\nSelecciona la entrada de conexión", out outId, out pt2)) { Compuerta cmp = Compuertas.FirstOrDefault(x => x.Value.Block.ObjectId == outId).Value; Input inpB = Entradas.FirstOrDefault(x => x.Value.Block.ObjectId == inpId).Value; cmp.InitBox(cmp.Name); inpB.InitBox(inpB.Name); ObjectId cableAId = cmp.Search("INPUTA").OfType <ObjectId>().FirstOrDefault(), cableBId = cmp.Search("INPUTB").OfType <ObjectId>().FirstOrDefault(), outputId = inpB.Search("OUTPUT").OfType <ObjectId>().FirstOrDefault(); TransactionWrapper tr = new TransactionWrapper(); tr.Run(ConnectionTask3, cmp, inpB, pt1, pt2, cableAId, cableBId, outputId); } }
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); }