<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create G - Code from sketch blocks using iLogic in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7672082#M95757</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see if i can get it working and get back to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2018 14:45:58 GMT</pubDate>
    <dc:creator>Thomas_Savage</dc:creator>
    <dc:date>2018-01-08T14:45:58Z</dc:date>
    <item>
      <title>Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7561580#M95755</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for some help with an iLogic code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My colleague uses G-Coder to create a code for our punch.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And i have placed the tools, which are sketch blocks, that he uses to get the center points, to get the x,y and z coordinates in to Inventor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it be possible to extract the x, y and z coordinates from the sketch blocks using iLogic?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So he would not have to manually type each x,y and z coordinate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached the .ipt below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Block iLogic.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/429109i13C57E557C218A92/image-size/large?v=v2&amp;amp;px=999" role="button" title="Block iLogic.png" alt="Block iLogic.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 12:01:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7561580#M95755</guid>
      <dc:creator>Thomas_Savage</dc:creator>
      <dc:date>2017-11-21T12:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7672023#M95756</link>
      <description>&lt;P&gt;I couldn't open your attachment (I think your Inventor is newer then mine.) I did just throw some random points on a sketch in a new part file and was able to get their X, Y, and Z coords with...&lt;/P&gt;&lt;PRE&gt;doc = ThisDoc.Document
compDef = doc.ComponentDefinition
oSketch = compDef.Sketches.Item(1) 'first sketch in file
For Each sketchPoint In osketch.SketchPoints
	MessageBox.Show("X=" &amp;amp; sketchPoint.Geometry3d.X &amp;amp; vbCr &amp;amp; "Y=" &amp;amp; sketchPoint.Geometry3d.Y &amp;amp; vbCr &amp;amp; "Z=" &amp;amp; sketchPoint.Geometry3d.Z, "Title")
Next&lt;/PRE&gt;&lt;P&gt;The results are in cm so you would have to do some math on them first if you need something else. Also you probably want to use some code from the "My Snippets" tab to write the data to a file of some kind rather then to just a message box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 14:24:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7672023#M95756</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-01-08T14:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7672082#M95757</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see if i can get it working and get back to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 14:45:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7672082#M95757</guid>
      <dc:creator>Thomas_Savage</dc:creator>
      <dc:date>2018-01-08T14:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7681933#M95758</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This does work. I am going to try and get the X &amp;amp; Y data in to a text file now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 12:02:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7681933#M95758</guid>
      <dc:creator>Thomas_Savage</dc:creator>
      <dc:date>2018-01-11T12:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7681994#M95759</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created the code to send the X and Y coordinates to a text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it sends each point individually, to individual text files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want all the X and Y coordinates in the same text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you tell me how to do that please. Code attached below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;doc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;compDef&lt;/SPAN&gt; = &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
&lt;SPAN&gt;oSketch&lt;/SPAN&gt; = &lt;SPAN&gt;compDef&lt;/SPAN&gt;.&lt;SPAN&gt;Sketches&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1) &lt;SPAN&gt;'first sketch in file&lt;/SPAN&gt;
&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;SketchPoint&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;osketch&lt;/SPAN&gt;.&lt;SPAN&gt;SketchPoints&lt;/SPAN&gt;

&lt;SPAN&gt;'____Create and write to a text file_________________&lt;/SPAN&gt;
&lt;SPAN&gt;oWrite&lt;/SPAN&gt; = &lt;SPAN&gt;System&lt;/SPAN&gt;.&lt;SPAN&gt;IO&lt;/SPAN&gt;.&lt;SPAN&gt;File&lt;/SPAN&gt;.&lt;SPAN&gt;CreateText&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;PathAndFileName&lt;/SPAN&gt;(&lt;SPAN&gt;False&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;".txt"&lt;/SPAN&gt;)
&lt;SPAN&gt;oWrite&lt;/SPAN&gt;.&lt;SPAN&gt;WriteLine&lt;/SPAN&gt;(&lt;SPAN&gt;"X="&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;sketchPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Geometry3d&lt;/SPAN&gt;.&lt;SPAN&gt;X&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;vbCr&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"Y="&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;sketchPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Geometry3d&lt;/SPAN&gt;.&lt;SPAN&gt;Y&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;vbCr&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"Z="&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;sketchPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Geometry3d&lt;/SPAN&gt;.&lt;SPAN&gt;Z&lt;/SPAN&gt;)
&lt;SPAN&gt;oWrite&lt;/SPAN&gt;.&lt;SPAN&gt;Close&lt;/SPAN&gt;()


&lt;SPAN&gt;'open the file&lt;/SPAN&gt;
&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Launch&lt;/SPAN&gt;(&lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;PathAndFileName&lt;/SPAN&gt;(&lt;SPAN&gt;False&lt;/SPAN&gt;) &amp;amp; &lt;SPAN&gt;".txt"&lt;/SPAN&gt;)

&lt;SPAN&gt;Next&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 12:24:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7681994#M95759</guid>
      <dc:creator>Thomas_Savage</dc:creator>
      <dc:date>2018-01-11T12:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7682195#M95760</link>
      <description>&lt;PRE&gt;doc = ThisDoc.Document
compDef = doc.ComponentDefinition
oSketch = compDef.Sketches.Item(1) 'first sketch in file


'____Create and write to a text file_________________
oWrite = System.IO.File.CreateText(ThisDoc.PathAndFileName(False) &amp;amp; ".txt")

For Each SketchPoint In osketch.SketchPoints
    oWrite.WriteLine("X=" &amp;amp; sketchPoint.Geometry3d.X &amp;amp; vbCr &amp;amp; "Y=" &amp;amp; sketchPoint.Geometry3d.Y &amp;amp; vbCr &amp;amp; "Z=" &amp;amp; sketchPoint.Geometry3d.Z)

Next
'open the file
ThisDoc.Launch(ThisDoc.PathAndFileName(False) &amp;amp; ".txt")
oWrite.Close()&lt;/PRE&gt;&lt;P&gt;for each point you made a new text file... you just need to move your for loop after you create the text file (and move the file open and close after the next so you don't do each of those actions for each point too)&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 13:40:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7682195#M95760</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-01-11T13:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create G - Code from sketch blocks using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7700287#M95761</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5352440"&gt;@clutsa&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It placed them all in the same text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 11:38:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-g-code-from-sketch-blocks-using-ilogic/m-p/7700287#M95761</guid>
      <dc:creator>Thomas_Savage</dc:creator>
      <dc:date>2018-01-18T11:38:40Z</dc:date>
    </item>
  </channel>
</rss>

