<?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: Fastest Way To Access Point/Vector Information to Get Center of Mass in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9146975#M103106</link>
    <description>&lt;P&gt;I ran a quick test in VBA to grab RangeBox coords on all planar surfaces.&lt;/P&gt;&lt;PRE&gt;Sub EdgeLoopTest()

Dim app As Application
Set app = ThisApplication
Dim doc As Document
Set doc = app.ActiveDocument

Dim startTime As Date, endTime As Date
startTime = Now()
If doc.DocumentType = kPartDocumentObject Then
    Dim count As Integer
    Dim pDoc As PartDocument&lt;BR /&gt;    Set pDoc = doc
    Dim cDef As ComponentDefinition
    Set cDef = pDoc.ComponentDefinition
    Dim srfBods As SurfaceBodies
    Set srfBods = cDef.SurfaceBodies
    Dim srfBod As SurfaceBody
    For Each srfBod In srfBods
        If srfBod.IsSolid Then
            Dim sFaces As Faces
            Set sFaces = srfBod.Faces
            Dim sFace As Face
            Dim eLoop As EdgeLoop
            For Each sFace In sFaces
                If sFace.SurfaceType = kPlaneSurface Then
                    For Each eLoop In sFace.EdgeLoops
                        'Dim x1 As Integer, x2 As Integer, y1 As Integer
                        'Dim y2 As Integer, z1 As Integer, z2 As Integer
                        Dim mn() As Double
                        Dim mx() As Double
                        eLoop.RangeBox.MinPoint.GetPointData mn
                        eLoop.RangeBox.MaxPoint.GetPointData mx
                        'x1 = eLoop.RangeBox.MinPoint.x
                        'y1 = eLoop.RangeBox.MinPoint.y
                        'z1 = eLoop.RangeBox.MinPoint.z
                        'x2 = eLoop.RangeBox.MaxPoint.x
                        'y2 = eLoop.RangeBox.MaxPoint.y
                        'z2 = eLoop.RangeBox.MaxPoint.z
                        count = count + 1
                    Next
                End If
            Next
        End If

    Next
End If
endTime = Now()

End Sub&lt;/PRE&gt;&lt;P&gt;The part I tested had over 4800 faces and it ran in less than a second.&amp;nbsp; I tried it with both the GetPointData and directly getting the XYZ properties.&amp;nbsp; Same amount of time on both ways.&amp;nbsp; I haven't tried it in an addin in c#.&amp;nbsp; I'm not sure why it's so slow for you?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 16:12:09 GMT</pubDate>
    <dc:creator>jjstr8</dc:creator>
    <dc:date>2019-11-14T16:12:09Z</dc:date>
    <item>
      <title>Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9133351#M102894</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the title suggests, I am looking for speed-saving methods to access underlying geometric information of Points, Vectors, etc. Namely, I am looking to get the center of mass of an EdgeLoop. Two methods I have come up with to get this are&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;edgeLoop.RangeBox.MinPoint.GetPointData(ref minPtData);
edgeLoop.RangeBox.MaxPoint.GetPointData(ref maxPtData);&lt;/PRE&gt;&lt;P&gt;then scaling by half and getting to the center, or the more obvious method of collecting the start/end point of each edge and getting the average.&lt;/P&gt;&lt;P&gt;The problem is that the Inventor API calls are incredibly slow, even just to access properties. The above two lines take ~200ms which means when I collect on the order of 100/1000 center points, this takes way too much time to be viable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea or know how to do this more efficiently? I have locally made versions of Points and Vectors to ease with the math once they are there, but to actually get the information from a Part/Assembly is where I am struggling.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 15:19:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9133351#M102894</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-07T15:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9146975#M103106</link>
      <description>&lt;P&gt;I ran a quick test in VBA to grab RangeBox coords on all planar surfaces.&lt;/P&gt;&lt;PRE&gt;Sub EdgeLoopTest()

Dim app As Application
Set app = ThisApplication
Dim doc As Document
Set doc = app.ActiveDocument

