Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
filippo.costantin3HZMT
584 Views, 8 Replies

Delete occurrence in Assembly

Hi everyone, 

 

I wrote a code for read iproperties from part or assembly in folder. The code run:

1 - read all file in folder

2 - filter file in folder (.asm, .ipt)

3 - add component to assembly

4 - read iproperties

5 - delete component

All works very weel but the last phase give me the error:

filippocostantin3HZMT_0-1666341928679.png

I create many logger for control the code anche the code raw that give me a problem is:

 

Sub DeleteComponent()
	Dim oAsmCompDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oAsmCompDef.Occurrences
		
		If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
			Logger.Info("⃝⃝⃝⃝  [ Rimozione assieme " & oOcc.Name & " ]")
			oOcc.Delete()
			Logger.Info("⃝⃝⃝⃝  [ Fine rimozione dell'elemento  " & oOcc.Name & " ]")
		End If	
	Next
End Sub

 

oOcc.Delete()

 

I've already use this function in other code but now I've this problem.

 

How can i Solve it? 

 

In attached the complete code. 

 

Thanks