<?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: VBA -&amp;gt; .Net Problem with Point2D in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7268094#M99190</link>
    <description>&lt;P&gt;Hi, thanks...thats what i am looking for. Now it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards Martin&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2017 11:39:35 GMT</pubDate>
    <dc:creator>Martin-Winkler-Consulting</dc:creator>
    <dc:date>2017-08-01T11:39:35Z</dc:date>
    <item>
      <title>VBA -&gt; .Net Problem with Point2D</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7260914#M99186</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i am actually writing VBA Code to VB.Net and have a problem with a Point2D object.&lt;/P&gt;&lt;P&gt;The macro shall align text, views and titles in an idw using the first selected object.&lt;/P&gt;&lt;P&gt;In VBA the macro works fine. In VB.NET i get a failure with the COM Object.&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is the example in VBA for the X Axis:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub AlignX()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oSelect As SelectSet
Set oSelect = oDoc.SelectSet

Dim newPoint As Point2d
Set newPoint = oSelect.Item(1).Position

For Each obj In oSelect
  newPoint.Y = obj.Position.Y
  obj.Position = newPoint
Next
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VB.Net Code:&lt;/P&gt;&lt;PRE&gt;Sub AlignX()
            Dim oDoc As DrawingDocument = InventorApp.ActiveDocument
            Dim oSelect As SelectSet = oDoc.SelectSet
            Dim tg As TransientGeometry = InventorApp.TransientGeometry
            Dim newPointX As Point2d = Nothing
            Dim obj As Object

            newPointX = tg.CreatePoint2d(oSelect.Item(1).Position.X, oSelect.Item(1).Position.Y)

                For Each obj In oSelect
                    newPoint.Y = obj.Position.Y
                    obj.Position = newPointX
                Next
            End Sub&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In the&amp;nbsp; For Each loop at obj.Position = newPointX&amp;nbsp; .Net creates the failure.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3DCS_2017.07.24_15h49m53s_001_.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/383269i309FC7A5221BB224/image-size/large?v=v2&amp;amp;px=999" role="button" title="3DCS_2017.07.24_15h49m53s_001_.jpg" alt="3DCS_2017.07.24_15h49m53s_001_.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards Martin&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 11:06:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7260914#M99186</guid>
      <dc:creator>Martin-Winkler-Consulting</dc:creator>
      <dc:date>2017-07-28T11:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; .Net Problem with Point2D</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7265110#M99187</link>
      <description>&lt;P&gt;Can you provide the document(if it is not confidential) and create a snapshot to tell which objects are selected, and we can look into where the problem is?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 10:54:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7265110#M99187</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2017-07-31T10:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; .Net Problem with Point2D</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7265185#M99188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;for better understanding the tool i make a video in which you can see how the tool works with the VBA Code.&lt;/P&gt;&lt;P&gt;You can try it in every idw!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After several workarrounds i think the problem is with the selected obj. because obj is declared as Object.&lt;/P&gt;&lt;P&gt;This is neccessary because obj can become different object types. But all of this objects have an obj.Position which i can set in VBA without problems.&lt;/P&gt;&lt;P&gt;In .Net there is a Type conflict because .Net not recognized that obj.Position is a Point2D. It.s a System_Com object&lt;/P&gt;&lt;P&gt;I tried declaring obj AS DrawingView...then it works, but only for DrawingViews.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i solve this type problem?&lt;/P&gt;&lt;P&gt;Let me know if you need more information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards Martin&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 11:39:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7265185#M99188</guid>
      <dc:creator>Martin-Winkler-Consulting</dc:creator>
      <dc:date>2017-07-31T11:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; .Net Problem with Point2D</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7267603#M99189</link>
      <description>&lt;P&gt;You can change the line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;obj.Position = newPoint&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Consolas" size="2"&gt;CallByName(obj, "Position", vbLet, newPoint)&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;Hope this helps.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 07:23:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7267603#M99189</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2017-08-01T07:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: VBA -&gt; .Net Problem with Point2D</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7268094#M99190</link>
      <description>&lt;P&gt;Hi, thanks...thats what i am looking for. Now it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards Martin&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 11:39:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-gt-net-problem-with-point2d/m-p/7268094#M99190</guid>
      <dc:creator>Martin-Winkler-Consulting</dc:creator>
      <dc:date>2017-08-01T11:39:35Z</dc:date>
    </item>
  </channel>
</rss>

