Anonymous
571 Views, 3 Replies

Job.Info Taking a Long Time to Instantiate

The first time that the Job.Info object is accessed it takes 20 seconds to continue to the next line.

oDR.InfoCreationDate = Job.Info.CreationDate;

 

 

// Command.cs...

namespace McKenneys
{
    public class DuctDataExport : IExtensionApplication
    {
        public void Initialize()
        {
            //string sFile = @"Autodesk\Fabrication 2017\CADmep\FabricationAPI.dll";
            //string sPF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), sFile);
            //Assembly MyDALL = Assembly.LoadFrom(sPF);
            //Type MyLoadClass = MyDALL.GetType("Autodesk.Fabrication.Job"); // name of your class
            //Activator.CreateInstance(MyLoadClass);
        }

        [CommandMethod("FabAPIDuctDataExport", "FabAPIDuctDataExport", CommandFlags.Modal)]
        public void Execute()
        {
            try
            {
                string sFile = @"Autodesk\Fabrication 2017\CADmep\FabricationAPI.dll";
                string sPF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), sFile);
                Assembly MyDALL = Assembly.LoadFrom(sPF);
                Type MyLoadClass = MyDALL.GetType("Autodesk.Fabrication.Job");
                Activator.CreateInstance(MyLoadClass);

                ClassStatic.SetApplicationProperties();
                ClassStatic.PopulateDataTables();
                new ClassFabrication();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        public void Terminate()
        {
        }

    }

}

// ClassFabrication.cs...

namespace McKenneys.Classes
{
    public class ClassFabrication
    {
        // Constructor...

        public ClassFabrication()
        {
            ...
            Data1UpdateProject();
            ...
        }

        private void Data1UpdateProject()
        {
            // Create new strongly-typed DataRow object.
            var oDR = ClassStatic.ProjectJobInformationDT.NewProjectJobInformationRow();

            oDR.ProjectId = _ProjectId;
            oDR.InfoCreationDate = Job.Info.CreationDate;
            oDR.InfoDescription = Job.Info.Description;
            ...
         }

    }

}

 

As you can see I've tried Assembly.Load from two different methods.

 

What do I need to do to resolve this?

 

Thanks,

 

Randy