Dim startTime As Date, endTime As Date
startTime = Now()
If doc.DocumentType = kPartDocumentObject Then
    Dim count As Integer
    Dim pDoc As PartDocument&lt;BR /&gt;    Set pDoc = doc
    Dim cDef As ComponentDefinition
    Set cDef = pDoc.ComponentDefinition
    Dim srfBods As SurfaceBodies
    Set srfBods = cDef.SurfaceBodies
    Dim srfBod As SurfaceBody
    For Each srfBod In srfBods
        If srfBod.IsSolid Then
            Dim sFaces As Faces
            Set sFaces = srfBod.Faces
            Dim sFace As Face
            Dim eLoop As EdgeLoop
            For Each sFace In sFaces
                If sFace.SurfaceType = kPlaneSurface Then
                    For Each eLoop In sFace.EdgeLoops
                        'Dim x1 As Integer, x2 As Integer, y1 As Integer
                        'Dim y2 As Integer, z1 As Integer, z2 As Integer
                        Dim mn() As Double
                        Dim mx() As Double
                        eLoop.RangeBox.MinPoint.GetPointData mn
                        eLoop.RangeBox.MaxPoint.GetPointData mx
                        'x1 = eLoop.RangeBox.MinPoint.x
                        'y1 = eLoop.RangeBox.MinPoint.y
                        'z1 = eLoop.RangeBox.MinPoint.z
                        'x2 = eLoop.RangeBox.MaxPoint.x
                        'y2 = eLoop.RangeBox.MaxPoint.y
                        'z2 = eLoop.RangeBox.MaxPoint.z
                        count = count + 1
                    Next
                End If
            Next
        End If

    Next
End If
endTime = Now()

End Sub&lt;/PRE&gt;&lt;P&gt;The part I tested had over 4800 faces and it ran in less than a second.&amp;nbsp; I tried it with both the GetPointData and directly getting the XYZ properties.&amp;nbsp; Same amount of time on both ways.&amp;nbsp; I haven't tried it in an addin in c#.&amp;nbsp; I'm not sure why it's so slow for you?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:12:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9146975#M103106</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2019-11-14T16:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9157722#M103278</link>
      <description>&lt;P&gt;Oh wow, that is very interesting...perhaps it is just this slow in the debugging environment? I will try this in a 'release' and report back here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's nice to know that it is capable of working so quickly, this would solve all my problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for taking the time to test this.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 16:33:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9157722#M103278</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-20T16:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9159797#M103317</link>
      <description>&lt;P&gt;I just re-ran the test in a c# addin in debug.&amp;nbsp; Same results, under a second for 4800+ faces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void EdgeLoopTest()
{
    Inventor.SurfaceBodies srfBodies = ((Inventor.PartDocument)Props.Document).ComponentDefinition.SurfaceBodies;
    int count = 0;
    DateTime start = DateTime.Now;
    foreach (SurfaceBody body in srfBodies)
    {
        if (body.IsSolid)
        {
            foreach (Face face in body.Faces)
            {
                if (face.SurfaceType == SurfaceTypeEnum.kPlaneSurface)
                {
                    foreach (EdgeLoop loop in face.EdgeLoops)
                    {
                        double[] minPt = new double[2];
                        double[] maxPt = new double[2];
                        loop.RangeBox.MinPoint.GetPointData(ref minPt);
                        loop.RangeBox.MaxPoint.GetPointData(ref maxPt);
                        ++count;
                    }
                }
            }
        }
    }
    DateTime end = DateTime.Now;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 14:47:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9159797#M103317</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2019-11-21T14:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9159901#M103320</link>
      <description>&lt;P&gt;Strange, I ran your exact code on my computer and it took 23 seconds, both in debug and release mode. The computer is far from slow for every other application, so this is very bizarre...&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:14:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9159901#M103320</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-21T15:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Fastest Way To Access Point/Vector Information to Get Center of Mass</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9160588#M103331</link>
      <description>&lt;P&gt;I'm at a loss.&amp;nbsp; What was your final face count?&amp;nbsp; I guess you could try a stand-alone app and try it using Apprentice.&amp;nbsp; I don't think it would be a version issue, but I'm on Inventor Pro 2017.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 20:39:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/fastest-way-to-access-point-vector-information-to-get-center-of/m-p/9160588#M103331</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2019-11-21T20:39:14Z</dc:date>
    </item>
  </channel>
</rss>

