<?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: HELP! Copy a part using iLogic in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599163#M112518</link>
    <description>&lt;P&gt;I think something like this should work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oApp as Inventor.Application = ThisApplication
Dim oCopyDoc as Document

Dim oCopyPartName as String = "New part name here"
Dim oAssyPath as String = ThisDoc.Path
Dim oCopyPath as String = oAssyPath &amp;amp; "\" &amp;amp; oCopyPartName &amp;amp; ".ipt"

Dim oPart as ComponentOccurrence = Components("Part to copy name here")
Dim oPartDoc as PartDocument = oPart.Definition.Document
Dim oPartFile as String = oPartDoc.FullFileName

oCopyDoc = oApp.Documents.Open(oPartFile,False)
oCopyDoc.SaveAs(oCopyPath,True)
oCopyDoc.Close

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jun 2020 17:46:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-06-24T17:46:21Z</dc:date>
    <item>
      <title>HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599041#M112515</link>
      <description>&lt;P&gt;I have read through numerous forums on copying a part, none of which seem to help me here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an assemly template, in this template I have a single part I wish to copy as a new file and save in a specified folder location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example, I have "Conduit1.ipt" as a component in an assembly, I'm looking for a code to grab the existing part, copy it as "Conduit2.ipt" and save it in the folder the assembly is saved in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me find a code I can do a simple copy and rename of the file name! I'm going crazy!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 16:54:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599041#M112515</guid>
      <dc:creator>mtresky</dc:creator>
      <dc:date>2020-06-24T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599163#M112518</link>
      <description>&lt;P&gt;I think something like this should work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oApp as Inventor.Application = ThisApplication
Dim oCopyDoc as Document

Dim oCopyPartName as String = "New part name here"
Dim oAssyPath as String = ThisDoc.Path
Dim oCopyPath as String = oAssyPath &amp;amp; "\" &amp;amp; oCopyPartName &amp;amp; ".ipt"

Dim oPart as ComponentOccurrence = Components("Part to copy name here")
Dim oPartDoc as PartDocument = oPart.Definition.Document
Dim oPartFile as String = oPartDoc.FullFileName

oCopyDoc = oApp.Documents.Open(oPartFile,False)
oCopyDoc.SaveAs(oCopyPath,True)
oCopyDoc.Close

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 17:46:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599163#M112518</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-24T17:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599218#M112520</link>
      <description>&lt;P&gt;@Anonymous&lt;/a&gt;&amp;nbsp; Thank you for the response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to accomplish this without having to open, save, close each time? Possibly just specify the part to copy, a new name, and have it copy?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only ask because this method works, however, in an assembly with a ton of parts it takes quite a while to run through when you have 50 parts to copy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 18:18:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599218#M112520</guid>
      <dc:creator>mtresky</dc:creator>
      <dc:date>2020-06-24T18:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599294#M112521</link>
      <description>&lt;P&gt;Try this iLogic rule.&lt;/P&gt;&lt;P&gt;Since your file name always has an Integer type number at the end of it, and that Integer may be 2 or 3 digits long, I created a Function to extract that number, then add 1 to it, to use in the new file name.&lt;/P&gt;&lt;P&gt;The component is already considered 'open' because it is in the active assembly, so it doesn't need to be opened again.&lt;/P&gt;&lt;P&gt;If within the SaveAs Sub, you specify true, that means it is doing a SaveCopyAs, so the original document remains open, while the new document is saved off, so you shouldn't need to close anything either.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule '" &amp;amp; iLogicVb.RuleName &amp;amp; "' only works for Assembly Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oOcc As ComponentOccurrence = oADef.Occurrences.Item(1)
