<?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: Export coordinates of selected points to Excel C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/8651542#M38122</link>
    <description>&lt;P&gt;I recommend&amp;nbsp;you to use&amp;nbsp;&lt;A href="https://zetexcel.com/" target="_blank"&gt;https://zetexcel.com/&lt;/A&gt;. I used it for many projects.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2019 03:37:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-03-12T03:37:40Z</dc:date>
    <item>
      <title>Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5887069#M38116</link>
      <description>&lt;P&gt;Hello folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have searched the fourm for C# codes to export coordintes of the selected points to Excel but did not find.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone can help please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 19:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5887069#M38116</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2015-10-31T19:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5888181#M38117</link>
      <description>&lt;P&gt;Could you specify your problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you not select points and get the coordinates?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then try something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database;
Editor editor = doc.Editor;

// Get the PickFirst selection set
PromptSelectionResult ss;
ss = editor.SelectImplied();
// If the prompt status is OK, objects were selected before
// the command was started, if not ask.
if (ss.Status != PromptStatus.OK)
{
	PromptSelectionOptions sOpt = new PromptSelectionOptions();
	//SelectionFilter sFilter = new SelectionFilter();
	ss = editor.GetSelection(sOpt);
}

Point3dCollection colRes = new Point3dCollection();
if (ss.Status == PromptStatus.OK)
{
   using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
   {
	if (ss.Value != null)
	{
		for (int i = 0; i &amp;lt; ss.Value.Count; i++)
		{
			Entity dim = tr.GetObject(ss.Value[i].ObjectId, OpenMode.ForRead) as Entity;
			if (dim is DBPoint)
			{
				colRes.Add(((DBPoint)dim).Position);
			}
		}&lt;BR /&gt;        }
	tr.Commit();
}&lt;/PRE&gt;&lt;P&gt;Or do you not know, how to export everything to excel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you could either write everything to a csv file (google for csv file and c# / .net)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or do you want to open excel and put the coordinates directly in the worksheet?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then google for excel automation and .net&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This article would be a good start :&amp;nbsp;&lt;A href="https://support.microsoft.com/en-us/kb/302084" target="_blank"&gt;https://support.microsoft.com/en-us/kb/302084&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 10:32:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5888181#M38117</guid>
      <dc:creator>Matti72</dc:creator>
      <dc:date>2015-11-02T10:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5889199#M38118</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry for not being clear .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;am after learning how the codes of C# work in AutoCAD via transfering data to Excel . for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select Points objects , then prompt the use to enter the name of the Excel file then transfer the coordinates of the previous selcted points into four&amp;nbsp;columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[ Serial No. ] &amp;nbsp;[ X ] [ Y ] [ Z ]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2015 20:13:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5889199#M38118</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2015-11-02T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5889516#M38119</link>
      <description>&lt;P&gt;I havent tested this, but hopefully it should give you a starting point and refine to your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public void WritePointsToCSVFile()
            {
            Document doc = AcApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            using (DocumentLock dLock = doc.LockDocument())
                {
                TypedValue[] tvs = new TypedValue[3];
                tvs.SetValue(new TypedValue((int)DxfCode.Operator, "&amp;lt;or"), 0);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, "POINT"), 1);
                tvs.SetValue(new TypedValue((int)DxfCode.Start, "or&amp;gt;"), 2);

                PromptSelectionOptions pso = new PromptSelectionOptions();
                pso.MessageForAdding = "\nSelect points: ";
                SelectionFilter sf = new SelectionFilter(tvs);
                PromptSelectionResult psr = ed.GetSelection(pso, sf);

                if (psr.Status == PromptStatus.OK)
                    {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "*.csv Files|*.csv";
                    if (sfd.ShowDialog() == DialogResult.OK)
                        {
                        StreamWriter sw = new StreamWriter(sfd.FileName);

                        using (Transaction tr = db.TransactionManager.StartTransaction())
                            {
                            foreach (ObjectId id in psr.Value.GetObjectIds())
                                {
                                DBPoint pt = (DBPoint)tr.GetObject(id, OpenMode.ForRead);
                                sw.WriteLine("{0},{1},{2}", pt.Position.X, pt.Position.Y, pt.Position.Z);
                                }
                            tr.Commit();
                            }
                        sw.Close();
                        ed.WriteMessage("\nCoordinates output to {0}", sfd.FileName);
                        }
                    }
                }
            }&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 00:39:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5889516#M38119</guid>
      <dc:creator>BrentBurgess1980</dc:creator>
      <dc:date>2015-11-03T00:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5890034#M38120</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The codes loaded without any error but it does not do anything . can you check the codes once again please ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 10:57:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5890034#M38120</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2015-11-03T10:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5890071#M38121</link>
      <description>&lt;P&gt;I was able to make to work by modifying the Typedvalue like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TypedValue[] tvs = new TypedValue[] { new TypedValue((int)DxfCode.Start, "POINT") };&lt;/PRE&gt;&lt;P&gt;but the codes write the coordinates (X,Y,Z) in one cell and I am in need of them to be each one in a cell in one row .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please modify the codes ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;EDIT: nevermind , I modified the codes by replacing the comma to semicolon and it works , thank you.&lt;/STRONG&gt;&lt;/FONT&gt; &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sw.WriteLine("{0};{1};{2}", pt.Position.X, pt.Position.Y, pt.Position.Z);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 11:47:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/5890071#M38121</guid>
      <dc:creator>J-Rocks</dc:creator>
      <dc:date>2015-11-03T11:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates of selected points to Excel C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/8651542#M38122</link>
      <description>&lt;P&gt;I recommend&amp;nbsp;you to use&amp;nbsp;&lt;A href="https://zetexcel.com/" target="_blank"&gt;https://zetexcel.com/&lt;/A&gt;. I used it for many projects.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 03:37:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-coordinates-of-selected-points-to-excel-c/m-p/8651542#M38122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-12T03:37:40Z</dc:date>
    </item>
  </channel>
</rss>

