Hardware ipt replacement

Hardware ipt replacement

susannah_lowryRR4FU
Participant Participant
318 Views
4 Replies
Message 1 of 5

Hardware ipt replacement

susannah_lowryRR4FU
Participant
Participant

Hey friends, I got a doozy for ya. The company I work for has been using Inventor for a few years now. When I came on board, I found pretty quickly that I am by far the foremost Inventor expert this company has ever had (I was an intermediate user at best), we don't have Vault (we are now getting it after I stressed how beneficial it would be, but it's slow going), and that the workflow for several thousand design assemblies has included: 

 

Copying everything from the reference design; this would be fine if that didn't include several .ipt files per design of things like ".25 steel washer" and ".5-13 steel hex bolt 1.5" (yes, each bolt material, length, & pitch has its own .ipt file within each design's designated folder)

Using only the hardware files copied over as needed, possibly going into other folders to find new files and copying them too, but not deleting the unused ones

Copying everything on to the next design as a reference and including more and more basic hardware .ipts with identical names that aren't even used in the assembly like dozens of vestigial tails

 

these hardware part files are third party bodies, I assume downloaded from McMaster. They are not custom-placed content library members and do not have any associated component authoring.

 

So since I obviously wasn't gonna continue doing that, I immediately set up a content center library. I wanted everything to show up on the BOM the way our shop & purchasing teams like, so I copied the base CC hardware to a custom library and messed with the family overrides until it did what I needed it to do. This library is what I've been using for months, manually replacing the hardware in the copied reference assemblies as I go. The rest of the engineering team has been continuing to bloat our shared drive with component files, but that's not my problem at the moment. 

 

I have convinced the company to implement Vault. There are many different reasons we need it, but the one I'm most excited about is that it will put a stop to this nonsense. Unfortunately, it will do that by breaking several thousand assemblies as it will refuse to import any of those extraneous identically-named files.

 

Friends, how do I replace the thousands of references to separate-but-identically-named .ipt files with content center parts? Is that even the right way to go about this? I didn't realize I should've been iMating everything (like I said, intermediate), and I know my coworkers haven't been, so I begrudgingly accept that the constraints will break, and that some of the .ipts are on different axes than the CC parts, so they'll sorta be floating sideways within the assemblies, but I just want Vault to approve the assembly imports without removing all hardware references.

0 Likes
319 Views
4 Replies
Replies (4)
Message 2 of 5

hollypapp65
Collaborator
Collaborator

Can't replace with CC part.  It'll break constrains.

You can get them all to use the same ipt in same folder.

Only use CC in new project.

Also depends on what they want to see in BOM.

CC will show different part number, description etc.

 

Actually nothing wrong with using those old ipt.  CC will create ipt for each part you use anyway.

Just pull them in folder and reuse them.

0 Likes
Message 3 of 5

susannah_lowryRR4FU
Participant
Participant

I'm worried that when we go to port everything into Vault it won't like that there are 8,000 files named ".375 washer.ipt" and it'll refuse to import them. Is there really no way to tell Inventor to map any instances of [each design's file path]\.375 washer.ipt to [library file path]\.375 washer.ipt? I know the constraints will break, but fixing those is easier than manually replacing every unresolved component and fixing those

0 Likes
Message 4 of 5

Curtis_W
Consultant
Consultant

Hi @susannah_lowryRR4FU , something like this might work.
Hope this helps, Curtis

' This is where the program starts running
Sub Main

	' Get the currently open assembly document in Inventor
	Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
	
	' Get all the component occurrences (parts/subassemblies) in the assembly
	Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
	
	' Print the assembly name to the log for reference
	Logger.Info(oADoc.DisplayName)

	' Start the recursive process to go through all components
	Call TraverseAssembly(oOccs)

	' After all replacements are done, print a summary
	Logger.Info("--- Replaced Documents ---")
	
	' Loop through each document that was replaced and print its path
	For Each docPath In processedDocs
		Logger.Info(docPath)
	Next

End Sub

