<?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: Can't call the function to get the tight bounding box in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322045#M89851</link>
    <description>&lt;P&gt;use this instead because you function is missing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub TestTightBoundingBox()
    Dim invApp As Inventor.Application = GetObject(, "Inventor.Application")
    ' Have a body selected.
    Dim body As SurfaceBody
    body = invApp.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select the body.")

    ' Call the function to get the tight bounding box.
    Dim bndBox As Box = calculateTightBoundingBox(body)

    ' Draw the bounding box using a 3D sketch.
    Dim partDoc As PartDocument = invApp.ActiveDocument
    Dim sk As Sketch3D = partDoc.ComponentDefinition.Sketches3D.Add()
    Dim lines As SketchLines3D = sk.SketchLines3D

    Dim tg As TransientGeometry = invApp.TransientGeometry

    Dim minXYZ As Point = bndBox.MinPoint
    Dim minXYmaxZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
    Dim minXmaxYZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MaxPoint.Z)
    Dim minXZmaxY As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)

    Dim maxXYZ As Point = bndBox.MaxPoint
    Dim maxXYminZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)
    Dim maxXZminY As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
    Dim maxXminYZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MinPoint.Z)

    lines.AddByTwoPoints(minXYZ, minXYmaxZ)
    lines.AddByTwoPoints(minXYZ, minXZmaxY)
    lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)
    lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)

    lines.AddByTwoPoints(maxXYZ, maxXYminZ)
    lines.AddByTwoPoints(maxXYZ, maxXZminY)
    lines.AddByTwoPoints(maxXYminZ, maxXminYZ)
    lines.AddByTwoPoints(maxXZminY, maxXminYZ)

    lines.AddByTwoPoints(minXYZ, maxXminYZ)
    lines.AddByTwoPoints(minXYmaxZ, maxXZminY)
    lines.AddByTwoPoints(minXmaxYZ, maxXYZ)
    lines.AddByTwoPoints(minXZmaxY, maxXYminZ)
End Sub


' Calculates a tight bounding box around the input body.  An optional
' tolerance argument is available.  This specificies the tolerance in
' centimeters.  If not provided the best existing display mesh is used.
Public Function calculateTightBoundingBox(body As SurfaceBody, Optional Tolerance As Double = 0) As Box
    Try
        Dim vertCount As Integer
        Dim facetCount As Integer
        Dim vertCoords() As Double = {}
        Dim normVectors() As Double = {}
        Dim vertInds() As Integer = {}

        ' If the tolerance is zero, use the best display mesh available.
        If Tolerance &amp;lt;= 0 Then
            ' Get the best display mesh available.
            Dim tolCount As Long
            Dim tols() As Double = {}
            Call body.GetExistingFacetTolerances(tolCount, tols)
            Dim bestTol As Double
            bestTol = tols(0)
            For i As Integer = 1 To tolCount - 1
                If tols(i) &amp;lt; bestTol Then
                    bestTol = tols(i)
                End If
            Next

            body.GetExistingFacets(bestTol, vertCount, facetCount, vertCoords, normVectors, vertInds)
        Else
            ' Calculate a new mesh based on the input tolerance.
            body.CalculateFacets(Tolerance, vertCount, facetCount, vertCoords, normVectors, vertInds)
        End If

        Dim tg As TransientGeometry = body.Application.TransientGeometry

        ' Calculate the range of the mesh.
        Dim smallPnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
        Dim largePnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
        For i As Integer = 1 To vertCount - 1
            Dim vertX As Double = vertCoords(i * 3)
            Dim vertY As Double = vertCoords(i * 3 + 1)
            Dim vertZ As Double = vertCoords(i * 3 + 2)

            If vertX &amp;lt; smallPnt.X Then
                smallPnt.X = vertX
            End If

            If vertY &amp;lt; smallPnt.Y Then
                smallPnt.Y = vertY
            End If

            If vertZ &amp;lt; smallPnt.Z Then
                smallPnt.Z = vertZ
            End If

            If vertX &amp;gt; largePnt.X Then
                largePnt.X = vertX
            End If

            If vertY &amp;gt; largePnt.Y Then
                largePnt.Y = vertY
            End If

            If vertZ &amp;gt; largePnt.Z Then
                largePnt.Z = vertZ
            End If
        Next

        ' Create and return a Box as the result.
        Dim newBox As Box = tg.CreateBox()
        newBox.MinPoint = smallPnt
        newBox.MaxPoint = largePnt
        Return newBox
    Catch ex As Exception
        Return Nothing
    End Try
