- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a rule that edits a circular pattern, it goes in and selects certain occurrences and makes them independent. Works fine. Now I need a rule that undoes this. I have managed to get it to delete the new independent parts. Then make the parts dependent again. But now I have the issue of changing their names back. As the parts when returned to the pattern do not get their original occurrence number but instead start counting from the last occurrence (which is 14). The elements in this code go by the name of 'COURSE 01 STEEL TANK SHEET Alpha v1:.......' where the dotted line is the occurrence number. I've tried a range of code to change the name back and have generally gave up at his point. What is shown below is very basic and just demonstrates what doesn't work. The message box shows the attached photo, showing that it isn't even referencing the correct thing, I need it to reference the 'COURSE 01 STEEL TANK SHEET Alpha v1:.......' name not the element. So therefore the last line does not work. I have tried many ways, and reverted back to this simple code as to try and explain what I am wanting. Any help would be greatly appreciated.
(Also any help on cleaning up the previous parts would be appreciated, I new to this syntax of coding, plain ilogic is easy for me but this type of code is all pretty new)
'Delete the independant parts
Dim doc As AssemblyDocument
doc = ThisDoc.Document
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences
oComps = doc.ComponentDefinition.Occurrences
For Each oComp In oComps
If oComp.Name.Equals("COURSE 01 STEEL TANK SHEET Alpha v1:2") Or oComp.Name.Equals("COURSE 01 STEEL TANK SHEET Alpha v1:3") Or oComp.Name.Equals("COURSE 01 STEEL TANK SHEET Alpha v1:5") Or oComp.Name.Equals("COURSE 01 STEEL TANK SHEET Alpha v1:12")Then
oComp.Delete
End If
Next
'Make the parts dependent again
Dim oCompDef As PartComponentDefinition
oDoc = ThisDoc.Document
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("COURSE 01 STEEL TANK Sheet Pattern")
oPattern.OccurrencePatternElements.Item(2).Independent = False
oPattern.OccurrencePatternElements.Item(3).Independent = False
oPattern.OccurrencePatternElements.Item(5).Independent = False
oPattern.OccurrencePatternElements.Item(12).Independent = False
'Change their names back
MessageBox.Show(oPattern.OccurrencePatternElements.Item(2).Name )
oPattern.OccurrencePatternElements.Item(2).Name = "COURSE 01 STEEL TANK SHEET Alpha v1:2"
'Reset parameter
BespokeCount = 1
Solved! Go to Solution.