Editor Duplicate With Properties modification and link to prefab

I am Building a Editor Script that among things i want it to Duplicate Selected GameObjects.
From my research i cant seem to find a solution that will maintain any possible connection to a prefab
but also maintain any number of changes to its properties Exactly like Edit/Duplicate does.

So my first Question is have i mist something? an Editor or prefab function that maybe is not documented?

Secondly is there a way to simple invoke the systems duplicate function?

I’ve tried :

EditorApplication.ExecuteMenuItem (“Edit/Duplicate”);

But unfortunately i get an error and from what i gather none of Edit Menu its work with ExecuteMenuItem…

Any Clever Ideas?

Thanks In Advance!!


i’ve found a way to invoke the menu item!
Also to prevent and faulty duplicates like the whole assets folder i focus to the main SceneView

SceneView.lastActiveSceneView.Focus ();
EditorWindow.focusedWindow.SendEvent (EditorGUIUtility.CommandEvent ("Duplicate"));