End Function&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Oct 2018 11:19:10 GMT</pubDate>
    <dc:creator>bradeneuropeArthur</dc:creator>
    <dc:date>2018-10-09T11:19:10Z</dc:date>
    <item>
      <title>Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321876#M89844</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to fix the problem, I can't call the function to get the tight bounding box by VBA.Net. I'm using the Microsoft studio to coding.&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="Code.png" style="width: 830px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/555392i188AA7B743D1F8BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Code.png" alt="Code.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ngoc Son&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Inventor's user&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 10:05:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321876#M89844</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-09T10:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321932#M89846</link>
      <description>&lt;P&gt;How does the function look like?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 10:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321932#M89846</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-10-09T10:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321951#M89847</link>
      <description>&lt;P&gt;It looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imports System&lt;BR /&gt;Imports System.Runtime.InteropServices&lt;BR /&gt;Imports Inventor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Class Form1&lt;/P&gt;&lt;P&gt;Dim invApp As Inventor.Application&lt;BR /&gt;Dim partDoc As Inventor.PartDocument&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;invApp = Marshal.GetActiveObject("Inventor.Application")&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click&lt;/P&gt;&lt;P&gt;partDoc = invApp.ActiveDocument&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim body As SurfaceBody&lt;BR /&gt;body = invApp.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select the body.")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim bndBox As Box = calculateTightBoundingBox(body)&lt;/P&gt;&lt;P&gt;Dim sk As Sketch3D = partDoc.ComponentDefinition.Sketches3D.Add()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim lines As SketchLines3D = sk.SketchLines3D&lt;/P&gt;&lt;P&gt;Dim tg As TransientGeometry = invApp.TransientGeometry&lt;/P&gt;&lt;P&gt;Dim minXYZ As Point = bndBox.MinPoint&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim minXYmaxZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)&lt;BR /&gt;Dim minXmaxYZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MaxPoint.Z)&lt;BR /&gt;Dim minXZmaxY As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim maxXYZ As Point = bndBox.MaxPoint&lt;BR /&gt;Dim maxXYminZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)&lt;BR /&gt;Dim maxXZminY As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)&lt;BR /&gt;Dim maxXminYZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MinPoint.Z)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;lines.AddByTwoPoints(minXYZ, minXYmaxZ)&lt;BR /&gt;lines.AddByTwoPoints(minXYZ, minXZmaxY)&lt;BR /&gt;lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)&lt;BR /&gt;lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;lines.AddByTwoPoints(maxXYZ, maxXYminZ)&lt;BR /&gt;lines.AddByTwoPoints(maxXYZ, maxXZminY)&lt;BR /&gt;lines.AddByTwoPoints(maxXYminZ, maxXminYZ)&lt;BR /&gt;lines.AddByTwoPoints(maxXZminY, maxXminYZ)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;lines.AddByTwoPoints(minXYZ, maxXminYZ)&lt;BR /&gt;lines.AddByTwoPoints(minXYmaxZ, maxXZminY)&lt;BR /&gt;lines.AddByTwoPoints(minXmaxYZ, maxXYZ)&lt;BR /&gt;lines.AddByTwoPoints(minXZmaxY, maxXYminZ)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Class&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 10:35:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8321951#M89847</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-09T10:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322029#M89849</link>
      <description>&lt;P&gt;I mean how does the function or module "&lt;SPAN&gt;calculateTightBoundingBox&lt;/SPAN&gt;" look like&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 11:13:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322029#M89849</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-10-09T11:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322045#M89851</link>
      <description>&lt;P&gt;use this instead because you function is missing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub TestTightBoundingBox()
    Dim invApp As Inventor.Application = GetObject(, "Inventor.Application")
    ' Have a body selected.
    Dim body As SurfaceBody
    body = invApp.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select the body.")

    ' Call the function to get the tight bounding box.
    Dim bndBox As Box = calculateTightBoundingBox(body)

    ' Draw the bounding box using a 3D sketch.
    Dim partDoc As PartDocument = invApp.ActiveDocument
    Dim sk As Sketch3D = partDoc.ComponentDefinition.Sketches3D.Add()
    Dim lines As SketchLines3D = sk.SketchLines3D

    Dim tg As TransientGeometry = invApp.TransientGeometry

    Dim minXYZ As Point = bndBox.MinPoint
    Dim minXYmaxZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
    Dim minXmaxYZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MaxPoint.Z)
    Dim minXZmaxY As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)

    Dim maxXYZ As Point = bndBox.MaxPoint
    Dim maxXYminZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)
    Dim maxXZminY As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
    Dim maxXminYZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MinPoint.Z)

    lines.AddByTwoPoints(minXYZ, minXYmaxZ)
    lines.AddByTwoPoints(minXYZ, minXZmaxY)
    lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)
    lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)

    lines.AddByTwoPoints(maxXYZ, maxXYminZ)
    lines.AddByTwoPoints(maxXYZ, maxXZminY)
    lines.AddByTwoPoints(maxXYminZ, maxXminYZ)
    lines.AddByTwoPoints(maxXZminY, maxXminYZ)

    lines.AddByTwoPoints(minXYZ, maxXminYZ)
    lines.AddByTwoPoints(minXYmaxZ, maxXZminY)
    lines.AddByTwoPoints(minXmaxYZ, maxXYZ)
    lines.AddByTwoPoints(minXZmaxY, maxXYminZ)
