6 Replies Latest reply on Mar 7, 2014 4:04 PM by Robert Krisher

    Help with Automating ArcFM Replication with Python

    Dane Hopkins

      Hello everyone!

      I am working to automate replication via Python and had a
      few questions to see if you anyone could help!


      I wanted to incorporate system commands in my script but I’m
      not sure which executables or dlls to use. I can fire off the Set ServerOID’s
      executable in my script, but I need to Create/Update ArcFM Solution System
      tables before I can do that. Is there an executable I can use to fire off the
      Create System tables dll? I may be on the wrong path completely, so just let me
      know if my logic is correct or incorrect.


      Any help or guidance would be greatly appreciated!

        • Re: Help with Automating ArcFM Replication with Python

          Many of the ArcFM tasks aren't currently exposed to python.  There are a few user requests/ideas for this:  https://infrastructurecommunity.schneider-electric.com/ideas/1063  and https://infrastructurecommunity.schneider-electric.com/ideas/1166 .  It is possible to accomplish a lot of this (if not all of it) using c# code, but its not going to be as easy to accomplish as one might hope.

          1 of 1 people found this helpful
          • Re: Help with Automating ArcFM Replication with Python
            Jim Kyle

            I have been meaning to automate backdrop creation as well and like you a Create/Update ArcFM Solution Tables standalone script/exe is needed.

            So if you are a C#r, you could just create a console application, check out licenses, and then
            IMMSystemTablesCreator mmCreator = Activator.CreateInstance(Type.GetTypeFromProgID("MMGXTools.MMCreateSystemTablesCmd")) as IMMSystemTablesCreator;
            and then in your method do;  mmCreator.CreateSystemTables(pWS, silent);
            Refer to: http://resources.arcfmsolution.com/10.0.1/DesktopSDK/Miner.Interop.Desktop~Miner.Interop.IMMSystemTablesCreator_members.html
            (You could also put this into a python script if you are familiar with what has been referenced as ArcFM.py).

              • Re: Help with Automating ArcFM Replication with Python

                The create system tables command is pretty straight forward.  Things get a bit more interesting when you have to start dealing with the ArcFM object conversion tool, triply so if you need to convert to designer objects.  The approach I tried to tackle with this problem was actually a hybrid between the two approaches you describe here, I used C# to expose coarse grained operations as python tools (Refer to the ESRI documentaiton about IGPFunction2 for more details).  From there you would be able to use python or even model builder to automate your tasks.

                Unfortunately the solution is still pretty rough around the edges, although given the interest in the subject it would be a pretty cool topic to present at Link (especially if I could get some polish on it!).

                  • Re: Help with Automating ArcFM Replication with Python
                    Doug Krohn

                    What I did was this:

                    1. Create a Template database that only had the ArcFM Solution tables in them, upgraded to the correct release level.

                    2. Pass the Template Database into your Python script and Copy the Template DB using os and shutil libraries


                         sTemplateDB = "Template.gdb"

                         sNewDB = "New.gdb"

                         if os.path.isdir(sTemplateDB):

                              #FGDB - copy Directory and subdirs



                              #PGDB - copy File only


                    3. Use your scripts to copy whatever you want.from the Source database


                    What I do need is some Python tools/Functions to actually programmatically convert the ArcFM objects to Esri objects.  Do any of you have those tools created?

                      • Re: Help with Automating ArcFM Replication with Python
                        Jim Kyle

                        In C# it would be something like;
                        IMMObjectClassConversionTool converter = Activator.CreateInstance(Type.GetTypeFromProgID("MMGXTools.MMObjectClassConversionTool")) as IMMObjectClassConversionTool;
                                private static void ConvertDataset(IMMObjectClassConversionTool converter, IEnumDataset datasets, mmObjectClassConversionOption convertTo, bool verbose)
                                    for (IDataset dataset = datasets.Next(); dataset != null; dataset = datasets.Next())
                                        if (converter.ConvertClass(dataset as IClass, convertTo, false) && verbose)
                                            Console.WriteLine("Converted " + dataset.Name + " to " + convertTo.ToString());
                                            IEnumDataset subsets = dataset.Subsets;
                                            ConvertDataset(converter, subsets, convertTo, verbose);

                        Probably could create a python object to call this .Net object.

                        Why doesn't someone create a ArcFM - GitHub   (something like https://github.com/Esri ) and we could through up some code to share?