public void DPulso() { Point3d insPt; Random r = new Random((int)DateTime.Now.Ticks); Boolean[] data = new Boolean[] { false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true }; int pulsoSize; if (Selector.Point("Selecciona el punto de inserción del pulso", out insPt) && Selector.Integer("El tamaño del pulso", out pulsoSize, 4)) { Boolean[] input = new Boolean[pulsoSize]; for (int i = 0; i < input.Length; i++) { input[i] = data[r.Next(data.Length - 1)]; } Pulso p = new Pulso(insPt, input); TransactionWrapper tr = new TransactionWrapper(); tr.Run(DPulsoTask, new Object[] { p }); } }
public void Dictionary() { ObjectId obj; if (Selector.Entity("Selecciona una entidad", out obj)) { TransactionWrapper tr = new TransactionWrapper(); tr.Run(DictionaryTask, obj); } }
public void DrawCasita() { Point3d insPt; Point3d endPt; if (Lab2.Selector.Point("Punto de inserción", out insPt) && Lab2.Selector.Point("El tamaño de la casita", out endPt, insPt)) { Casita c = new Casita(insPt.DistanceTo(endPt), insPt); TransactionWrapper tr = new TransactionWrapper(); tr.Run(DrawGeometry, c.Faces.ToArray()); } }
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); } }
public void InsertOR() { if (Compuertas == null) { Compuertas = new Dictionary <Handle, Compuerta>(); } Point3d pt; if (Selector.Point("Selecciona el punto de inserción de la compuerta", out pt)) { TransactionWrapper tr = new TransactionWrapper(); var cmp = tr.Run(InsertCompuertaTask, new OR(2), pt) as Compuerta; Compuertas.Add(cmp.Id, cmp); } }
public void InsertSalida() { if (Compuertas == null) { Compuertas = new Dictionary <Handle, Compuerta>(); } Point3d insPt; if (Selector.Point("Selecciona el punto de inserción de la salida", out insPt)) { TransactionWrapper tr = new TransactionWrapper(); var cmp = tr.Run(InsertCompuertaTask, new Output(), insPt) as Compuerta; Compuertas.Add(cmp.Id, cmp); } }
public void InsertGnd() { if (Entradas == null) { Entradas = new Dictionary <Handle, Input>(); } Point3d insPt; if (Selector.Point("Selecciona el punto de inserción de GND", out insPt)) { TransactionWrapper tr = new TransactionWrapper(); var inp = tr.Run(InsertEntradaTask, new Gnd(), insPt) as Input; Entradas.Add(inp.Id, inp); } }
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 DrawToroide() { Point3d pt; Point3d endPt; int p; if (Lab2.Selector.Point("Selecciona el centro", out pt) && Lab2.Selector.Point("El tamaño del toroide", out endPt, pt) && Lab2.Selector.Integer("Presición del toroide", out p, 4)) { double size = pt.DistanceTo(endPt); Toroide t = new Toroide(size, size / 2d, p, p, pt); t.Draw(); TransactionWrapper tr = new TransactionWrapper(); tr.Run(DrawGeometry, t.Faces.ToArray()); } }
public void DrawTriangle() { Point3d insPt; Point3d endPt; int order; if (Lab2.Selector.Point("Punto de inserción", out insPt) && Lab2.Selector.Point("El tamaño del triangulo", out endPt, insPt) && Lab2.Selector.Integer("El orden del triangulo", out order, 3)) { Sierpinski triangle = new Sierpinski(insPt, insPt.DistanceTo(endPt)); List <Entity> ents = new List <Entity>(); triangle.Draw(triangle, ref ents, order); TransactionWrapper tr = new TransactionWrapper(); tr.Run(DrawGeometry, ents.ToArray()); Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("Total de triangulos", ents.Count); } }
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); } }
public void TestCompuerta() { ObjectId p1Id, p2Id, cmpId; Point3d pt1, pt2; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; if (Selector.Entity("\nSelecciona un pulso", typeof(Polyline), out p1Id) && Selector.Entity("\nSelecciona la entrada de conexión", out cmpId, out pt1) && Selector.Entity("\nSelecciona un pulso", typeof(Polyline), out p2Id) && Selector.Entity("\nSelecciona la entrada de conexión", out cmpId, out pt2)) { TransactionWrapper tr = new TransactionWrapper(); Compuerta cmp = this.Compuertas.Values.FirstOrDefault(x => x.Block.Id == cmpId); if (cmp != null) { tr.Run(TestCompuertaTask, cmp, p1Id, p2Id, pt1, pt2); } else { ed.WriteMessage("No es Compuerta"); } } }
public void CargarCompuertas() { TransactionWrapper trW = new TransactionWrapper(); Object acadObj = Application.AcadApplication; acadObj.GetType().InvokeMember("ZoomExtents", System.Reflection.BindingFlags.InvokeMethod, null, acadObj, null); trW.TransactionTask = (Document doc, Transaction tr, object[] input) => { Compuertas = new Dictionary <Handle, Compuerta>(); BlockTable blockTable = doc.Database.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable; BlockTableRecord modelSpace = blockTable[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForRead) as BlockTableRecord; DBObject obj; BlockReference block; String[] appBlocks = new String[] { "OR", "AND", "NOR", "NAND", "XOR", "XNOR", "NOT", "VCC", "GND" }; foreach (var objId in modelSpace) { obj = objId.GetObject(OpenMode.ForRead); if (obj is BlockReference && appBlocks.Contains(((obj as BlockReference).Name))) { block = (obj as BlockReference); switch (block.Name) { case "OR": Compuertas.Add(obj.Handle, new OR(2) { Block = block }); break; case "AND": Compuertas.Add(obj.Handle, new AND(2) { Block = block }); break; case "NOR": Compuertas.Add(obj.Handle, new NOR(2) { Block = block }); break; case "NAND": Compuertas.Add(obj.Handle, new NAND(2) { Block = block }); break; case "XOR": Compuertas.Add(obj.Handle, new XOR(2) { Block = block }); break; case "XNOR": Compuertas.Add(obj.Handle, new XNOR(2) { Block = block }); break; case "NOT": Compuertas.Add(obj.Handle, new NOT() { Block = block }); break; case "GND": Entradas.Add(obj.Handle, new Gnd() { Block = block }); break; case "VCC": Entradas.Add(obj.Handle, new Vcc() { Block = block }); break; case "OUTPUT": Compuertas.Add(obj.Handle, new Output() { Block = block }); break; } } } return(null); }; trW.Run(trW.TransactionTask); acadObj.GetType().InvokeMember("ZoomPrevious", System.Reflection.BindingFlags.InvokeMethod, null, acadObj, null); }