示例#1
0
            public override string ToString()
            {
                //    OutputString($"outputting {Name}");
                try
                {
                    PadComparer pc = new PadComparer();
                    // put pads in numerical order (not really necessary)
                    Pads.Sort(pc);
                    if (Attr == "smd")
                    {
                        foreach (var pad in Pads)
                        {
                            if (pad.Type == "thru_hole")
                            {
                                Attr = "";
                            }
                        }
                    }

                    StringBuilder ret = new StringBuilder("");
                    //X -= Globals.MinX;
                    //Y -= Globals.MaxY;
                    string LOCKED = (Locked) ? "locked" : "";
                    ret.Append($"  (module \"{Name}\" {LOCKED} (layer {Layer}) {Tedit} {Tstamp}\n");
                    ret.Append($"    (at {X} {-(Y)} {Rotation})\n");
                    if (Attr != "")
                    {
                        ret.Append($"    (attr {Attr})\n");
                    }

                    // this bit is for a particular test board where the idiot had put the Comment as .designator
                    if (Strings != null)
                    {
                        foreach (var str in Strings)
                        {
                            if (str.Value.ToLower() == ".comment")
                            {
                                str.Value = Comment;
                            }
                            if (str.Value.ToLower() == ".designator")
                            {
                                str.Value = Designator;
                            }
                        }
                    }

                    if (Strings != null)
                    {
                        ret.Append(Strings.ToString(X, Y, Rotation));
                    }


                    if (Pads != null)
                    {
                        ret.Append(Pads.ToString(X, Y, Rotation));
                    }
                    // ret += Vias.ToString(X, Y, Rotation); // vias not allowed in modules...yet
                    if (Lines != null)
                    {
                        ret.Append(Lines.ToString(X, Y, -Rotation));
                    }
                    if (Arcs != null)
                    {
                        ret.Append(Arcs.ToString(X, Y, -Rotation));
                    }
                    if (Fills != null)
                    {
                        ret.Append(Fills.ToString(X, Y, -Rotation));
                    }
                    if (Polygons != null)
                    {
                        ret.Append(Polygons.ToString());
                    }
                    if (Regions != null)
                    {
                        ret.Append(Regions.ToString(X, Y, -Rotation));
                    }
                    CurrentLayer = Layer;
                    if (ComponentBodies != null)
                    {
                        ret.Append(ComponentBodies.ToString(X, Y, Rotation));                          // (Layer=="F.Cu")?-Rotation:-(Rotation-180));
                    }
                    if (ShapeBasedModels != null)
                    {
                        ret.Append(ShapeBasedModels.ToString(X, Y, -Rotation));
                    }
                    ret.Append("  )\n");
                    return(ret.ToString());
                }
                catch (Exception Ex)
                {
                    CheckThreadAbort(Ex);
                    return("");
                }
            }
示例#2
0
            public override string ToString()
            {
                //    OutputString($"outputting {Name}");
                try
                {
                    string ret = "";
                    ret  = $"  (module \"{Name}\" (layer {Layer}) {Tedit} {Tstamp}\n";
                    ret += $"    (at {X} {-Y} {Rotation})\n";
                    ret += $"    (attr {Attr})\n";

                    // this bit is for a particular test board where the idiot had put the Comment as .designator
                    if (Strings != null)
                    {
                        foreach (var str in Strings)
                        {
                            if (str.Value.ToLower() == ".comment")
                            {
                                str.Value = Comment;
                            }
                            if (str.Value.ToLower() == ".designator")
                            {
                                str.Value = Designator;
                            }
                        }
                    }

                    if (Strings != null)
                    {
                        ret += Strings.ToString(X, Y, Rotation);
                    }

                    PadComparer pc = new PadComparer();
                    // put pads in numerical order (not really necessary)
                    Pads.Sort(pc);

                    if (Pads != null)
                    {
                        ret += Pads.ToString(X, Y, Rotation);
                    }
                    // ret += Vias.ToString(X, Y, Rotation); // vias not allowed in modules...yet
                    if (Lines != null)
                    {
                        ret += Lines.ToString(X, Y, -Rotation);
                    }
                    if (Arcs != null)
                    {
                        ret += Arcs.ToString(X, Y, -Rotation);
                    }
                    if (Fills != null)
                    {
                        ret += Fills.ToString(X, Y, -Rotation);
                    }
                    if (Polygons != null)
                    {
                        ret += Polygons.ToString();
                    }
                    if (Regions != null)
                    {
                        ret += Regions.ToString(X, Y, -Rotation);
                    }
                    CurrentLayer = Layer;
                    if (ComponentBodies != null)
                    {
                        ret += ComponentBodies.ToString(X, Y, Rotation);                          // (Layer=="F.Cu")?-Rotation:-(Rotation-180));
                    }
                    if (ShapeBasedModels != null)
                    {
                        ret += ShapeBasedModels.ToString(X, Y, -Rotation);
                    }
                    ret += "  )\n";
                    return(ret);
                }
                catch (Exception Ex)
                {
                    CheckThreadAbort(Ex);
                    return("");
                }
            }