Hi
What is best for use API or Plugin? or it's not comparable? advantages/disadvantages for each one
For me the most important thing is that the plugin embedded in powermill gives you access to the events and the external automation libraries do not capture events executed by the user. That yes, programming a plugin is an arduous task and programming an external application is easy.
Hi guys
This is a great question. At present it is not possible to mix the two, but you have summed up their benefits perfectly. I will look into whether it is possible to use the two in collaboration.
Really in my daily work I use a plugin in powermill that I get of events that I capture in other applications, I use the plugin like bridge of information.
Hi,
i must correct you, actually it is possible to use both in the same project... I am creating a robot welding plugin and i am using both options in my project :D. I use api for entity info, and the "plugin" most of it for the events...wich are very important in my case.
cheers
I am with you, I also use the plugin to capture events and the application to interact with the plugin ... we are in the same line then ...;)
when having more than a powermill open how you control your API to get the entity from the correct pmill?
Hi,
Even when using both options to develop plugins, i don't get 2 instances of Pmill, so i didn't had to manage that problem.
How come you have more instances ? is it the user who opens 2 pmill ?
Can you please be more specific...i couldn't understand much...
ps: what is ROT ?
ROT = Running Object Table...
I use a class similar to this to capture the powermill objects that are running, but I think CSC has the encapsulated property, and does not allow the multi-instance, you should ask the CSC forum moderator if it is possible to implement multi -instance
/// <summary> /// Connect to COM Object /// </summary> public class PMDNConnect { /// The identifier of Powermill COM Object major version 9 /// </summary> internal const string IDnew = "POWERMILL.APPLICATION"; /// <summary> /// The identifier of Powermill COM Object menor version 9 /// </summary> internal const string IDold = "PMILL.DOCUMENT"; /// <summary> /// Creates the bind CTX. /// </summary> /// <param name="reserved">The reserved.</param> /// <param name="ppbc">The PPBC.</param> /// <returns></returns> [DllImport("ole32.dll")] static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc); /// <summary> /// Gets the running object table. /// </summary> /// <param name="reserved">The reserved.</param> /// <param name="prot">The prot.</param> [DllImport("ole32.dll")] internal static extern void GetRunningObjectTable(int reserved, out IRunningObjectTable prot); /// <summary> /// Class Constructor /// </summary> public PMDNConnect() { foreach(object instance in GetRunningInstances(new string[] { IDnew, IDold })) { //instance is a powermill instance } } /// <summary> /// Gets the running instances. /// </summary> /// <param name="progIds">The prog ids.</param> /// <returns></returns> private List<object> GetRunningInstances(string[] progIds) { List<string> clsIds = new List<string>(progIds); // get Running Object Table ... IRunningObjectTable Rot = null; GetRunningObjectTable(0, out Rot); if (Rot == null) return null; // get enumerator for ROT entries IEnumMoniker monikerEnumerator = null; Rot.EnumRunning(out monikerEnumerator); if (monikerEnumerator == null) return null; monikerEnumerator.Reset(); List<object> instances = new List<object>(); IntPtr pNumFetched = new IntPtr(); IMoniker[] monikers = new IMoniker[1]; // go through all entries and identifies app instances while (monikerEnumerator.Next(1, monikers, pNumFetched) == 0) { IBindCtx bindCtx; CreateBindCtx(0, out bindCtx); if (bindCtx == null) continue; string displayName; monikers[0].GetDisplayName(bindCtx, null, out displayName); foreach (string clsId in clsIds) { if (displayName.ToUpper().Contains(clsId)) { object ComObject; Rot.GetObject(monikers[0], out ComObject); if (ComObject == null) continue; instances.Add(ComObject); break; } } } return instances; } }