Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone!
I am currently trying to write an ilogic script with which I can delete all user parameters and all user-specific iProperties in the assemblies and in the parts. The user-specific parameters are deleted with the ilogic, but the iProperties are not, I just can't get them deleted
Perhaps someone here can help me with what I am doing wrong here.
many thanks in advance
Sub Main
Dim invApp As Application
invApp = ThisApplication
' Aktive Baugruppe holen
Dim doc As AssemblyDocument
If TypeOf invApp.ActiveDocument Is AssemblyDocument Then
doc = invApp.ActiveDocument
Else
MsgBox ("Bitte eine Baugruppe öffnen!")
Exit Sub
End If
' Benutzerparameter in deren Baugruppe löschen
DeleteUserParameters(doc)
' iProperties in der Baugruppe löschen
DeleteAlliProperties(doc)
' Alle Bauteile in der Baugruppe durchlaufen
Dim compDef As AssemblyComponentDefinition
compDef = doc.ComponentDefinition
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In compDef.Occurrences
If oOccurrence.DefinitionDocumentType = kPartDocumentObject Then
Dim partDoc As PartDocument
partDoc = oOccurrence.ReferencedDocumentDescriptor.ReferencedDocument
DeleteUserParameters(partDoc)
DeleteAlliProperties(partDoc)
End If
Next
MsgBox("Alle Benutzerparameter und iProperties wurden gelöscht!")
End Sub
Sub DeleteUserParameters(ByVal doc As Document)
On Error Resume Next
Dim params As UserParameters
params = doc.ComponentDefinition.Parameters.UserParameters
Dim i As Integer
For i = params.Count To 1 Step -1
params.Item(i).Delete
Next i
On Error GoTo 0
End Sub
Sub DeleteAlliProperties(ByVal doc As Document)
On Error Resume Next
Dim propSets As PropertySets
propSets = doc.PropertySets
' Alle iProperties (Standard und Benutzerdefiniert) durchlaufen
Dim propSet As PropertySet
Dim prop As Inventor.Property
Dim i As Integer
For Each propSet In propSets
' Für jede PropertySet durchlaufen
For i = propSet.Count To 1 Step -1
prop = propSet.Item(i)
' Überprüfen, ob die iProperty nicht schreibgeschützt ist
If Not prop.ReadOnly Then
' iProperty löschen
propSet.Remove (i)
End If
Next i
Next propSet
On Error GoTo 0
End Sub
Solved! Go to Solution.