ilogic - delete sub assembly

ilogic - delete sub assembly

Simon.robertsX5M9D
Contributor Contributor
429 Views
1 Reply
Message 1 of 2

ilogic - delete sub assembly

Simon.robertsX5M9D
Contributor
Contributor

Hi peeps

 

need help with deleting a sub assembly with in a main Assembly by using ilogic

 

In my main assembly have handled sub assembly, like to  choice the option to delete one

Can this be done by ilgoic and can it to done by the prefix of the assembly name example 027-00000-201 or 027-00000-0200 ( really like to control it by either 200 or 201 on the end of the file name)

 

thanks

 

 

 

 

 

0 Likes
430 Views
1 Reply
Reply (1)
Message 2 of 2

JhoelForshav
Mentor
Mentor

Hi @Simon.robertsX5M9D 

Are you looking for something like this? 🙂

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oDef.Occurrences
	If oOcc.Definition.Type = ObjectTypeEnum.kAssemblyComponentDefinitionObject
		Dim oName = System.IO.Path.GetFileNameWithoutExtension(oOcc.ReferencedDocumentDescriptor.DisplayName)
		Dim Last3 As String = oName.Substring(oName.Length - 3)
		If Last3 = "200" Or Last3 = "201"
			Dim oDelete As DialogResult = MessageBox.Show("Delete " & oOcc.Name, "Delete Sub Assembly?", MessageBoxButtons.YesNo)
			If oDelete = DialogResult.Yes Then oOcc.Delete
		End If

	End If
Next
0 Likes