{"id":211,"date":"2022-10-10T10:06:46","date_gmt":"2022-10-10T08:06:46","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=211"},"modified":"2022-10-10T13:48:13","modified_gmt":"2022-10-10T11:48:13","slug":"how-to-create-a-line-object","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-create-a-line-object\/","title":{"rendered":"How to create a line object"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">As simple demo here is the code to create a line. Following is a button event to create a layer and use the method to add the new line on this layer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the end is a method to check the tool definition in PCB-Investigator and create a new tool if the searched tool dos not exist.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><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\/Demo4VBCode.zip\" target=\"_blank\" rel=\"noopener\">download VB<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo4CSharp.zip\" target=\"_blank\" rel=\"noopener\">download C#<\/a><\/li><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/Demo4_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    \/\/\/ This methode creates a line in PCB-Investigator.\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=\"pcbiFilter\"&gt;The object creating class of PCB-I.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"matrix\"&gt;The job matrix in PCB-I (IPCBIWindow.GetMatrix()).&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"parentLayer\"&gt;The layer on which the object should be created.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"lineStart\"&gt;The start point of the line.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"lineEnd\"&gt;The end point of the line.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"thickness\"&gt;The diameter of the line.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"NetName\"&gt;The netname if you want to use it.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"step\"&gt;The current step in PCB-I (e.g. IPCBIWindow.GetCurrentStep())&lt;\/param&gt;\n    internal void CreateLine(IFilter pcbiFilter, IMatrix matrix, IODBLayer parentLayer, PointF lineStart, PointF lineEnd, float thickness, String NetName, IStep step)\n    {\n      IODBObject line = pcbiFilter.CreateLine(parentLayer); \/\/create a new line object\n      ILineSpecifics specLine = (ILineSpecifics)line.GetSpecifics(); \/\/the specifics of the object to fill the informations\n      specLine.Start = lineStart;\n      specLine.End = lineEnd;\n      specLine.ShapeIndex = CheckShapeIndexRound(pcbiFilter, parentLayer, thickness); \/\/In PCB-Investigator all objects have a shape index for drawing.\n      specLine.Diameter = thickness;\n      specLine.Positive = true;\n      specLine.Type = PCBI.Symbol_Type.r; \/\/definition of the line ends, most lines are rounds(r)\n      line.SetSpecifics(specLine, specLine.ShapeIndex); \/\/activate the setting!\n    }\n \nIPCBIWindow window;\nIStep step; \/\/e.g. window.GetCurrentStep();\n \nprivate void buttonAddLineAndLayerToExistingStep_Click(object sender, EventArgs e)\n    {\nPCBI.Automation.IFilter filter = new PCBI.Automation.IFilter(window);\n \nIODBLayer layer = filter.CreateEmptyODBLayer(\"layer1\", step.Name);\n     \nCreateLine(filter, matrix, layer, new PointF(10, 10), new PointF(150, 10), 10, \"\", step);\n     \n}\n \n\/\/\/ &lt;summary&gt;\n    \/\/\/ Example to create or load a round tool.\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=\"pcbiFilter\"&gt;To check the known tools&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"parentLayer\"&gt;Each layer needs his own tool definitions.&lt;\/param&gt;\n    \/\/\/ &lt;param name=\"diameter\"&gt;The thickness of the round tool.&lt;\/param&gt;\n    \/\/\/ &lt;returns&gt;The shape Index for later use.&lt;\/returns&gt;\n    internal static int CheckShapeIndexRound(IFilter pcbiFilter, IODBLayer parentLayer, float diameter)\n    {\n      int shapeIndex = -1;\n      Dictionary&lt;int, PCBI.Automation.IFilter.ToolDefinition&gt; symbolList = pcbiFilter.GetUsedSymbolList(parentLayer);\n \n      foreach (KeyValuePair&lt;int, PCBI.Automation.IFilter.ToolDefinition&gt; symbs in symbolList)\n      {\n        if (symbs.Value.Diameter == diameter\n          &amp;&amp; symbs.Value.Type == PCBI.Symbol_Type.r)\n          return symbs.Key; \/\/If the tool is allready known, we do not create a second one!\n      }\n \n      shapeIndex = IFilter.AddToolDefinitionRound(parentLayer, diameter, 1);\n \n      return shapeIndex;\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As simple demo here is the code to create a line. Following is a button event to create a layer and use the method to add the new line on this layer. At the end is a method to check the tool definition in PCB-Investigator and create a new tool if the searched tool dos [&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-211","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/211","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=211"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/211\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/211\/revisions\/212"}],"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=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}