Community
PowerShape and PowerMill API Forum
Welcome to Autodesk’s PowerShape and PowerMill API Forums. Share your knowledge, ask questions, and explore popular API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PowerMILL API vs PowerMILL Plugin

12 REPLIES 12
Reply
Message 1 of 13
rui_rita
2457 Views, 12 Replies

PowerMILL API vs PowerMILL Plugin

Hi 

 

What is best for use API or Plugin? or it's not comparable? advantages/disadvantages for each one

 

 



Os melhores cumprimentos | Best regards
Rui Rita
________________________________
NEWCAM, Lda.
12 REPLIES 12
Message 2 of 13
Vasago
in reply to: rui_rita

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.

Message 3 of 13

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.


Luke Edwards
Consulting Services Manager
Message 4 of 13

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.

Message 5 of 13
psx2
in reply to: Vasago

sorry but wath is plugin ?

A csc application ? or other?

 

an example of plugin ?

 

Thanks

Message 6 of 13
Vasago
in reply to: psx2

In the powermill directory ([YourPowermillDirectory]\file\plugins) you have examples and a guide to create plugins.

Message 7 of 13

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

Message 8 of 13
Vasago
in reply to: adrian.motea

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 ...;)

Message 9 of 13
rui_rita
in reply to: adrian.motea

@adrian.motea

 

when having more than a powermill open how you control your API to get the entity from the correct pmill?



Os melhores cumprimentos | Best regards
Rui Rita
________________________________
NEWCAM, Lda.
Message 10 of 13
adrian.motea
in reply to: rui_rita

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 ? 

Message 11 of 13
Vasago
in reply to: adrian.motea

I look for in the ROT the Powermill objects and the rescue it...

Message 12 of 13
adrian.motea
in reply to: Vasago

Can you please be more specific...i couldn't understand much...

 

ps: what is ROT ?

Message 13 of 13
Vasago
in reply to: adrian.motea

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;
        }
    }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report