{"id":201,"date":"2022-10-10T09:58:18","date_gmt":"2022-10-10T07:58:18","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=201"},"modified":"2022-10-10T13:48:30","modified_gmt":"2022-10-10T11:48:30","slug":"how-to-create-special-pads","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-create-special-pads\/","title":{"rendered":"How to create special pads"},"content":{"rendered":"\n<p>Some formats including elements how are not included in ODB++, for this you can create special pads. For existing elements its very easy to add them e.g.:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int index1 = IFilter.AddToolDefinitionRound(layer, 10, 0);\nint index2 = IFilter.AddToolDefinitionRect(layer, 20, 1, 20, 50, true);\nint index3 = IFilter.AddToolDefinitionDonut(layer, 50, 25, 2);\nint index4 = IFilter.AddToolDefinitionOct(layer, 40, 40, 40, 5, 3);<\/code><\/pre>\n\n\n\n<p>Then add your element and use the correct shape index from your definition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>IPadSpecifics padInfos = new IPadSpecifics();\npadInfos.Location = new PointF(400, 400);\npadInfos.Positiv = (true);\npad.SetSpecifics(padInfos, index1);<\/code><\/pre>\n\n\n\n<p>For ODB++ Features it is possible to create them form strings, in the same way like reading it from an ODB++ feature file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\/ &lt;summary&gt;\n\/\/\/ Creates an pad from an ODB++ String, please check specification for details.\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=\"pcbiFilter\"&gt;The creation object with reference to PCB-Investigator.&lt;\/param&gt;\n\/\/\/ &lt;param name=\"parentLayer\"&gt;The layer to add the new object.&lt;\/param&gt;\n\/\/\/ &lt;param name=\"location\"&gt;Where should the pad located?&lt;\/param&gt;\n\/\/\/ &lt;param name=\"ODBString\"&gt;The ODB++ specificated element.&lt;\/param&gt;\n\/\/\/ &lt;param name=\"symbolType\"&gt;To fill the property correct.&lt;\/param&gt;\n\/\/\/ &lt;returns&gt;The shape index for later using.&lt;\/returns&gt;\ninternal int CreatePadFromString(IFilter pcbiFilter, IODBLayer parentLayer, PointF location, string ODBString, PCBI.Symbol_Type symbolType)\n{\nIODBObject pad = pcbiFilter.CreatePad(parentLayer);\/\/create a new pad object\nIPadSpecifics specPad = (IPadSpecifics)pad.GetSpecifics();\nspecPad.Location = location;\nspecPad.ShapeIndex = IFilter.AddToolFromODBString(parentLayer, ODBString, -1);\n \nspecPad.Positiv = true;\nspecPad.Type = symbolType; \/\/for pads are many different symbols reasonable, special symbols can have all outlines you wan't (see there).\npad.SetSpecifics(specPad, specPad.ShapeIndex); \/\/activate the new setting.\n \nreturn specPad.ShapeIndex; \/\/maybe you want save the ShapeIndex in your own list.\n}<\/code><\/pre>\n\n\n\n<p>But for new elements its a little bit more work to do, first the CreateSpecialPad method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\/ &lt;summary&gt;\n\/\/\/ This only a specific example, you have to change some parts of it.\n\/\/\/ You can use the returned shape index to set the outline for more pads.\n\/\/\/ &lt;\/summary&gt;\ninternal static int CreateSpecialPad(IFilter pcbiFilter, IODBLayer parentLayer, PointF Location, List&lt;ExampleSurface.Grf_Object&gt; OutlineOfSpecialPad)\n{\nIODBObject t = pcbiFilter.CreateOutlinePolygon(); \/\/the t is only a temporary object to create a specifics!\nISurfaceSpecifics outline = (ISurfaceSpecifics)t.GetSpecifics(); \/\/put all outline elements in this object\nIODBObject padODB = null; \/\/this is the object in pcb-investigator.\nIPadSpecifics specPad = null; \/\/to set the specifics us this.\n \n#region example set outline\nbool started = false;\nforeach (IFilterDemoApp.ExampleSurface.Grf_Object obj in OutlineOfSpecialPad) \/\/you need a list of objects from your own class, here we hace Grf_Objects with Grf_Arc and Grf_Line\n{\nif (obj is IFilterDemoApp.ExampleSurface.Grf_Line) \/\/special class for Lines\n{\n#region line\nIFilterDemoApp.ExampleSurface.Grf_Line line = (IFilterDemoApp.ExampleSurface.Grf_Line)obj;\n\nif (!started)\n{\nstarted = true;\noutline.StartPolygon(false, line.Start);\n}\noutline.AddLine(line.Start, line.End); \/\/add the line to the outline of the special pad.\n#endregion\n}\nelse if (obj is IFilterDemoApp.ExampleSurface.Grf_Arc) \/\/special class for Arcs\n{\n#region arc\nIFilterDemoApp.ExampleSurface.Grf_Arc arc = (IFilterDemoApp.ExampleSurface.Grf_Arc)obj;\n\nif (!started)\n{\nstarted = true;\noutline.StartPolygon(false, arc.Start);\n}\n \noutline.AddArc(arc.Start, arc.End, arc.Center, arc.Clockwise);\n#endregion\n}\n#endregion\n}\n#endregion\n \noutline.EndPolygon();\nRectangleF bounds = outline.GetBounds();\n \nif (padODB == null)\npadODB = pcbiFilter.CreatePad(parentLayer);\nif (specPad == null)\nspecPad = (IPadSpecifics)padODB.GetSpecifics();\n \n\/\/maybe you save a counter, or use this:\nDictionary&lt;int, PCBI.Automation.IFilter.ToolDefinition&gt; symbolList = pcbiFilter.GetUsedSymbolList(parentLayer);\n \n\/\/The name should be descipe the outline or typenumber or the name in your specifics.\nspecPad.ShapeIndex = pcbiFilter.AddToolDefinitionSpecial(parentLayer, \"special_\" + \"name of pad\", outline, outline.GetBounds().Width, symbolList.Count + 1);\n \nspecPad.Positiv = true;\nspecPad.Type = PCBI.Symbol_Type.special;\nspecPad.Location.X = Location.X;\nspecPad.Location.Y = Location.Y;\n \npadODB.SetSpecifics(specPad, specPad.ShapeIndex);\n \nreturn specPad.ShapeIndex;\n}\n \ninternal class ExampleSurface\n{\n \ninternal class Grf_Object\n{ }\n\/\/\/ &lt;summary&gt;\n\/\/\/ The Line is a simple element with Start and End Points.\n\/\/\/ &lt;\/summary&gt;\n\ninternal class Grf_Line : Grf_Object\n{\ninternal PointF Start;\ninternal PointF End;\n}\n\/\/\/ &lt;summary&gt;\n\/\/\/ The Arc has more information for Center and direction of the arc.\n\/\/\/ &lt;\/summary&gt;\n\ninternal class Grf_Arc : Grf_Object\n{\ninternal PointF Start;\ninternal PointF End;\ninternal PointF Center;\ninternal bool Clockwise = true<\/code><\/pre>\n\n\n\n<p><strong><strong>Here is the example code in C Sharp and VB:<\/strong><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo5VBCode.zip\" target=\"_blank\" rel=\"noopener\">download VB<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo5CSharp.zip\" target=\"_blank\" rel=\"noopener\">download C#<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Some formats including elements how are not included in ODB++, for this you can create special pads. For existing elements its very easy to add them e.g.: Then add your element and use the correct shape index from your definition: For ODB++ Features it is possible to create them form strings, in the same way [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":246,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-201","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/201\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/201\/revisions\/202"}],"up":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/246"}],"wp:attachment":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}