Copy Custom Parameters from one .ipt to Multiple.ipt's (Existing Files)

Copy Custom Parameters from one .ipt to Multiple.ipt's (Existing Files)

RockyBrown4134
Collaborator Collaborator
3,715 Views
23 Replies
Message 1 of 24

Copy Custom Parameters from one .ipt to Multiple.ipt's (Existing Files)

RockyBrown4134
Collaborator
Collaborator

Is ther a way to copy parameters from one part file to multiple part files? I have two parameters that I would like to add to multiple files at once.

 

The Example below, Cutlength already existin in the part files. I want to add the parameters FT and IN. My ultimate gole is to have feet and inches displayed in my parts list.

 

parameter.jpg

 

 

Thanks.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Accepted solutions (3)
3,716 Views
23 Replies
Replies (23)
Message 21 of 24

tjvz85
Enthusiast
Enthusiast

Hi @Curtis_Waguespack ,

 

Would it be possible to adjust the Select Parts File rule to have a window select option, to pick parts right from the open assembly, or browser?

0 Likes
Message 22 of 24

Curtis_Waguespack
Consultant
Consultant

Hi @tjvz85 

 

The batch file in this thread is a part file, but assuming you've copied the rules and form from that file to an assembly file and have all of that working, you could use this example or something similar for the selection rule.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Sub Main
Create_Params()
Select_Files()
End Sub

Sub Create_Params()


' Get the active document.  Assumes a part document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

' Get the UserParameters collection
Dim userParams As UserParameters
userParams = oDoc.ComponentDefinition.Parameters.UserParameters

'check for parameter and create if not found
Try
	oTest = Parameter("Part_Files_List") 
Catch
	'multi-value text parameter
	userParams.AddByValue("Part_Files_List", "< No Files >", UnitsTypeEnum.kTextUnits)
End Try
Parameter.Param("Part_Files_List").IsKey​ = True


Try
	oTest = Parameter("ActionList") 
Catch
	'multi-value text parameter
	userParams.AddByValue("ActionList", "Copy All Custom Parameters", UnitsTypeEnum.kTextUnits)
	MultiValue.SetList("ActionList", "Copy All Custom Parameters", "Delete All Custom Parameters")

End Try
Parameter.Param("ActionList").IsKey​ = True


End Sub

Sub Select_Files()


Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveEditDocument.ComponentDefinition
Dim oPart As ComponentOccurrence

Dim oHighLight As Inventor.HighlightSet
oHighLight = ThisDoc.Document.CreateHighlightSet

Dim oSelect As ComponentOccurrence 
Dim oNamesList As New ArrayList


Dim oPrompt1 As String 
oPrompt1 = "Select components, then press Escape to continue..."
While True

	oSelect = ThisApplication.CommandManager.Pick _
		(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, oPrompt1)
		
		'if nothing then exit
	If IsNothing(oSelect) Then Exit While  
		
	
	oNamesList.Add(oSelect.Definition.document.fullfilename)
	Call oHighLight.AddItem(oSelect)	

End While

'define ArrayList to hold each file name
Dim MyArrayList As New ArrayList

'add existing parameter list items to the array
For Each Item In MultiValue.List("Part_Files_List")
	If Item <> "< No Files >" Then
	MyArrayList.Add(Item)
	Else 
	End If
Next


'Loop through result strings with For Each.
Dim sFile As String
i = 0
For Each sFile In oNamesList
'check for duplicates then 
'add selected files to the array
If Not (MyArrayList.Contains(sFile)) Then
	MyArrayList.Add(sFile)
Else
'add to counter for each duplicate file
i = i +1
End If
Next

'add the array to the parameter list
MultiValue.List("Part_Files_List") = MyArrayList
Parameter("Part_Files_List") = myArrayList(0)

If i >0 Then
MessageBox.Show("Note: Duplicate file(s) not added to the list.","iLogic", _
MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

End Sub


 

EESignature

0 Likes
Message 23 of 24

tjvz85
Enthusiast
Enthusiast

Thanks so much @Curtis_Waguespack ,

 

We have taken it all and converted to a global form, to run external rules. The Select Part Files routine adds the parameter needed for the batch rule to run and then we proceed from there.

 

Thanks so much, will test and let you know how it works.

0 Likes
Message 24 of 24

tjvz85
Enthusiast
Enthusiast

Works like a charm, thanks again.

0 Likes