{"id":221,"date":"2022-10-10T10:18:31","date_gmt":"2022-10-10T08:18:31","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=221"},"modified":"2022-10-10T13:48:25","modified_gmt":"2022-10-10T11:48:25","slug":"how-to-create-scripts-with-visual-studio-express","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-create-scripts-with-visual-studio-express\/","title":{"rendered":"How to create scripts with Visual Studio Express"},"content":{"rendered":"\n<p>Some users use scripts very often. The scripting tool has a good highlighting and is easy to use for small scripts and changes of scripts.<br>For users who want to create big scripts with many classes it is better to develop in visual studio.<\/p>\n\n\n\n<p>You can download the free express version from microsoft under&nbsp;<a href=\"https:\/\/www.visualstudio.com\/en-us\/products\/visual-studio-express-vs.aspx\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.visualstudio.com\/en-us\/products\/visual-studio-express-vs.aspx<\/a>. It&#8217;s important to download the desktop version to open our example.<\/p>\n\n\n\n<p>You find our example code to create a script in visual studio download here:&nbsp;<a href=\"http:\/\/www.easylogix.de\/download\/Examples\/HowToCreatePCBIScripts_example.zip\" target=\"_blank\" rel=\"noopener\">Downlad C Sharp Code<\/a><\/p>\n\n\n\n<p>We have added two references to the project.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>First PCB-Investigator-Demo from the standard installation directory.<\/li><li>Than PCB-Investigator-Scripting.dll from the PlugIn subdirectory.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.pcb-investigator.com\/wp-content\/uploads\/2022\/09\/API-AddReference.jpg\" alt=\"\" class=\"wp-image-1162\"\/><\/figure>\n\n\n\n<p>At the end after developing your script with all comfort of visual studio you can&nbsp;<strong>import the class ScriptExample.cs<\/strong>&nbsp;in to your scripting tool or copy the code in an empty script.<\/p>\n\n\n\n<p>Here is the main exampe class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Synchronous template\n\/\/-----------------------------------------------------------------------------------\n\/\/ PCB-Investigator Automation Script\n\/\/ Created on 25.03.2015\n\/\/ Autor easylogix\n\/\/\n\/\/ Template to show windows form for synchronous script.\n\/\/-----------------------------------------------------------------------------------\n \nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing PCBI.Plugin;\nusing PCBI.Plugin.Interfaces;\nusing System.Windows.Forms;\nusing System.Drawing;\nusing PCBI.Automation;\nusing System.IO;\nusing System.Drawing.Drawing2D;\nusing PCBI.MathUtils;\n \nnamespace PCBIScript\n{\n  public class PScript : IPCBIScript\n  {\n    public PScript()\n    {\n    }\n \n    public void Execute(IPCBIWindow parent)\n    {\n      \/\/your code here\n      FormExampleForScript myExampleForm = new FormExampleForScript();\n      if (myExampleForm.ShowDialog() != DialogResult.OK) return;\n \n      bool myOptionA = myExampleForm.OptionA;\n \n      if (myOptionA)\n        MessageBox.Show(\"User has selected option A!\", \"Message\", MessageBoxButtons.OK, MessageBoxIcon.Information);\n      else\n        MessageBox.Show(\"User has unselected option A!\", \"Message\", MessageBoxButtons.OK, MessageBoxIcon.Warning);\n \n      parent.UpdateView();\n    }\n \n    #region use form in script\n    public class FormExampleForScript : Form\n    {\n      public FormExampleForScript()\n      {\n        InitializeComponent();\n      }\n      public bool OptionA\n      {\n        get { return checkBox1.Checked; }\n      }\n \n      private void button1_Click(object sender, EventArgs e)\n      {\n        this.DialogResult = System.Windows.Forms.DialogResult.OK;\n        this.Close();\n      }\n \n      \/\/\/ &lt;summary&gt;\n      \/\/\/ Required designer variable.\n      \/\/\/ &lt;\/summary&gt;\n      private System.ComponentModel.IContainer components = null;\n \n      \/\/\/ &lt;summary&gt;\n      \/\/\/ Clean up any resources being used.\n      \/\/\/ &lt;\/summary&gt;\n      \/\/\/ &lt;param name=\"disposing\"&gt;true if managed resources should be disposed; otherwise, false.&lt;\/param&gt;\n      protected override void Dispose(bool disposing)\n      {\n        if (disposing &amp;&amp; (components != null))\n        {\n          components.Dispose();\n        }\n        base.Dispose(disposing);\n      }\n \n      #region Windows Form Designer generated code\n \n      \/\/\/ &lt;summary&gt;\n      \/\/\/ Required method for Designer support - do not modify\n      \/\/\/ the contents of this method with the code editor.\n      \/\/\/ &lt;\/summary&gt;\n      private void InitializeComponent()\n      {\n        this.button1 = new System.Windows.Forms.Button();\n        this.checkBox1 = new System.Windows.Forms.CheckBox();\n        this.SuspendLayout();\n        \/\/\n        \/\/ button1\n        \/\/\n        this.button1.Location = new System.Drawing.Point(234, 9);\n        this.button1.Name = \"button1\";\n        this.button1.Size = new System.Drawing.Size(75, 23);\n        this.button1.TabIndex = 0;\n        this.button1.Text = \"OK\";\n        this.button1.UseVisualStyleBackColor = true;\n        this.button1.Click += new System.EventHandler(this.button1_Click);\n        \/\/\n        \/\/ checkBox1\n        \/\/\n        this.checkBox1.AutoSize = true;\n        this.checkBox1.Location = new System.Drawing.Point(12, 13);\n        this.checkBox1.Name = \"checkBox1\";\n        this.checkBox1.Size = new System.Drawing.Size(86, 17);\n        this.checkBox1.TabIndex = 1;\n        this.checkBox1.Text = \"Set Option A\";\n        this.checkBox1.UseVisualStyleBackColor = true;\n        \/\/\n        \/\/ FormExampleForScript\n        \/\/\n        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n        this.ClientSize = new System.Drawing.Size(321, 44);\n        this.Controls.Add(this.checkBox1);\n        this.Controls.Add(this.button1);\n        this.Name = \"FormExampleForScript\";\n        this.Text = \"FormExampleForScript\";\n        this.ResumeLayout(false);\n        this.PerformLayout();\n \n      }\n \n      #endregion\n \n      private System.Windows.Forms.Button button1;\n      private System.Windows.Forms.CheckBox checkBox1;\n    }\n \n    #endregion\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some users use scripts very often. The scripting tool has a good highlighting and is easy to use for small scripts and changes of scripts.For users who want to create big scripts with many classes it is better to develop in visual studio. You can download the free express version from microsoft under&nbsp;https:\/\/www.visualstudio.com\/en-us\/products\/visual-studio-express-vs.aspx. It&#8217;s important [&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-221","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/221","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=221"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/221\/revisions"}],"predecessor-version":[{"id":222,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/221\/revisions\/222"}],"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=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}