End Sub


' Calculates a tight bounding box around the input body.  An optional
' tolerance argument is available.  This specificies the tolerance in
' centimeters.  If not provided the best existing display mesh is used.
Public Function calculateTightBoundingBox(body As SurfaceBody, Optional Tolerance As Double = 0) As Box
    Try
        Dim vertCount As Integer
        Dim facetCount As Integer
        Dim vertCoords() As Double = {}
        Dim normVectors() As Double = {}
        Dim vertInds() As Integer = {}

        ' If the tolerance is zero, use the best display mesh available.
        If Tolerance &amp;lt;= 0 Then
            ' Get the best display mesh available.
            Dim tolCount As Long
            Dim tols() As Double = {}
            Call body.GetExistingFacetTolerances(tolCount, tols)
            Dim bestTol As Double
            bestTol = tols(0)
            For i As Integer = 1 To tolCount - 1
                If tols(i) &amp;lt; bestTol Then
                    bestTol = tols(i)
                End If
            Next

            body.GetExistingFacets(bestTol, vertCount, facetCount, vertCoords, normVectors, vertInds)
        Else
            ' Calculate a new mesh based on the input tolerance.
            body.CalculateFacets(Tolerance, vertCount, facetCount, vertCoords, normVectors, vertInds)
        End If

        Dim tg As TransientGeometry = body.Application.TransientGeometry

        ' Calculate the range of the mesh.
        Dim smallPnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
        Dim largePnt As Point = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
        For i As Integer = 1 To vertCount - 1
            Dim vertX As Double = vertCoords(i * 3)
            Dim vertY As Double = vertCoords(i * 3 + 1)
            Dim vertZ As Double = vertCoords(i * 3 + 2)

            If vertX &amp;lt; smallPnt.X Then
                smallPnt.X = vertX
            End If

            If vertY &amp;lt; smallPnt.Y Then
                smallPnt.Y = vertY
            End If

            If vertZ &amp;lt; smallPnt.Z Then
                smallPnt.Z = vertZ
            End If

            If vertX &amp;gt; largePnt.X Then
                largePnt.X = vertX
            End If

            If vertY &amp;gt; largePnt.Y Then
                largePnt.Y = vertY
            End If

            If vertZ &amp;gt; largePnt.Z Then
                largePnt.Z = vertZ
            End If
        Next

        ' Create and return a Box as the result.
        Dim newBox As Box = tg.CreateBox()
        newBox.MinPoint = smallPnt
        newBox.MaxPoint = largePnt
        Return newBox
    Catch ex As Exception
        Return Nothing
    End Try
End Function&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2018 11:19:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322045#M89851</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-10-09T11:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322699#M89872</link>
      <description>&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 15:10:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322699#M89872</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-09T15:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322840#M89879</link>
      <description>&lt;P&gt;So I saw the code to use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;ExtentsWidth&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ExtentsLength&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;to create a stock size for a part&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SyntaxEditor Code Snippet (ilogic)&lt;/P&gt;&lt;PRE&gt;		&lt;SPAN&gt;Thickness&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsLength&lt;/SPAN&gt;
		
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsWidth&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsLength&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
			&lt;SPAN&gt;Width&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsWidth&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;Thickness&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsWidth&lt;/SPAN&gt;
			&lt;SPAN&gt;Width&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsLength&lt;/SPAN&gt;
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
		&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;Width&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
			&lt;SPAN&gt;Lenght&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt;
		&lt;SPAN&gt;Else&lt;/SPAN&gt;
			&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt; &amp;gt; &lt;SPAN&gt;Thickness&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
				&lt;SPAN&gt;Lenght&lt;/SPAN&gt; = &lt;SPAN&gt;Width&lt;/SPAN&gt;
				&lt;SPAN&gt;Width&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt;
			&lt;SPAN&gt;Else&lt;/SPAN&gt;
				&lt;SPAN&gt;Lenght&lt;/SPAN&gt; = &lt;SPAN&gt;Width&lt;/SPAN&gt;
				&lt;SPAN&gt;Width&lt;/SPAN&gt; = &lt;SPAN&gt;Thickness&lt;/SPAN&gt;
				&lt;SPAN&gt;Thickness&lt;/SPAN&gt; = &lt;SPAN&gt;Measure&lt;/SPAN&gt;.&lt;SPAN&gt;ExtentsHeight&lt;/SPAN&gt;
			&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
			
		&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;How can I use it in Visual Studio?&amp;nbsp;I try but can not! Please help me one more!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 16:15:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8322840#M89879</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-09T16:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8323177#M89887</link>
      <description>&lt;P&gt;For Vb.net:&lt;/P&gt;&lt;PRE&gt;Public Sub DimensionComponentSimple()
