public void Report_Via_Pad()
        {
            dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application"));

            wordApp.Visible = true;

            dynamic wordDoc = wordApp.Documents.Add();
            //////

            StringBuilder sb = new StringBuilder();

            IStep   step = Parent.GetCurrentStep();
            IMatrix m    = Parent.GetMatrix();

            foreach (INet NetList in step.GetNets())
            {
                foreach (IODBObject obj in NetList.GetAllNetObjects(Parent))
                {
                    if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            float         x  = ps.Location.X;
                            float         Y  = ps.Location.Y;
                            sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                        }
                    }
                }
            }
            //////
            string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString();

            dynamic rng = wordApp.ActiveDocument.Range(0, 0);

            rng.Text = LVText;

            System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp);
        }
示例#2
0
        public void Execute(IPCBIWindow parent)
        {
            if (parent == null)
            {
                return;
            }
            TextType tt = TextType.angle;

            ShowInputDialog(ref tt);

            // MessageBox.Show( tt.ToString());
            IMatrix m    = parent.GetMatrix();
            IStep   step = parent.GetCurrentStep();

            if (tt == TextType.angle)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;
                            double         angle     = PCBI.MathUtils.IMath.GetAngle(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End));
                            obj.FreeText = "? " + angle.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD   = (IPadSpecifics)os;
                            double        angle = PAD.Rotation;
                            obj.FreeText = "? " + angle.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.lenght)
            {
                foreach (string layerName in m.GetAllSignalLayerNames())
                {
                    IODBLayer layer = (IODBLayer)step.GetLayer(layerName);

                    foreach (IODBObject obj in layer.GetAllLayerObjects())
                    {
                        IObjectSpecifics os = obj.GetSpecifics();
                        if (os.GetType() == typeof(ILineSpecifics))
                        {
                            ILineSpecifics lineEdges = (ILineSpecifics)os;

                            double length = PCBI.MathUtils.IMath.DistancePointToPoint(PCBI.MathUtils.PointD.FromPointF(lineEdges.Start), PCBI.MathUtils.PointD.FromPointF(lineEdges.End)) / 100;
                            if (parent.GetUnit())
                            {
                                length *= 2.54f;
                            }
                            length       = Math.Round(length, 2);
                            obj.FreeText = "L: " + length.ToString();
                        }
                        if (os.GetType() == typeof(IPadSpecifics))
                        {
                            IPadSpecifics PAD    = (IPadSpecifics)os;
                            RectangleF    bounds = obj.GetBounds();
                            double        w      = bounds.Width / 100;
                            double        h      = bounds.Height / 100;

                            if (parent.GetUnit())
                            {
                                w *= 2.54f;
                                h *= 2.54f;
                            }
                            w            = Math.Round(w, 2);
                            h            = Math.Round(h, 2);
                            obj.FreeText = "w: " + w.ToString() + " h: " + h.ToString();
                        }
                    }
                }
            }
            if (tt == TextType.ViaCount)
            {
                foreach (INet NetList in step.GetNets())
                {
                    int drillCount = 0;
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                        {
                            drillCount++;
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "DrillCount: " + drillCount.ToString();
                    }
                }
            }
            if (tt == TextType.NetOnLayer)
            {
                foreach (INet NetList in step.GetNets())
                {
                    string LNames = "";
                    foreach (string LayerNames in NetList.GetAllUsedLayers(step))
                    {
                        if (m.GetMatrixLayerType(LayerNames) == MatrixLayerType.Signal)
                        {
                            LNames += LayerNames + "; ";
                        }
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "layer: " + LNames;
                    }
                }
            }
            if (tt == TextType.NetLength)
            {
                foreach (INet NetList in step.GetNets())
                {
                    double length = CalculateNetLenth(NetList.GetAllNetObjects(parent)) / 100;
                    if (parent.GetUnit())
                    {
                        length *= 2.54f;
                    }
                    foreach (IODBObject obj in NetList.GetAllNetObjects(parent))
                    {
                        obj.FreeText = "Netlength: " + Math.Round(length, 2);
                    }
                }
            }
            parent.ShowFreeTextInfoOnAllLayer = true;
            parent.UpdateView();
        }
        public void Report_Via_Pad()
        {
            var excelType = Type.GetTypeFromProgID("Excel.Application");

            dynamic excel = Activator.CreateInstance(excelType);

            excel.Visible = true;
            excel.Workbooks.Add();
            //////

            StringBuilder sb = new StringBuilder();

            IStep   step = Parent.GetCurrentStep();
            IMatrix m    = Parent.GetMatrix();

            foreach (INet NetList in step.GetNets())
            {
                foreach (IODBObject obj in NetList.GetAllNetObjects(Parent))
                {
                    if (m.GetMatrixLayerType(obj.GetParentLayerName()) == MatrixLayerType.Drill)
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            float         x  = ps.Location.X;
                            float         Y  = ps.Location.Y;
                            if (Parent.GetUnit())
                            {
                                float unit = 25.4f / 1000;
                                x = x * unit;
                                Y = Y * unit;
                            }
                            sb.Append("Via;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetTopSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_top;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                    else
                    if (obj.GetParentLayerName().ToLower() == m.GetBotSignalLayer().ToLower())
                    {
                        if (obj.Type == IObjectType.Pad)
                        {
                            IPadSpecifics ps = (IPadSpecifics)obj.GetSpecifics();
                            if (ps.Type != PCBI.Symbol_Type.r)
                            {
                                float x = ps.Location.X;
                                float Y = ps.Location.Y;
                                if (Parent.GetUnit())
                                {
                                    float unit = 25.4f / 1000;
                                    x = x * unit;
                                    Y = Y * unit;
                                }
                                sb.Append("PAD_bot;" + obj.NetName + ";" + x.ToString("N3") + ";" + Y.ToString("N3") + Environment.NewLine);
                            }
                        }
                    }
                }
            }
            //////

            //string LVText = "Type\tNetName\tposx\tposy" + Environment.NewLine + sb.ToString();
            string     LVText       = "Type;NetName;posx;posy" + Environment.NewLine + sb.ToString();
            string     LVCsv        = sb.ToString();
            DataObject LVDataObject = new DataObject();

            LVDataObject.SetData(DataFormats.Text, false, LVText);
            LVDataObject.SetData(DataFormats.CommaSeparatedValue, false, LVCsv);
            Clipboard.SetDataObject(LVDataObject, true);

            excel.ActiveSheet.Paste();

            //release the object
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
        }