Dim oOccDoc As PartDocument = oOcc.Definition.Document
Dim oPath As String = Left(oOccDoc.FullFileName, InStrRev(oOccDoc.FullFileName, "\"))
Dim oOldName As String = IO.Path.GetFileNameWithoutExtension(oOccDoc.FullFileName)
Dim oInt As Integer = ExtractInteger(oOldName)
Dim oName As String = Replace(oOldName, oInt, Nothing)
Dim oNewName As String = oName &amp;amp; oInt + 1 &amp;amp; ".ipt"
oOccDoc.SaveAs(oNewName,True)
End Sub
Function ExtractInteger(oSt As String) As Integer
	Dim oNumSt As String
	For i = 1 To Len(oSt)
		Select Case Mid(oSt, i)
		Case "1"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "2"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "3"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "4"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "5"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "6"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "7"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "8"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "9"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		Case "0"
			oNumSt = oNumSt &amp;amp; Mid(oSt, i)
		End Select
	Next
	Return CInt(oNumSt)
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 18:56:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599294#M112521</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-06-24T18:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599391#M112524</link>
      <description>&lt;P&gt;As per&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;advice, since your assembly is open you should be able to remove both the Open and Close methods from my code and it should still work. I used open/close when copying from outside an assembly and assumed it worked the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim oApp as Inventor.Application = ThisApplication

Dim oCopyPartName as String = "New part name here"
Dim oAssyPath as String = ThisDoc.Path
Dim oCopyPath as String = oAssyPath &amp;amp; "\" &amp;amp; oCopyPartName &amp;amp; ".ipt"

Dim oPart as ComponentOccurrence = Components("Part to copy name here")
Dim oPartDoc as PartDocument = oPart.Definition.Document

oPartDoc.SaveAs(oCopyPath,True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For naming/copying a lot of parts, if you want to iterate through a bunch of parts and name/copy them automatically that will be quite a bit more code. If you're looking for a more manual way, I'd make a simple form in Inventor with two text User Parameters inputs and a button to run the rule to copy.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 19:36:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9599391#M112524</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-24T19:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9601040#M112568</link>
      <description>&lt;P&gt;There is always the "&lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-0BE1A21F-E2B4-4442-A4B9-F48C26210795" target="_blank" rel="noopener"&gt;iLogic Design Copy&lt;/A&gt;" tool too, if you're familiar with that.&lt;/P&gt;&lt;P&gt;To access it, close all other Inventor documents, but leave Inventor open.&lt;/P&gt;&lt;P&gt;Then it is on the Tools tab / iLogic panel.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 11:45:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9601040#M112568</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-06-25T11:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: HELP! Copy a part using iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9602155#M112584</link>
      <description>&lt;P&gt;Thanks for your help, I got it to work using the following loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;CopyPipes&lt;/SPAN&gt;()

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPart&lt;/SPAN&gt; = &lt;SPAN&gt;Component&lt;/SPAN&gt;.&lt;SPAN&gt;InventorComponent&lt;/SPAN&gt;(&lt;SPAN&gt;"CON1:1"&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;oPart&lt;/SPAN&gt;.&lt;SPAN&gt;Definition&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Path&lt;/SPAN&gt;


	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;XX&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt; = 1 &lt;SPAN&gt;To&lt;/SPAN&gt; (&lt;SPAN&gt;COUNT1&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT2&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT3&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT4&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT5&lt;/SPAN&gt;) &lt;SPAN&gt;Step&lt;/SPAN&gt; 1		
		
		&lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;SaveAs&lt;/SPAN&gt;(&lt;SPAN&gt;oPath&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"/CON"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;XX&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;".ipt"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)

	&lt;SPAN&gt;Next&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;		&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I was able to mimic it for my straps and strut as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;CopyStraps&lt;/SPAN&gt;()

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPart&lt;/SPAN&gt; = &lt;SPAN&gt;Component&lt;/SPAN&gt;.&lt;SPAN&gt;InventorComponent&lt;/SPAN&gt;(&lt;SPAN&gt;"Strut Strap1:1"&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;oPart&lt;/SPAN&gt;.&lt;SPAN&gt;Definition&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Path&lt;/SPAN&gt;


	&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;XX&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt; = 1 &lt;SPAN&gt;To&lt;/SPAN&gt; (&lt;SPAN&gt;COUNT1&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT2&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT3&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT4&lt;/SPAN&gt; + &lt;SPAN&gt;COUNT5&lt;/SPAN&gt;)*2 &lt;SPAN&gt;Step&lt;/SPAN&gt; 1		
		
		&lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;SaveAs&lt;/SPAN&gt;(&lt;SPAN&gt;oPath&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;"/Strut Strap"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;XX&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;".ipt"&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;)

	&lt;SPAN&gt;Next&lt;/SPAN&gt;

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;		&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jun 2020 19:01:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/help-copy-a-part-using-ilogic/m-p/9602155#M112584</guid>
      <dc:creator>mtresky</dc:creator>
      <dc:date>2020-06-25T19:01:42Z</dc:date>
    </item>
  </channel>
</rss>

