By Adam Nagy
There is a sample in the API Help about demoting an occurrence using the BrowserPane.Reorder function - search for "Demote occurrence API Sample"
However, it does not work in case of an OccurrencePattern, because that is not supported by the product either:
If you think this would be something useful to have in the product then please log it on the IdeaStation:
There is another way to demote a component however: use the "AssemblyDemoteCmd" control definition.
Just make sure that you are selecting the correct component - if you select Occurrences(1) that will only return an item inside the pattern and not the pattern object itself:
Sub DemoteWithCommand() Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As AssemblyComponentDefinition Set oDef = oDoc.ComponentDefinition 'Set a reference to the first occurrence Dim oOcc As ComponentOccurrence Set oOcc = oDef.Occurrences.Item(1) Dim oItemToMove As Object If oOcc.IsPatternElement Then Set oItemToMove = oOcc.PatternElement.Parent Else Set oItemToMove = oOcc End If 'Clear select set oDoc.SelectSet.Clear 'Add the occurrence to demote to the select set oDoc.SelectSet.Select oItemToMove ThisApplication.SilentOperation = True Dim oCM As CommandManager Set oCM = ThisApplication.CommandManager ' Prepopulate the file name of new component in ' the 'Create Component' dialog oCM.PostPrivateEvent kFileNameEvent, "C:\temp\test\demoted.iam" Dim oControlDef As ControlDefinition Set oControlDef = oCM.ControlDefinitions("AssemblyDemoteCmd") ' Execute the demote command oControlDef.Execute ThisApplication.SilentOperation = False End Sub