dim ThisApplicationInv As Inventor.Application   &lt;BR /&gt;Try

        Dim oInventorDoc As Inventor.Document
        'oInventorDoc = ThisApplicationInv.ActiveDocument
        oInventorDoc = ThisApplicationInv.ActiveEditDocument

        
        If oInventorDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Or oInventorDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then

            Dim b As ComponentDefinition = Nothing

            If oInventorDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                Dim OinventorDocToBeDim As Inventor.AssemblyDocument
                OinventorDocToBeDim = oInventorDoc
                b = OinventorDocToBeDim.ComponentDefinition
               End If

            If oInventorDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                Dim OinventorDocToBeDim As Inventor.PartDocument
                OinventorDocToBeDim = oInventorDoc
                b = OinventorDocToBeDim.ComponentDefinition
                'b = CType(oInventorDoc, Inventor.PartDocument).ComponentDefinition&lt;BR /&gt;            End If


            Dim c As Box
            c = b.RangeBox

            Dim dmax As Point
            dmax = c.MaxPoint

            Dim dmin As Point
            dmin = c.MinPoint

            Dim dX As Decimal
            Dim dY As Decimal
            Dim dZ As Decimal

            Dim strLENGTH As Single
            Dim strWIDTH As Single
            Dim strTHICKNESS As Single

            dX = (dmax.X - dmin.X) * 10
            dY = (dmax.Y - dmin.Y) * 10
            dZ = (dmax.Z - dmin.Z) * 10

            dX = Math.Round(dX, DocPrec)
            dY = Math.Round(dY, DocPrec)
            dZ = Math.Round(dZ, DocPrec)

            Try
                
                If dX = dY Then
                    'MsgBox("x")
                    strLENGTH = dX '&amp;amp; " mm"
                    strWIDTH = dY
                    strTHICKNESS = dZ

                End If

                If dX = dZ Then
                    strLENGTH = dX '&amp;amp; " mm"
                    strWIDTH = dZ '&amp;amp; " mm"
                    strTHICKNESS = dY

                End If

                If dZ = dY Then
                    'MsgBox("x")
                    strLENGTH = dZ '&amp;amp; " mm"
                    strWIDTH = dY
                    strTHICKNESS = dX

                End If
               

                If dX &amp;gt; dY And dX &amp;gt; dZ Then
                    'MsgBox "x"
                    strLENGTH = dX
                    If dY &amp;gt; dZ Then
                        strWIDTH = dY
                        strTHICKNESS = dZ
                    Else
                        strWIDTH = dZ
                        strTHICKNESS = dY
                    End If
                End If
            Catch ex As Exception

            End Try

            If dY &amp;gt; dZ And dY &amp;gt; dX Then
                'MsgBox "y"
                strLENGTH = dY

                If dZ &amp;gt; dX Then
                    strWIDTH = dZ
                    strTHICKNESS = dX
                Else
                    strWIDTH = dX
                    strTHICKNESS = dZ
                End If
            End If

            If dZ &amp;gt; dX And dZ &amp;gt; dY Then
                'MsgBox "z"
                strLENGTH = dZ
                If dX &amp;gt; dY Then
                    strWIDTH = dX
                    strTHICKNESS = dY
                Else
                    strWIDTH = dY
                    strTHICKNESS = dX
                End If
            End If

            Dim LENGTH As [Property]
            Dim WIDTH As [Property]
            Dim THICKNESS As [Property]
            Dim StockNumber As [Property]
            Dim RoutineDimensioned As [Property]
            Dim DimensionDirty As Boolean = False

            Try
                LENGTH = oInventorDoc.PropertySets.Item("User Defined Properties").Add("", "LENGTH")
                If Not LENGTH.Expression = strLENGTH &amp;amp; " mm" Then '(dmax.X - dmin.X) * 10 &amp;amp; " mm"
                    LENGTH.Expression = strLENGTH &amp;amp; " mm"
                    DimensionDirty = True
                End If
            Catch ex As Exception
                LENGTH = oInventorDoc.PropertySets.Item("User Defined Properties").Item("LENGTH")
                If Not LENGTH.Expression = strLENGTH &amp;amp; " mm" Then '(dmax.X - dmin.X) * 10 &amp;amp; " mm"
                    LENGTH.Expression = strLENGTH &amp;amp; " mm"
                    DimensionDirty = True
                End If
            End Try
            Try
                WIDTH = oInventorDoc.PropertySets.Item("User Defined Properties").Add("", "WIDTH")
                If Not WIDTH.Expression = strWIDTH &amp;amp; " mm" Then '(dmax.Y - dmin.Y) * 10 &amp;amp; " mm"
                    WIDTH.Expression = strWIDTH &amp;amp; " mm"
                    DimensionDirty = True
                End If
            Catch ex As Exception
                WIDTH = oInventorDoc.PropertySets.Item("User Defined Properties").Item("WIDTH")
                If Not WIDTH.Expression = strWIDTH &amp;amp; " mm" Then '(dmax.Y - dmin.Y) * 10 &amp;amp; " mm"
                    WIDTH.Expression = strWIDTH &amp;amp; " mm"
                    DimensionDirty = True
                End If
            End Try

            Try
                THICKNESS = oInventorDoc.PropertySets.Item("User Defined Properties").Add("", "THICKNESS")
                If Not THICKNESS.Expression = strTHICKNESS &amp;amp; " mm" Then '(dmax.z - dmin.z) * 10 &amp;amp; " mm"
                    THICKNESS.Expression = strTHICKNESS &amp;amp; " mm"
                    DimensionDirty = True
                End If
            Catch ex As Exception
                THICKNESS = oInventorDoc.PropertySets.Item("User Defined Properties").Item("THICKNESS")
                If Not THICKNESS.Expression = strTHICKNESS &amp;amp; " mm" Then '(dmax.z - dmin.z) * 10 &amp;amp; " mm"
                    THICKNESS.Expression = strTHICKNESS &amp;amp; " mm"
                    DimensionDirty = True
                End If
            End Try

            Try
                StockNumber = oInventorDoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number")

                If Not StockNumber.Expression = "=&amp;lt;Width&amp;gt; x &amp;lt;Thickness&amp;gt;" Then
                    StockNumber.Expression = "=&amp;lt;Width&amp;gt; x &amp;lt;Thickness&amp;gt;"
                End If

            Catch ex As Exception
                MsgBox("Stock Number Error: " &amp;amp; ex.Message)
            End Try

            'Only show message if needed on dirty property
            If oInventorDoc.Dirty = True Then

                If DimensionDirty = True Then

                    msgbox = "Dimensions of " &amp;amp; oInventorDoc.DisplayName &amp;amp; " :" &amp;amp; LENGTH.Expression &amp;amp; " x " &amp;amp; WIDTH.Expression &amp;amp; " x " &amp;amp; THICKNESS.Expression
                End If
            End If

        End If
            Catch ex As Exception

        MsgBox("Error Dimensioning: " &amp;amp; ex.Message)
    End Try

