Issue in replacing process

Issue in replacing process

rbertoletti
Enthusiast Enthusiast
120 Views
0 Replies
Message 1 of 1

Issue in replacing process

rbertoletti
Enthusiast
Enthusiast

Hi guys,

I'm working on a "convert" rule which replace all the components (including all sub assemblies) in order to create a indipendent copy of a "Template assembly".

Unfortunately some components (often Sheet metal components) are not changed by the process and some perform the replace command wrongly.

 

This is the rule:

Sub Main()
Dim oAsmDoc As AssemblyDocument 
oAsmDoc = ThisApplication.ActiveDocument  
Call Iterate(oAsmDoc.ComponentDefinition.Occurrences, 1)
iLogicVb.UpdateWhenDone = True
RuleParametersOutput()
InventorVb.DocumentUpdate()
InventorVb.DocumentUpdate(False)
End Sub 
']

Private Sub Iterate(Occurrences As ComponentOccurrences, Level As Integer)
Dim oPanelCode As String = ThisDoc.FileName(False)
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences

For Each oComp In Occurrences 
On Error Resume Next

If oComp.DefinitionDocumentType = kAssemblyDocumentObject Then	
Call Iterate(oComp.SubOccurrences, Level + 1)			   
				
'[REPLACE
Dim oOccName As String = oComp.Name
Dim oOccDoc As Document = oComp.Definition.Document
Dim oOccFullFileName As String = oOccDoc.FullFileName
	
'DEFINES BACKSLASH AS THE SUBDIRECTORY SEPARATOR
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar

'FIND THE POSITION OF THE LAST BACKSLASH IN THE PATH
oBackSlsPos = InStrRev(oOccFullFileName, "\", -1)
	
'GET THE FILE NAME WITH THE EXTENSIONS
oOccFileName = Right(oOccFullFileName, Len(oOccFullFileName) -oBackSlsPos)

'REPLACE THE TEMPLATE FILE WITH THE PANEL FILE
Dim oPanelItemsDirectory As String = ThisDoc.Path & "\" & "\LIBRARY\"
Dim oNewComp As String = oPanelItemsDirectory & oPanelCode & "_" & oOccFileName


Component.Replace(oOccName, oNewComp, True)
']
			   
Else
				
'[REPLACE
Dim oOccName As String = oComp.Name
Dim oOccDoc As Document = oComp.Definition.Document
Dim oOccFullFileName As String = oOccDoc.FullFileName
	
'DEFINES BACKSLASH AS THE SUBDIRECTORY SEPARATOR
Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar

'FIND THE POSITION OF THE LAST BACKSLASH IN THE PATH
oBackSlsPos = InStrRev(oOccFullFileName, "\", -1)
	
'GET THE FILE NAME WITH THE EXTENSIONS
oOccFileName = Right(oOccFullFileName, Len(oOccFullFileName) -oBackSlsPos)

'REPLACE THE TEMPLATE FILE WITH THE PANEL FILE
Dim oPanelItemsDirectory As String = ThisDoc.Path & "\" & "\LIBRARY\"
Dim oNewComp As String = oPanelItemsDirectory & oPanelCode & "_" & oOccFileName


Component.Replace(oOccName, oNewComp, True)
']
				 
End If  

Next 
End Sub

 

The items not changed are all the "LP" items:

rbertoletti_0-1700494875313.png

but as you can see all the other items are replaced correctly.

Also in the LINER_1 assembly the LP item replace the original "P_LPCT_CA-47V_1.ipt" with the n.er 35:

rbertoletti_1-1700494994021.png

 

Please, let me know how to fix it.

 

Thanks in advance

0 Likes
121 Views
0 Replies
Replies (0)