{"id":219,"date":"2022-10-10T10:16:47","date_gmt":"2022-10-10T08:16:47","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=219"},"modified":"2022-10-10T13:49:24","modified_gmt":"2022-10-10T11:49:24","slug":"how-to-load-a-gerber-layer","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-load-a-gerber-layer\/","title":{"rendered":"How to load a Gerber layer"},"content":{"rendered":"\n<p>As easy example to use PCB-Investigator as library here the code to load a gerber layer and count elements on it. Its important to add the reference of PCB-Investigator first and add using PCBI.Automation.<\/p>\n\n\n\n<p><strong>Here is the example code in C Sharp and VB:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo1VB.zip\" target=\"_blank\" rel=\"noopener\">download VB<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo1CSharp.zip\" target=\"_blank\" rel=\"noopener\">download C#<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo1_CLI.zip\" target=\"_blank\" rel=\"noopener\">download C++<\/a><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\/ &lt;summary&gt;\n    \/\/\/ Create an overview how much elements on one gerberlayer.\n    \/\/\/ &lt;\/summary&gt;\n    private static void CreateGerberReport()\n    {\n      IAutomation.IAutomationInit();\n \n      \/\/create a window to handle your actions\n      IPCBIWindow mainWindowPCBI = IAutomation.CreateNewPCBIWindow(false);\n \n      \/\/create a directory for ODB++ structure with one step names \"pcb\"\n      string jobPath = mainWindowPCBI.CreateNewJobDirectory(@\"C:\\tests\\FirstTestJob\", \"FirstTestJob\", \"pcb\");\n \n      \/\/after creating the directory we have to load it\n      mainWindowPCBI.LoadODBJob(jobPath);\n \n      IStep firstStep = mainWindowPCBI.GetStep(\"pcb\");\n \n      \/\/show a dialog to select the first layer from an gerber file\n      OpenFileDialog openDLG = new OpenFileDialog();\n      openDLG.Title = \"Select gerber file for demo application\";\n      if (openDLG.ShowDialog() != System.Windows.Forms.DialogResult.OK)\n        return;\n \n      \/\/we load the gerberdata in one layer and remember the layername\n      string gerberLayerName = firstStep.AddGerberLayer(openDLG.FileName, false);\n \n      \/\/we need the ILayer object for handling data of the gerberfile\n      ILayer GerberLayer = firstStep.GetLayer(gerberLayerName);\n \n      \/\/now we make an report of all element types\n \n      int counterPads = 0;\n      int counterLines = 0;\n      int counterArcs = 0;\n      int counterOthers = 0;\n      foreach (IObject ObjOnGerber in GerberLayer.GetAllLayerObjects())\n      {\n        if (ObjOnGerber.Type == IObjectType.Pad)\n          counterPads++;\n        else if (ObjOnGerber.Type == IObjectType.Line)\n          counterLines++;\n        else if (ObjOnGerber.Type == IObjectType.Arc)\n          counterArcs++;\n        else\n          counterOthers++;\n      }\n \n      Console.WriteLine(\"Report Gerber File \" + gerberLayerName);\n      Console.WriteLine(\"Pads: \" + counterPads.ToString());\n      Console.WriteLine(\"Lines: \" + counterLines.ToString());\n      Console.WriteLine(\"Arcs: \" + counterArcs.ToString());\n      Console.WriteLine(\"Others: \" + counterOthers.ToString());\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As easy example to use PCB-Investigator as library here the code to load a gerber layer and count elements on it. Its important to add the reference of PCB-Investigator first and add using PCBI.Automation. Here is the example code in C Sharp and VB: download VB download C# download C++<\/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-219","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/219","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=219"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/219\/revisions"}],"predecessor-version":[{"id":220,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/219\/revisions\/220"}],"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=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}