Job.Info Taking a Long Time to Instantiate

Anonymous

Job.Info Taking a Long Time to Instantiate

Anonymous
Not applicable
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

 

0 Likes
Reply
Accepted solutions (1)
574 Views
3 Replies
Replies (3)

Anonymous
Not applicable

BTW... This next bit of information could be helpful.

 

I have Fabrication 2016 and 2017 installed on my computer.

Fabrication CADmep 2016 runs on top of AutoCAD.

Fabrication CADmep 2017 runs on top of AutoCAD MEP.

The Visual Studio project has only been defined to run using the AutoCAD 2017-related DLLs using .NET framework 4.5.2

 

The debug startup is:

Start external program: C:\AutoCAD 2017\acad.exe 

Command line arguments: /ld "C:\Program Files\Autodesk\Fabrication 2017\CADmep\CADmep21_x64.arx"

 

0 Likes

Anonymous
Not applicable

Solved my own problem.

The time it takes to "instantiate" the Job object is directly proportional to how many entities are in the file.

The more entities, the longer it takes.

I had over 3000 objects in the file.

 

0 Likes

Anonymous
Not applicable
Accepted solution

The solution (from Andy Robins)...

 

When you load CADmep or a DWG that contains CADmep objects, the application is basically in “viewer” mode UNTIL you use any command, then it checks the license out. I suspect if you double click on an object in the model or take a new object off, you will experience the same delay, then it will be fine and so will the API (as its licensed now).

 

Andy

0 Likes