End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 19:04:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8323177#M89887</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-10-09T19:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8323877#M89892</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Bradeneurope,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Manymany Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 03:54:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8323877#M89892</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-10T03:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8325502#M89915</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;Hi&amp;nbsp;Bradeneurope,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Please help me. Now I can calculate the stock number for parts in the context Assembly. But I have a problem is I can not finish edit part in assembly by code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Can you suggest me another way that no need to edit part in the context ass, please?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Here is the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imports System&lt;BR /&gt;Imports System.Runtime.InteropServices&lt;BR /&gt;Imports Inventor&lt;/P&gt;&lt;P&gt;Public Class Form1&lt;/P&gt;&lt;P&gt;Dim invApp As Inventor.Application&lt;BR /&gt;Dim partDoc As Inventor.PartDocument&lt;BR /&gt;Dim assemblyDoc As Inventor.AssemblyDocument&lt;/P&gt;&lt;P&gt;Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click&lt;/P&gt;&lt;P&gt;invApp = Marshal.GetActiveObject("Inventor.Application")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;assemblyDoc = invApp.ActiveEditDocument&lt;BR /&gt;Dim assemblyDef As Inventor.AssemblyComponentDefinition&lt;BR /&gt;assemblyDef = assemblyDoc.ComponentDefinition&lt;/P&gt;&lt;P&gt;Dim oComponentOccurrence As Inventor.ComponentOccurrence&lt;BR /&gt;For Each oComponentOccurrence In assemblyDef.Occurrences&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim oBox As Inventor.Box&lt;BR /&gt;oBox = oComponentOccurrence.RangeBox&lt;/P&gt;&lt;P&gt;Dim dmax As Point&lt;BR /&gt;dmax = oBox.MaxPoint&lt;/P&gt;&lt;P&gt;Dim dmin As Point&lt;BR /&gt;dmin = oBox.MinPoint&lt;/P&gt;&lt;P&gt;Dim dX As Decimal&lt;BR /&gt;Dim dY As Decimal&lt;BR /&gt;Dim dZ As Decimal&lt;/P&gt;&lt;P&gt;Dim strLength As Single&lt;BR /&gt;Dim strWidth As Single&lt;BR /&gt;Dim strThickness As Single&lt;/P&gt;&lt;P&gt;dX = (dmax.X - dmin.X) * 10&lt;BR /&gt;dY = (dmax.Y - dmin.Y) * 10&lt;BR /&gt;dZ = (dmax.Z - dmin.Z) * 10&lt;/P&gt;&lt;P&gt;Dim docPrec As Integer&lt;/P&gt;&lt;P&gt;dX = Math.Round(dX, docPrec)&lt;BR /&gt;dY = Math.Round(dY, docPrec)&lt;BR /&gt;dZ = Math.Round(dZ, docPrec)&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;If dX = dY Then&lt;BR /&gt;strLength = dX&lt;BR /&gt;strWidth = dY&lt;BR /&gt;strThickness = dZ&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If dY = dZ Then&lt;BR /&gt;strLength = dX&lt;BR /&gt;strWidth = dZ&lt;BR /&gt;strThickness = dY&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;If dX = dZ Then&lt;BR /&gt;strLength = dZ&lt;BR /&gt;strWidth = dY&lt;BR /&gt;strThickness = dX&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If dX &amp;gt; dY And dX &amp;gt; dZ Then&lt;BR /&gt;strLength = dX&lt;BR /&gt;If dY &amp;gt; dZ Then&lt;BR /&gt;strWidth = dY&lt;BR /&gt;strThickness = dZ&lt;BR /&gt;Else&lt;BR /&gt;strWidth = dZ&lt;BR /&gt;strThickness = dY&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;Catch ex As Exception&lt;/P&gt;&lt;P&gt;End Try&lt;/P&gt;&lt;P&gt;If dY &amp;gt; dX And dY &amp;gt; dZ Then&lt;BR /&gt;strLength = dY&lt;BR /&gt;If dX &amp;gt; dZ Then&lt;BR /&gt;strWidth = dX&lt;BR /&gt;strThickness = dZ&lt;BR /&gt;Else&lt;BR /&gt;strWidth = dZ&lt;BR /&gt;strThickness = dX&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If dZ &amp;gt; dX And dZ &amp;gt; dY Then&lt;BR /&gt;strLength = dZ&lt;BR /&gt;If dX &amp;gt; dY Then&lt;BR /&gt;strWidth = dX&lt;BR /&gt;strThickness = dY&lt;BR /&gt;Else&lt;BR /&gt;strWidth = dY&lt;BR /&gt;strThickness = dX&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;MsgBox("Stock Number of " &amp;amp; oComponentOccurrence.Name &amp;amp; "is: " &amp;amp; strLength &amp;amp; " mm x " &amp;amp; strWidth &amp;amp; " mm x " &amp;amp; strThickness &amp;amp; " mm")&lt;/P&gt;&lt;P&gt;oComponentOccurrence.Edit()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim length As [Property]&lt;BR /&gt;Dim dimensiondirty As Boolean = False&lt;/P&gt;&lt;P&gt;partDoc = invApp.ActiveEditDocument&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try&lt;BR /&gt;length = partDoc.PropertySets.Item("User Defined Properties").Add("", "Length")&lt;/P&gt;&lt;P&gt;If Not length.Expression = strLength &amp;amp; " mm" Then&lt;/P&gt;&lt;P&gt;length.Expression = strLength &amp;amp; " mm"&lt;BR /&gt;dimensiondirty = True&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Catch ex As Exception&lt;/P&gt;&lt;P&gt;length = partDoc.PropertySets.Item("User Defined Properties").Item("Length")&lt;/P&gt;&lt;P&gt;If Not length.Expression = strLength &amp;amp; " mm" Then&lt;/P&gt;&lt;P&gt;length.Expression = strLength &amp;amp; " mm"&lt;BR /&gt;dimensiondirty = True&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;End Try&lt;/P&gt;&lt;P&gt;'...&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;End Class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ngoc Son&lt;/P&gt;&lt;P&gt;Inventor's User&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 16:47:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/8325502#M89915</guid>
      <dc:creator>ngocson8335</dc:creator>
      <dc:date>2018-10-10T16:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/10192230#M122750</link>
      <description>&lt;P&gt;Hello. I am new to the subject of Inventor VBA programming, and I also do not understand how to make the "calcualteTightBoundingBox(Body)"&amp;nbsp; in the following code&lt;/P&gt;&lt;P&gt;(source: &lt;A href="https://modthemachine.typepad.com/my_weblog/2017/06/getting-the-overall-size-of-parts.html)" target="_blank"&gt;https://modthemachine.typepad.com/my_weblog/2017/06/getting-the-overall-size-of-parts.html)&lt;/A&gt; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub TestTightBoundingBox()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN&gt;' Have a body selected.&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim body As SurfaceBody&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set body = ThisApplication.CommandManager.Pick(kPartBodyFilter, "Select the body.")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN&gt;' Call the function to get the tight bounding box.&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim bndBox As Box&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set bndBox = calculateTightBoundingBox(body)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN&gt;' Draw the bounding box using a 3D sketch.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim partDoc As PartDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set partDoc = ThisApplication.ActiveDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sk As Sketch3D&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set sk = partDoc.ComponentDefinition.Sketches3D.Add()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim lines As SketchLines3D&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set lines = sk.SketchLines3D&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tg As TransientGeometry&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tg = ThisApplication.TransientGeometry&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim minXYZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim minXYmaxZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim minXmaxYZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim minXZmaxY As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set minXYZ = bndBox.MinPoint&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set minXYmaxZ = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MinPoint.y, bndBox.MaxPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set minXmaxYZ = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MaxPoint.y, bndBox.MaxPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set minXZmaxY = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MaxPoint.y, bndBox.MinPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim maxXYZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim maxXYminZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim maxXZminY As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim maxXminYZ As Point&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set maxXYZ = bndBox.MaxPoint&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set maxXYminZ = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MaxPoint.y, bndBox.MinPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set maxXZminY = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MinPoint.y, bndBox.MaxPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set maxXminYZ = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MinPoint.y, bndBox.MinPoint.Z)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXYZ, minXYmaxZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXYZ, minXZmaxY)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(maxXYZ, maxXYminZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(maxXYZ, maxXZminY)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(maxXYminZ, maxXminYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(maxXZminY, maxXminYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXYZ, maxXminYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXYmaxZ, maxXZminY)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXmaxYZ, maxXYZ)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call lines.AddByTwoPoints(minXZmaxY, maxXYminZ)&lt;BR /&gt;End Sub &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 16:32:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/10192230#M122750</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-27T16:32:24Z</dc:date>
    </item>
    <item>
      <title>Betreff: Can't call the function to get the tight bounding box</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/10192413#M122751</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are the codetags missing around the function, so it looks a little confusing. The complete VBA Code is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Public Sub TestTightBoundingBox()
    ' Have a body selected.
    Dim body As SurfaceBody
    Set body = ThisApplication.CommandManager.Pick(kPartBodyFilter, "Select the body.")
    
    ' Call the function to get the tight bounding box.
    Dim bndBox As Box
    Set bndBox = calculateTightBoundingBox(body)
        
    ' Draw the bounding box using a 3D sketch.
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    Dim sk As Sketch3D
    Set sk = partDoc.ComponentDefinition.Sketches3D.Add()
    Dim lines As SketchLines3D
    Set lines = sk.SketchLines3D

    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
    
    Dim minXYZ As Point
    Dim minXYmaxZ As Point
    Dim minXmaxYZ As Point
    Dim minXZmaxY As Point
    Set minXYZ = bndBox.MinPoint
    Set minXYmaxZ = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MinPoint.y, bndBox.MaxPoint.Z)
    Set minXmaxYZ = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MaxPoint.y, bndBox.MaxPoint.Z)
    Set minXZmaxY = tg.CreatePoint(bndBox.MinPoint.x, bndBox.MaxPoint.y, bndBox.MinPoint.Z)
    
    Dim maxXYZ As Point
    Dim maxXYminZ As Point
    Dim maxXZminY As Point
    Dim maxXminYZ As Point
    Set maxXYZ = bndBox.MaxPoint
    Set maxXYminZ = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MaxPoint.y, bndBox.MinPoint.Z)
    Set maxXZminY = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MinPoint.y, bndBox.MaxPoint.Z)
    Set maxXminYZ = tg.CreatePoint(bndBox.MaxPoint.x, bndBox.MinPoint.y, bndBox.MinPoint.Z)
    
    Call lines.AddByTwoPoints(minXYZ, minXYmaxZ)
    Call lines.AddByTwoPoints(minXYZ, minXZmaxY)
    Call lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)
    Call lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)
    
    Call lines.AddByTwoPoints(maxXYZ, maxXYminZ)
    Call lines.AddByTwoPoints(maxXYZ, maxXZminY)
    Call lines.AddByTwoPoints(maxXYminZ, maxXminYZ)
    Call lines.AddByTwoPoints(maxXZminY, maxXminYZ)
    
    Call lines.AddByTwoPoints(minXYZ, maxXminYZ)
    Call lines.AddByTwoPoints(minXYmaxZ, maxXZminY)
    Call lines.AddByTwoPoints(minXmaxYZ, maxXYZ)
    Call lines.AddByTwoPoints(minXZmaxY, maxXYminZ)
