<?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: iLogic vector intersection point in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12968362#M7034</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13696024"&gt;@thomas_wegerBYFE5&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-72FEB5CB-8711-40BE-BCD8-3C09D7E5B3ED" target="_blank" rel="noopener"&gt;Line&lt;/A&gt; Objects have an "&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-2DF22B00-8ACE-4321-8144-E2DA702E00C7" target="_blank" rel="noopener"&gt;IntersectionWithCurve&lt;/A&gt;" Method, which should give you what you want.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 19:37:59 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2024-08-19T19:37:59Z</dc:date>
    <item>
      <title>iLogic vector intersection point</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12967550#M7033</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have trouble to find the intersection point of two working axes which I created.&lt;BR /&gt;I would like to use the point in a sketch later.&lt;BR /&gt;I was expecting to find a method in the line object...but I could not. &lt;STRONG&gt;Maybe I oversaw it?&lt;/STRONG&gt;&lt;BR /&gt;Here is my code so far, which is not working...and my math class days are quite a bit ago...(plus I would like with inventor methods where it is possible.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached also my part becuase I maybe &lt;STRONG&gt;overcomplicating things(?)&lt;/STRONG&gt;....the rule "CreateAssembly" is creating an ipt file. On the intersection of the volumes I need to have a cut out feature. After that I create with "CreateMultiBody" the assembly. My first attemp was to bottom up but with top down I expect to handle modifications in the ipt faster and once the configuration is done I produce the assembly parts.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub main()
' Get the active document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

' Get the component definition (part)
Dim oCompDef As ComponentDefinition
oCompDef = oDoc.ComponentDefinition

' Get references to the two work axes by name
Dim oAxis1 As WorkAxis
Dim oAxis2 As WorkAxis

oAxis1 = oCompDef.WorkAxes.Item("Arbeitsachse1") ' Replace with the name of your first work axis
oAxis2 = oCompDef.WorkAxes.Item("Arbeitsachse2") ' Replace with the name of your second work axis

' Get the geometry of the work axes
Dim oLine1 As Line
Dim oLine2 As Line

oLine1 = oAxis1.Line
oLine2 = oAxis2.Line

' Call the function to find the intersection point
Dim intersectionPt As Point
intersectionPt = FindIntersectionPoint(oLine1, oLine2)

' Output the intersection point
If intersectionPt IsNot Nothing Then
    MsgBox("Intersection Point: X=" &amp;amp; intersectionPt.X &amp;amp; ", Y=" &amp;amp; intersectionPt.Y &amp;amp; ", Z=" &amp;amp; intersectionPt.Z)
Else
    MsgBox("No intersection point found.")
End If


End Sub

' Function to calculate the intersection point between two lines
Function FindIntersectionPoint(line1 As Line, line2 As Line) As Point
    ' Get the direction vectors of the lines
    Dim dir1 As Vector
    Dim dir2 As Vector
    dir1 = line1.Direction.AsVector
    dir2 = line2.Direction.AsVector

    ' Get the point on the first line (origin)
    Dim pt1 As Point
    pt1 = line1.RootPoint

    ' Get the point on the second line (origin)
    Dim pt2 As Point
    pt2 = line2.RootPoint

    ' Calculate the cross product of the direction vectors
    Dim crossDir As Vector
    crossDir = dir1.CrossProduct(dir2)

    ' If the cross product is nearly zero, the lines are parallel or coincident
    If crossDir.Length &amp;lt; 0.000001 Then
        MsgBox("The lines are parallel or coincident, no unique intersection point.")
        Return Nothing
    End If


    ' Calculate the intersection point using the parameter of the first line
    Dim t As Double
    t = (pt2 - pt1).DotProduct(crossDir) / dir1.DotProduct(crossDir)

    ' Calculate the intersection point
    Dim intersectionPoint As Point
    intersectionPoint = pt1 + dir1 * t

    Return intersectionPoint
End &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 13:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12967550#M7033</guid>
      <dc:creator>thomas_wegerBYFE5</dc:creator>
      <dc:date>2024-08-19T13:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic vector intersection point</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12968362#M7034</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13696024"&gt;@thomas_wegerBYFE5&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-72FEB5CB-8711-40BE-BCD8-3C09D7E5B3ED" target="_blank" rel="noopener"&gt;Line&lt;/A&gt; Objects have an "&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-2DF22B00-8ACE-4321-8144-E2DA702E00C7" target="_blank" rel="noopener"&gt;IntersectionWithCurve&lt;/A&gt;" Method, which should give you what you want.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 19:37:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12968362#M7034</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-08-19T19:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic vector intersection point</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12969168#M7035</link>
      <description>&lt;P&gt;Thank you for your quick reply! Your solution worked perfectly.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here the modified code as a example:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub main()
' Get the active document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

' Get the component definition (part)
Dim oCompDef As ComponentDefinition
oCompDef = oDoc.ComponentDefinition

' Get references to the two work axes by name
Dim oAxis1 As WorkAxis
Dim oAxis2 As WorkAxis

oAxis1 = oCompDef.WorkAxes.Item("Arbeitsachse1") ' Replace with the name of your first work axis
oAxis2 = oCompDef.WorkAxes.Item("Arbeitsachse14") ' Replace with the name of your second work axis

' Get the geometry of the work axes
Dim oLine1 As Line
Dim oLine2 As Line

oLine1 = oAxis1.Line
oLine2 = oAxis2.Line

Dim crossingPointEnum As ObjectsEnumerator
crossingPointEnum = oLine1.IntersectWithCurve(oLine2)

Dim xPoint As Point

'Get the first crossing point
xPoint = crossingPointEnum.Item(1) 

' Output the intersection point
If crossingPointEnum IsNot Nothing Then
    MsgBox("XPoint" &amp;amp; xPoint.X.ToString &amp;amp; "YPoint" &amp;amp; xPoint.Y.ToString &amp;amp; "ZPoint" &amp;amp; xPoint.Z.ToString)
Else
    MsgBox("No intersection point found.")
End If
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 06:28:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12969168#M7035</guid>
      <dc:creator>thomas_wegerBYFE5</dc:creator>
      <dc:date>2024-08-20T06:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic vector intersection point</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12969401#M7036</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13696024"&gt;@thomas_wegerBYFE5&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;&amp;lt;SNIP&amp;gt;
    ' If the cross product is nearly zero, the lines are parallel or coincident
    If crossDir.Length &amp;lt; 0.000001 Then
        MsgBox("The lines are parallel or coincident, no unique intersection point.")
        Return Nothing
    End If
&amp;lt;/SNIP&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Side-note: Did you know that the vector object has an &lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-02DFE83C-14CF-4867-BBA5-011EADB4A06D" target="_blank" rel="noopener"&gt;IsParallelTo method&lt;/A&gt; which you can use to easily check if two vectors are parallel? (easily meaning no calculation of cross-product and no checking of length against a very small value/tolerance).&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 08:45:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-vector-intersection-point/m-p/12969401#M7036</guid>
      <dc:creator>_dscholtes_</dc:creator>
      <dc:date>2024-08-20T08:45:49Z</dc:date>
    </item>
  </channel>
</rss>

