<?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: Removing components from &amp;quot;internal&amp;quot; memory in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9716676#M115302</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8828333"&gt;@nedeljko.sovljanski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #800080;"&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Documents&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;CloseAll&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;To close all unreferenced files in Inventors memory &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Aug 2020 07:25:07 GMT</pubDate>
    <dc:creator>JhoelForshav</dc:creator>
    <dc:date>2020-08-28T07:25:07Z</dc:date>
    <item>
      <title>Removing components from "internal" memory</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9715196#M115290</link>
      <description>&lt;P&gt;I used this example from Inventor API help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub CopyBodyFromPartToPart()
    ' The first portion of this program creates an assembly so that the
    ' copy body API can be demonstrated. Any assembly could potentially
    ' be used, but the sample is simpler if it's for a specific case.
    '
    ' This creates an assembly that contains two parts. An interesting
    ' aspect of the sample is that the assembly and parts only exist
    ' in memory and are not written to disk. Filenames are assigned,
    ' so that if you perform a Save they will be written to disk using
    ' the specified filenames.

    ' Create a new assembly.
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.Documents.Add(kAssemblyDocumentObject, ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject))

    ' Define the filename for the assembly. It won't be saved at this point, but
    ' this name will be used if the assembly is saved later by the user.
    oAsmDoc.FullFileName = "C:\Users\TCuser\Documents\Inventor\Kompozitor\CopyFaces\CopyBodyTestAsm.iam"

    ' Create a new part, invisibly.
    Dim oPartDoc1 As PartDocument
    Set oPartDoc1 = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject), False)

    ' Define the filename for the part. It won't be saved at this point, but
    ' this name will be used if the part is saved later by the user.
    oPartDoc1.FullFileName = "C:\Users\TCuser\Documents\Inventor\Kompozitor\CopyFaces\CopyBodyTestPart1.ipt"

    ' Set a reference to the transient geometry object.
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc1.ComponentDefinition
    
    ' Create an extrude feature.
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(1))
    Call oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(0, 0), 2)
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent(3, kPositiveExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
    
    ' Create a second extrude feature as a work surface.
    Set oSketch = oPartDoc1.ComponentDefinition.Sketches.Add(oPartDoc1.ComponentDefinition.WorkPlanes.Item(1))
    Call oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(-3, -3), oTG.CreatePoint2d(3, 3))
    Set oProfile = oSketch.Profiles.AddForSolid

    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kSurfaceOperation)
    Call oExtrudeDef.SetDistanceExtent(1.5, kPositiveExtentDirection)
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)

    ' Insert the occurrence into the assembly using a somewhat arbitrary position.
    Dim oMatrix As Matrix
    Set oMatrix = oTG.CreateMatrix
    Call oMatrix.Translation.AddVector(oTG.CreateVector(2, 3, 4))
    Call oMatrix.SetToRotation(0.5, oTG.CreateVector(1, 0, 0), oTG.CreatePoint(2, 3, 4))
    Dim oOcc1 As ComponentOccurrence
    Set oOcc1 = oAsmDoc.ComponentDefinition.Occurrences.AddByComponentDefinition(oPartDoc1.ComponentDefinition, oMatrix)

    ' Create a second new part, invisibly.
    Dim oPartDoc2 As PartDocument
    Set oPartDoc2 = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject), False)

    ' Define the filename for the part. It won't be saved at this point, but
    ' this name will be used if the part is saved later by the user.
    oPartDoc2.FullFileName = "C:\Users\TCuser\Documents\Inventor\Kompozitor\CopyFaces\CopyBodyTestPart2.ipt"

    ' Insert the second part into the assembly using a somewhat arbitrary position.
    Set oMatrix = oTG.CreateMatrix
    Call oMatrix.Translation.AddVector(oTG.CreateVector(-1, -1, -1))
    Call oMatrix.SetToRotation(0.5, oTG.CreateVector(1, 1, 0), oTG.CreatePoint(1, 1, 1))
    Dim oOcc2 As ComponentOccurrence
    Set oOcc2 = oAsmDoc.ComponentDefinition.Occurrences.AddByComponentDefinition(oPartDoc2.ComponentDefinition, oMatrix)

    ' Get the surface body from the first part that represents the work surface.
    ' In this case we know there's only one work surface so this just gets the
    ' first work surface in the collection.
    Dim oWorkSurface As WorkSurface
    Set oWorkSurface = oPartDoc1.ComponentDefinition.WorkSurfaces.Item(1)
    Dim oBody As SurfaceBody
    Set oBody = oWorkSurface.SurfaceBodies.Item(1)

    ' Define the matrix to use in copying the surface body from one part to
    ' another. Any matrix can be used, but in this case I want the position
    ' of the body to be the same with respect to assembly space. Because
    ' the occurrences are in different positions within the assembly the matrix
    ' needs to take into account the transfrom from one occurrence to the other.

    ' Get the transform from the occurrence where the surface body currently exists.
    ' This defines the tranform of the surface body into assembly space.
    Set oMatrix = oOcc1.Transformation

    ' Get the matrix of the second occurrence and invert it.
    ' The inverse of the second occurrence's transform defines the tranform from
    ' assembly space into that occurrence's part space.
    Dim oMatrix2 As Matrix
    Set oMatrix2 = oOcc2.Transformation
    oMatrix2.Invert

    ' Combine these matrices.
    Call oMatrix.PreMultiplyBy(oMatrix2)

    ' Copy the surface body from the first part into the second. You shouldn't
    ' see anything graphically change because the new body is directly on top of
    ' the existing body, but it can be verified because the new body is in
    ' the second part.
    'Call oPartDoc2.ComponentDefinition.Features.NonParametricBaseFeatures.Add(oBody, oMatrix)
            
    Dim oDerPartDef As DerivedPartCoordinateSystemDef
    Set oDerPartDef = oPartDoc2.ComponentDefinition.ReferenceComponents.DerivedPartComponents.CreateCoordinateSystemDef(oPartDoc1.FullFileName)
    
    oDerPartDef.ExcludeAll
    oDerPartDef.IncludeAllurfaces = kDerivedIndividualDefined
    oDerPartDef.Surfaces.Item(1).IncludeEntity = True

    Call oPartDoc2.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Add(oDerPartDef)
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First time everything is fine.I closed created assembly and deleted created files from disc. But second time subroutine stopped on&lt;/P&gt;&lt;P&gt;oPartDoc1.FullFileName = "C:\Users\TCuser\Documents\Inventor\Kompozitor\CopyFaces\CopyBodyTestPart1.ipt"&lt;/P&gt;&lt;P&gt;with message:&amp;nbsp; Run-time error'5': Invalid procedure call or argument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I need to do is to close Inventor and run again, and I have next one shot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to purge Inventor from residual files in memory?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 13:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9715196#M115290</guid>
      <dc:creator>nedeljko.sovljanski</dc:creator>
      <dc:date>2020-08-27T13:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Removing components from "internal" memory</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9716676#M115302</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8828333"&gt;@nedeljko.sovljanski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #800080;"&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Documents&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;CloseAll&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;To close all unreferenced files in Inventors memory &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 07:25:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9716676#M115302</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2020-08-28T07:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing components from "internal" memory</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9717303#M115325</link>
      <description>&lt;P&gt;There is another similar tool you can use that works closely with the method Joel mentioned.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDoc.ReleaseReference&lt;/LI-CODE&gt;&lt;P&gt;Here is the pop-up info for this Sub.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Document-ReleaseReference.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/812491i5F477153C907A55F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Document-ReleaseReference.png" alt="Document-ReleaseReference.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 13:27:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9717303#M115325</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-08-28T13:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing components from "internal" memory</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9717876#M115343</link>
      <description>&lt;P&gt;Both solution can be accepted but IMPORTANT notice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They must be implement on the end of Sub CopyBodyFromPartToPart().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first implementation is:&lt;/P&gt;&lt;P&gt;oPartDoc1.ReleaseReference&lt;/P&gt;&lt;P&gt;oPartDoc2.ReleaseReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;second implementation is:&lt;/P&gt;&lt;P&gt;ThisApplication.Documents.CloseAll True&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 17:57:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/removing-components-from-quot-internal-quot-memory/m-p/9717876#M115343</guid>
      <dc:creator>nedeljko.sovljanski</dc:creator>
      <dc:date>2020-08-28T17:57:24Z</dc:date>
    </item>
  </channel>
</rss>