End Sub


' Calculates a tight bounding box around the input body.  An optional
' tolerance argument is available.  This specificies the tolerance in
' centimeters.  If not provided the best existing display mesh is used.
Public Function calculateTightBoundingBox(body As SurfaceBody, Optional Tolerance As Double = 0) As Box
    On Error GoTo ErrorFound
       
    Dim vertCount As Long
    Dim facetCount As Long
    Dim vertCoords() As Double
    Dim normVectors() As Double
    Dim vertInds() As Long
       
    ' If the tolerance is zero, use the best display mesh available.
    If Tolerance &amp;lt;= 0 Then
        ' Get the best display mesh available.
        Dim tolCount As Long
        Dim tols() As Double
        Call body.GetExistingFacetTolerances(tolCount, tols)
        Dim i As Integer
        Dim bestTol As Double
        bestTol = tols(0)
        For i = 1 To tolCount - 1
            If tols(i) &amp;lt; bestTol Then
                bestTol = tols(i)
            End If
        Next
       
        Call body.GetExistingFacets(bestTol, vertCount, facetCount, vertCoords, normVectors, vertInds)
    Else
        ' Calculate a new mesh based on the input tolerance.
        Call body.CalculateFacets(Tolerance, vertCount, facetCount, vertCoords, normVectors, vertInds)
    End If

    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
   
    ' Calculate the range of the mesh.
    Dim smallPnt As Point
    Dim largePnt As Point
    Set smallPnt = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
    Set largePnt = tg.CreatePoint(vertCoords(0), vertCoords(1), vertCoords(2))
   
    For i = 1 To vertCount - 1
        Dim vertX As Double
        Dim vertY As Double
        Dim vertZ As Double
        vertX = vertCoords(i * 3)
        vertY = vertCoords(i * 3 + 1)
        vertZ = vertCoords(i * 3 + 2)
       
        If vertX &amp;lt; smallPnt.x Then
            smallPnt.x = vertX
        End If
           
        If vertY &amp;lt; smallPnt.y Then
            smallPnt.y = vertY
        End If
           
        If vertZ &amp;lt; smallPnt.Z Then
            smallPnt.Z = vertZ
        End If
       
        If vertX &amp;gt; largePnt.x Then
            largePnt.x = vertX
        End If
           
        If vertY &amp;gt; largePnt.y Then
            largePnt.y = vertY
        End If
           
        If vertZ &amp;gt; largePnt.Z Then
            largePnt.Z = vertZ
        End If
    Next
   
    ' Create and return a Box as the result.
    Set calculateTightBoundingBox = tg.CreateBox()
    calculateTightBoundingBox.MinPoint = smallPnt
    calculateTightBoundingBox.MaxPoint = largePnt
    Exit Function
ErrorFound:
    Set calculateTightBoundingBox = Nothing
    Exit Function
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 18:54:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/can-t-call-the-function-to-get-the-tight-bounding-box/m-p/10192413#M122751</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-03-27T18:54:03Z</dc:date>
    </item>
  </channel>
</rss>

