You are on page 1of 5

Demote OccurrencePattern - Manufacturing DevBlog

1 de 5

http://adndevblog.typepad.com/manufacturing/2016/06/demote-occurr...

Manufacturing DevBlog
(http://adndevblog.typepad.com
/manufacturing/)
The resource for software developers working with Design, Lifecycle and Simulation
technologies from Autodesk.

06/22/2016

Demote OccurrencePattern
By Adam Nagy (http://adndevblog.typepad.com/manufacturing
/adam-nagy.html)
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:

(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01bb0915712a970d-popup)
If you think this would be something useful to have in the product
then please log it on the IdeaStation:
http://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232

20/01/2017 23:19

Demote OccurrencePattern - Manufacturing DevBlog

2 de 5

http://adndevblog.typepad.com/manufacturing/2016/06/demote-occurr...

/tab/most-recent (http://forums.autodesk.com/t5/inventorideas/idb-p/v1232/tab/most-recent)
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:

(http://adndevblog.typepad.com
/.a/6a0167607c2431970b01bb091571d3970d-popup)

20/01/2017 23:19

Demote OccurrencePattern - Manufacturing DevBlog

3 de 5

http://adndevblog.typepad.com/manufacturing/2016/06/demote-occurr...

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\te
st\demoted.iam"
Dim oControlDef As ControlDefinition
Set oControlDef = oCM.ControlDefinitions("Assemb
lyDemoteCmd")
' Execute the demote command
oControlDef.Execute
ThisApplication.SilentOperation = False

20/01/2017 23:19

Demote OccurrencePattern - Manufacturing DevBlog

4 de 5

http://adndevblog.typepad.com/manufacturing/2016/06/demote-occurr...

End Sub

Posted at 11:04 AM in Adam Nagy (http://adndevblog.typepad.com/manufacturing


/adam-nagy/), Inventor (http://adndevblog.typepad.com/manufacturing
/inventor/) | Permalink (http://adndevblog.typepad.com/manufacturing/2016/06
/demote-occurrencepattern.html)
(http://twitter.com/share?url=http%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&text=Demote%20OccurrencePattern)
(https://plus.google.com/share?url=http://adndevblog.typepad.com
/manufacturing/2016/06/demote-occurrencepattern.html)
(http://www.facebook.com/sharer.php?u=http%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html)

Comments
Comment below or sign in with
Typepad (http://www.typepad.com
/sitelogin?uri=http%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&fp=52ea211844195de5b354150dad712d60&view_uri=http
%3A%2F%2Fprofile.typepad.com%2F&via=blogside&post_uri=http:
//adndevblog.typepad.com/manufacturing/2016/06/demoteoccurrencepattern.html)
Facebook (http://www.typepad.com/sitelogin?uri=http
%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&fp=52ea211844195de5b354150dad712d60&view_uri=http
%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=facebook&
post_uri=http://adndevblog.typepad.com/manufacturing/2016/06/demoteoccurrencepattern.html)
Twitter (http://www.typepad.com/sitelogin?uri=http
%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&fp=52ea211844195de5b354150dad712d60&view_uri=http
%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=twitter&
post_uri=http://adndevblog.typepad.com/manufacturing/2016/06/demoteoccurrencepattern.html)
Google+ (http://www.typepad.com/sitelogin?uri=http
%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&fp=52ea211844195de5b354150dad712d60&view_uri=http
%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=gplus&
post_uri=http://adndevblog.typepad.com/manufacturing/2016/06/demoteoccurrencepattern.html) and more... (http://www.typepad.com/sitelogin?uri=http
%3A%2F
%2Fadndevblog.typepad.com%2Fmanufacturing%2F2016%2F06%2Fdemoteoccurrencepattern.html&fp=52ea211844195de5b354150dad712d60&view_uri=http
%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=openid&
post_uri=http://adndevblog.typepad.com/manufacturing/2016/06/demote-

20/01/2017 23:19

Demote OccurrencePattern - Manufacturing DevBlog

5 de 5

http://adndevblog.typepad.com/manufacturing/2016/06/demote-occurr...

occurrencepattern.html)

(URLs automatically linked.)

Email address is not displayed with comment.

(http://www.typepad.com/)
Manufacturing DevBlog (http://adndevblog.typepad.com/manufacturing/)

20/01/2017 23:19

You might also like