' ========================================
' GLOBAL VARIABLE
' ========================================
' This list keeps track of which documents we've already processed
' We use this to avoid replacing the same document multiple times
' (String = text, in this case file paths)
Dim processedDocs As New List(Of String)

' ========================================
' TRAVERSE ASSEMBLY FUNCTION
' ========================================
' This function goes through every component in the assembly
' It calls itself recursively to handle nested subassemblies
Function TraverseAssembly(oOccs As ComponentOccurrences)

	' Declare a variable to hold each component occurrence as we loop
	Dim oOcc As ComponentOccurrence
	
	' Loop through each component in the current level
	For Each oOcc In oOccs

		' Get the document (file) that this component references
		Dim oDoc As Document = oOcc.Definition.Document

		' Check what type of component this is
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			' If it's an assembly (contains other parts), dive into it recursively
			' This allows us to process nested assemblies
			Call TraverseAssembly(oOcc.SubOccurrences)
		Else
			' If it's a part (not an assembly), process it for replacement
			
			UCASNAME = UCase(oDoc.FullFileName)
			
			' OPTIONAL: You can filter by filename here if needed
			' Uncomment the to only process files with "washer" or "bolt" in the name
			'If UCASNAME.Contains("WASHER") or if UCASNAME.Contains("BOLT") Then
			ReplaceComponent(oOcc)
			'End If
		End If
	Next

End Function

' ========================================
' SAVE AND REPLACE FUNCTION
' ========================================
' This function replaces a component with a version from a different folder
Sub ReplaceComponent(oOcc As ComponentOccurrence)

	' Define the folder where the replacement files are located
	' IMPORTANT: Change this path to match your file location
	newPath = "C:\Temp\LibPath\"

	' Get the document (file) for this component
	Dim oDoc As Document = oOcc.Definition.Document
	
	' Get the full file path of the current document
	' Example: "C:\Projects\Part1.ipt"
	Dim fullPath As String = oDoc.FullFileName

	' Check if we've already processed this exact document
	' If yes, exit early to avoid duplicate work
	If processedDocs.Contains(fullPath) Then Return

	' Extract just the filename from the full path
	' Example: "Part1.ipt" from "C:\Projects\Part1.ipt"
	oName = IO.Path.GetFileName(fullPath)
	
	' Build the complete path to the replacement file
	' Example: "C:\Temp\LibPath\Part1.ipt"
	Dim targetFile As String = newPath & oName

	' Check if the replacement file actually exists at the target location
	If Not IO.File.Exists(targetFile) Then
		' If the file doesn't exist, log a message and skip this component
		Logger.Info("File not found, skipping: " & targetFile)
	Else
		' The file exists, so proceed with the replacement
		
		' Replace the component with the file from the new location
		' Parameters: component name, new file path, True = update references
		Component.Replace(oOcc.Name, newPath & oName, True)
		
		' Ground the component (fixes it in place) to help avoid constraint issues
		oOcc.Grounded = True
		'delete all existing cosntraints
		For Each oConstraint As AssemblyConstraint In oOcc.Constraints
			oConstraint.Delete
		Next
		
		' Add this document to our "already processed" list
		' This prevents us from replacing the same document multiple times
		processedDocs.Add(fullPath)
	End If

End Sub

EESignature

0 Likes
Message 5 of 5

marcin_otręba
Advisor
Advisor

Hi,

 

I was there a few years ago.. and for sure you must! clean this mess before you go into vault with your designs, @Curtis_W  already gave you some code for it so try it and check if it suits you..

Enforce Unique File Names by enabling this setting - it is also must!, to be sure nobody will add duplicate files innto it, vault itself has some replace tool built in but it is not perfect.. 

You can use autoloader for vault wchich will find and show duplicates...

Those files can be also managed using some library folder and placing it there - i mean only one oof duplicated files, i bet those dupliucates are indentical so if you place one in library and replace in all assemblies you will not need to resolve any constaints - or maybe only some of it?

make good permission rules for files and files lifecycles..

 

good luck!

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders

0 Likes