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

Reload Revit Links From...

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
ATassera
4265 Views, 10 Replies

Reload Revit Links From...

Hi Everyone,

 

Here I'm attempting my second Revit tool written in C# and my noobness comes out once again 🙂 I need some help.

 

What my script is doing right now is getting the names of all linked files in the model > getting the file path from the files the user is prompted to choose from a folder depending on if the name of the link is contained in the file path > now what I want to do is to actually reload the files from the new file path (which are strings)...but it's not working.

 

This is my code for the last part:

 

foreach (string path in elementsToReload)
{
FileInfo filePath = new FileInfo(path);

ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName.ToString());

WorksetConfiguration worksetConfiguration = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets);

Element revitLink = doc.GetElement(path);
RevitLinkType revLink = revitLink as RevitLinkType;
RevitLinkType.LoadFrom(linkpath, worksetConfiguration);
}

where elementsToReload is the IEnumerable<string> that contains the file paths described above. I am sure this is correct cause if I print the result in a message box it tells me exactly the file path from where I want to reload from.

 

Now, I'm not 100% if the first part is correct, but where I get the error is when I say:

RevitLinkType.LoadFrom(linkpath, worksetConfiguration);

 

Here Visual Studio underlines RevitLinkType.LoadFrom in red and says:

'An object reference is required for the non-static field, method or property 'RevitLinkType.LoadFrom(ModelPath, WorksetConfiguration)'

 

Any idea on what am I doing wrong?

 

Thanks a lot,

 

Andrea

 

10 REPLIES 10
Message 2 of 11
MarryTookMyCoffe
in reply to: ATassera

On quick look :

doc.GetElement(path) don' t take path as method data, only id

If you what load family us: 

doc.LoadFamily(path)

or doc.LoadFamilySymbol(path, typename)

 

with revit you can install SDK, try it, it can help some times.
 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 3 of 11
jeremytammik
in reply to: ATassera
Message 4 of 11
ATassera
in reply to: jeremytammik

Thank you for your reply @jeremytammik !

 

I actually had a look at your post while I was developing my script but I must have missed something and I did something wrong in the conversions.

 

Now I modified the script and the debugger doesn't give any more red squiggly lines but the tool does not work.

Here is the code:

foreach (string path in elementsToReload)
{
    FileInfo filePath = new FileInfo(path);

    ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName.ToString());
                                
    Element revitLink = doc.GetElement(path);
    RevitLinkType revLinkType = revitLink as RevitLinkType;
    revLinkType.LoadFrom(linkpath, new WorksetConfiguration());

I think I'm still doing something wrong in the conversions from strings to RevitLinkType etc and now I catch this exception that says: "Object reference not set to an instance of an object."

 

Any advice and/or explanation is very appreciated. I find this process still quite confusing.

 

Thanks a lot!

 

Andrea

Message 5 of 11
jeremytammik
in reply to: ATassera

Dear Andrea,

 

Thank you for your update and glad to hear you are making progress.

 

Sorry to hear that the issue is not yet completely resolved.

 

The easiest way for all involved to analyse an issue like this is generally to share a minimal reproducible case:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

It makes it simpler for you to explain what the problem is, and easier for others to understand and analyse.

 

In very many cases, the simplification made in order to share the problem actually ended up solving it!

 

Whenever you run into that exception, you can easily determine exactly what is causing it by spreading out your algorithm over a maximum number of individual lines of code and stepping through them one by one in the debugger.

 

As soon as the exception is thrown, you step back up one line and look at value of the variable causing the null reference.

 

Where does the null value come from?

 

Normally, the flaw is evident as soon as you know exactly where to look.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 11
ATassera
in reply to: jeremytammik

Hi Jeremy,

 

Thanks a lot for your reply and for the suggestions. I actually applied that bit of methodology that you suggested and I ended up finding the solution and making the tool work!

 

The error in my code (so what was being null) was the revLinkType parameter that was pointing to the wrong thing.

 

I modified the loading part completely pairing ModelPath from where to reload (taken by the user selection) and the RevitLinkType to actually reload (the files linked in the folder) through the Zip and Tuple.Create methods.

To be fair it looks a bit over-complicated from my point of view. It might be an overkill but I'm not much of an expert so I'm just glad it works.

 

I'll post here following my final working code so that it can be useful for someone else (as my biggest struggle is always to find examples of the Revit API).

 

 

namespace BatchReloadRVTLinks
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            // Get application and document objects

            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Autodesk.Revit.DB.Document doc = uidoc.Document;

            // NO TRANSACTION NEEDS TO BE OPENED

            try
            {
                using (Transaction tx = new Transaction(doc))
                {
                    // Collect files linked in current project

                    FilteredElementCollector collector = new FilteredElementCollector(doc);
                    ICollection<Element> linkInstances = collector.OfClass(typeof(RevitLinkType)).ToElements();

                    // Convert ICollection into a list of RevitLinkTypes

                    List<RevitLinkType> revLinkType = new List<RevitLinkType>();
                    foreach (RevitLinkType i in linkInstances)
                    {
                        revLinkType.Add(i);
                    }

                    // Put names of linked files into a list of strings

                    List<string> linkNames = new List<string>();
                    foreach (Element i in linkInstances)
                    {
                        linkNames.Add(i.Name.Split(' ')[0]);
                    }

                    // Prompt user with files selection dialog

                    Start:
                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    openFileDialog1.InitialDirectory = (@"P:\");
                    openFileDialog1.Filter = "RVT|*.rvt";
                    openFileDialog1.Multiselect = true;
                    openFileDialog1.RestoreDirectory = true;
                    
                    // If you select the files and hit OK (in the file browser)

                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        // Show which files (path + version) has been selected before linking them

                        StringBuilder userSelectionWVersion = new StringBuilder();
                        foreach (string fp in openFileDialog1.FileNames)
                        {
                            userSelectionWVersion.AppendLine(
                                fp.ToString()
                                + " which was created with " +
                                BasicFileInfo.Extract(fp).SavedInVersion.ToString().ToUpper());
                        }

                        // Recap the user with his selection + Revit version of the file

                        DialogResult linkCorrect = MessageBox.Show(
                            userSelectionWVersion.ToString(),
                            "You selected the files:",
                            MessageBoxButtons.OKCancel);

                        // Put paths of files selected by user into a list

                        if (linkCorrect == DialogResult.OK)
                        {

                            List<string> userSelectionNames = new List<string>();
                            foreach (string fp in openFileDialog1.FileNames)
                            {
                                userSelectionNames.Add(fp.ToString());
                            }

                            // Check which of the files that the user selected have the same name of the files linked in the project

                            IEnumerable<string> elementsToReload = userSelectionNames.Where(a => linkNames.Exists(b => a.Contains(b)));

                            // Show which files need to be reloaded

                            StringBuilder intersection = new StringBuilder();
                            foreach (string fp in elementsToReload)
                            {
                                   intersection.AppendLine(fp.ToString());
                            }
                            DialogResult temp = MessageBox.Show(intersection.ToString(), "The following files need to be roloaded");

                            // Initialize + populate list of ModelPaths > path from where to reload

                            List<ModelPath> modPaths = new List<ModelPath>();

                            foreach (string fp in elementsToReload)
                            {
                                FileInfo filePath = new FileInfo(fp);
                                ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.ToString());
                                modPaths.Add(linkpath);
                            }

                            // Zip together file (as RevitLinkType) and the corresponding path to be reloaded from > Reload

                            foreach(var ab in revLinkType.Zip(modPaths, Tuple.Create))
                            {
                                ab.Item1.LoadFrom(ab.Item2, new WorksetConfiguration());
                            }
                        }
                return Result.Succeeded;
            }

            catch (Exception ex)
            {
                // If something went wrong return Result.Failed

                DialogResult genericException = MessageBox.Show(ex.Message, "Oops there was problem!");

                return Result.Failed;
            }
        }
    }
}

 

The purpose of the script is to prompt the use with a file browser to select which files wants to be reloaded, then match file path of the new files where they Contain the name of the linked file, create a tuple so you have the same order of ModelPath and RevitLinkOption and you LoadFrom with a for each file.

 

Test files attached in case anyone want to give it a go.

 

Any comment is highly appreciated as it will help me get better!

 

PS I was wondering if there is a way in the Revit APIs to get the status of the linked file (i.e. Status = Not Loaded). This would help me in selecting for reload only the files that actually need to be reloaded and avoid useless calculations.

 

Thanks again for the input 😉

 

Andrea

Message 7 of 11
ATassera
in reply to: jeremytammik

Hi @jeremytammik,

 

Thanks for your reply! Your methodology suggestion did actually put me on the right path and I managed to make the tool working!

 

The problem was that my revLinkType parameter was not pointing to the right thing so the script didn't know what to reload. I fixed the issue by pairing the ModelPath and the RevitLinkType through the Zip and Tuple.Create methods. I think it might be a bit of an overkill but I'm not much of an expert right now so I'm just glad it works. Any suggestion/comment is more than welcome

 

I'm copying here my final working script so that everyone with the same issue can have a look and it will maybe help someone:

 

namespace BatchReloadRVTLinks
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            // Get application and document objects

            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Autodesk.Revit.DB.Document doc = uidoc.Document;

            // NO TRANSACTION NEEDS TO BE OPENED

            try
            {
                using (Transaction tx = new Transaction(doc))
                {
                    // Collect files linked in current project

                    FilteredElementCollector collector = new FilteredElementCollector(doc);
                    ICollection<Element> linkInstances = collector.OfClass(typeof(RevitLinkType)).ToElements();

                    // Convert ICollection into a list of RevitLinkTypes

                    List<RevitLinkType> revLinkType = new List<RevitLinkType>();
                    foreach (RevitLinkType i in linkInstances)
                    {
                        revLinkType.Add(i);
                    }

                    // Put names of linked files into a list of strings

                    List<string> linkNames = new List<string>();
                    foreach (Element i in linkInstances)
                    {
                        linkNames.Add(i.Name.Split(' ')[0]);
                    }

                    // Prompt user with files selection dialog

                    Start:
                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    openFileDialog1.InitialDirectory = (@"P:\");
                    openFileDialog1.Filter = "RVT|*.rvt";
                    openFileDialog1.Multiselect = true;
                    openFileDialog1.RestoreDirectory = true;
                    
                    // If you select the files and hit OK (in the file browser)

                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        // Show which files (path + version) has been selected before linking them

                        StringBuilder userSelectionWVersion = new StringBuilder();
                        foreach (string fp in openFileDialog1.FileNames)
                        {
                            userSelectionWVersion.AppendLine(
                                fp.ToString()
                                + " which was created with " +
                                BasicFileInfo.Extract(fp).SavedInVersion.ToString().ToUpper());
                        }

                        // Recap the user with his selection + Revit version of the file

                        DialogResult linkCorrect = MessageBox.Show(
                            userSelectionWVersion.ToString(),
                            "You selected the files:",
                            MessageBoxButtons.OKCancel);

                        // Put paths of files selected by user into a list

                        if (linkCorrect == DialogResult.OK)
                        {

                            List<string> userSelectionNames = new List<string>();
                            foreach (string fp in openFileDialog1.FileNames)
                            {
                                userSelectionNames.Add(fp.ToString());
                            }

                            // Check which of the files that the user selected have the same name of the files linked in the project

                            IEnumerable<string> elementsToReload = userSelectionNames.Where(a => linkNames.Exists(b => a.Contains(b)));

                            // Show which files need to be reloaded

                            StringBuilder intersection = new StringBuilder();
                            foreach (string fp in elementsToReload)
                            {
                                   intersection.AppendLine(fp.ToString());
                            }
                            DialogResult temp = MessageBox.Show(intersection.ToString(), "The following files need to be roloaded");

                            // Initialize + populate list of ModelPaths > path from where to reload

                            List<ModelPath> modPaths = new List<ModelPath>();

                            foreach (string fp in elementsToReload)
                            {
                                FileInfo filePath = new FileInfo(fp);
                                ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.ToString());
                                modPaths.Add(linkpath);
                            }

                            // Zip together file (as RevitLinkType) and the corresponding path to be reloaded from > Reload

                            foreach(var ab in revLinkType.Zip(modPaths, Tuple.Create))
                            {
                                ab.Item1.LoadFrom(ab.Item2, new WorksetConfiguration());
                            }
                        }

                return Result.Succeeded;
            }

            catch (Exception ex)
            {
                // If something went wrong return Result.Failed

                DialogResult genericException = MessageBox.Show(ex.Message, "Oops there was problem!");

                return Result.Failed;
            }
        }
    }
}

Any comment is highly appreciated as it will help me get better in the future!

 

Also, find attached the test file I was using in case you guys want to give it a try.

 

PS do you know if there is a class/method to get the status of a linked file? (as it appears in the Manage Links window inside of Revit where it says Status = Not Loaded). This would help me optimise the script so I could reload only the files with the Not Loaded Status and avoid useless calculations for the files that are already correctly loaded.

 

Thanks again for the advice.

 

Ciao,

 

Andrea

Message 8 of 11
jeremytammik
in reply to: ATassera

Dear Andrea,

 

Thank you very much for sharing your solution!

 

I see the method RevitLinkType.IsLoaded, but only for Revit 2015:

 

http://www.revitapidocs.com/2018.1/a59a0c41-0fe3-9ecf-e448-82414966b745.htm

 

I am sure there is some suitable replacement available for later versions.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 11
jeremytammik
in reply to: ATassera

Dear Andrea,

 

I looked at your code and find it very confusing.

 

Here is my attempt at simplification:

 

    public Result Execute1(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )
    {
      // Get application and document objects

      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Document doc = uidoc.Document;

      using( Transaction tx = new Transaction( doc ) )
      {
        // Collect files linked in current project

        FilteredElementCollector linkInstances
          = new FilteredElementCollector( doc )
            .OfClass( typeof( RevitLinkType ) );

        // Put names of linked files into a list of strings

        List<string> linkNames = new List<string>();
        foreach( Element i in linkInstances )
        {
          linkNames.Add( i.Name.Split( ' ' )[0] );
        }

        // Prompt user with files selection dialog

        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        openFileDialog1.InitialDirectory = ( @"P:\" );
        openFileDialog1.Filter = "RVT|*.rvt";
        openFileDialog1.Multiselect = true;
        openFileDialog1.RestoreDirectory = true;

        // If you select the files and hit OK (in the file browser)

        if( openFileDialog1.ShowDialog() == DialogResult.OK )
        {
          // Show which files (path + version) has been selected before linking them

          StringBuilder userSelectionWVersion = new StringBuilder();
          foreach( string fp in openFileDialog1.FileNames )
          {
            userSelectionWVersion.AppendLine(
              fp.ToString()
              + " which was created with " +
              BasicFileInfo.Extract( fp ).SavedInVersion.ToString().ToUpper() );
          }

          // Recap the user with his selection + Revit version of the file

          DialogResult linkCorrect = MessageBox.Show(
            userSelectionWVersion.ToString(),
            "You selected the files:",
            MessageBoxButtons.OKCancel );

          // Put paths of files selected by user into a list

          if( linkCorrect == DialogResult.OK )
          {
            List<string> userSelectionNames = new List<string>();
            foreach( string fp in openFileDialog1.FileNames )
            {
              userSelectionNames.Add( fp.ToString() );
            }

            // Check which of the files that the user 
            // selected have the same name of the files 
            // linked in the project

            IEnumerable<string> elementsToReload
              = userSelectionNames.Where( a =>
                linkNames.Exists( b => a.Contains( b ) ) );

            // Show which files need to be reloaded

            StringBuilder intersection = new StringBuilder();
            foreach( string fp in elementsToReload )
            {
              intersection.AppendLine( fp.ToString() );
            }
            DialogResult temp = MessageBox.Show(
              intersection.ToString(),
              "The following files need to be roloaded" );

            // Initialize + populate list of ModelPaths 
            // > path from where to reload

            List<ModelPath> modPaths = new List<ModelPath>();

            foreach( string fp in elementsToReload )
            {
              FileInfo filePath = new FileInfo( fp );
              ModelPath linkpath = ModelPathUtils
                .ConvertUserVisiblePathToModelPath(
                  filePath.ToString() );
              modPaths.Add( linkpath );
            }

            // Zip together file (as RevitLinkType) and 
            // the corresponding path to be reloaded 
            // from > Reload

            int i = 0;
            WorksetConfiguration wc = new WorksetConfiguration();

            foreach( RevitLinkType a in linkInstances )
            {
              a.LoadFrom( modPaths[i++], wc );
            }
          }
        }
      }
      return Result.Succeeded;
    }

Do you see what I fixed, and understand why?

 

Does this also do what you need?

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 10 of 11
ATassera
in reply to: jeremytammik

Hi @jeremytammik,

 

Thanks for having a look at my code!

 

If I understand what you mean I guess the confusing parts are two:

1) You don't need to create a list of RevitLinkType and therefore you don't need to initially create an ICollection of elements

2) Zipping the name of the link to be reloaded with its file path.

 

I'll try to explain why I did it:

1) I found it confusing as well but I was taking it from another script and I copied as it was because I thought it was the way of doing it...I know it's a very bad way of doing and learning things. I'll try to avoid it in the future

Although, now I modified the program with your suggestion of using the IsLoaded method (thanks for that one as well!!) and I'm now it's a lot more efficient cause I can select whatever file from the browser but Revit is going to reload only the ones that are Not Loaded skipping the ones that don't need reloading. But to use the IsLoaded I need a RevitLinkType object otherwise it says that the method doesn't exist for other types. Is it correct?

2) I might have overworried for this last part but the reason why I Zipped a tuple and then loaded by items at the same index is because I was worried that my program could have associated the wrong file path to the file to be reloaded, hence finding that, for example, it was reloading the file named Link1 from the path C:\user\Links\Link2.rvt...does it make sense?

Looking at how you did this last part I believe it actually does the same thing without Zipping. I swapped my code with yours and it actually works as expected without mixing up files and file paths. The only problem is that it gives me an exception saying: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" Even though it then works correctly.

 

Did I understand what you meant?

 

Here is how I modified the code thanks to the IsLoaded method:

 

namespace BatchReloadRVTLinks
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            // Get application and document objects

            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Autodesk.Revit.DB.Document doc = uidoc.Document;

            // NO TRANSACTION NEEDS TO BE OPENED

            try
            {
                using (Transaction tx = new Transaction(doc))
                {
                    // Collect files linked in current project

                    FilteredElementCollector collector = new FilteredElementCollector(doc);
                    ICollection<Element> linkInstances = collector.OfClass(typeof(RevitLinkType)).ToElements();

                    // Check which elements are loaded > to be used as filter

                    List<bool> loaded = new List<bool>();
                    foreach (RevitLinkType i in linkInstances)
                    {
                        loaded.Add(RevitLinkType.IsLoaded(doc, i.Id));
                    }

                    // Convert ICollection into a list of RevitLinkTypes
                    int i1 = 0;

                    List<RevitLinkType> revLinkType = new List<RevitLinkType>();
                    foreach (RevitLinkType rli in linkInstances)
                    {
                        if (!loaded[i1++])
                        {
                            revLinkType.Add(rli);
                        }
                    }


                    // Put names of linked files into a list of strings
                    int i2 = 0;

                    List<string> linkNames = new List<string>();
                    foreach (Element eli in linkInstances)
                    {
                        if (!loaded[i2++])
                        {
                            linkNames.Add(eli.Name.Split(' ')[0]);
                        }
                    }

                    // Prompt user with files selection dialog

                    Start:
                    OpenFileDialog openFileDialog1 = new OpenFileDialog();
                    openFileDialog1.InitialDirectory = (@"P:\");
                    openFileDialog1.Filter = "RVT|*.rvt";
                    openFileDialog1.Multiselect = true;
                    openFileDialog1.RestoreDirectory = true;

                    // If you select the files and hit OK (in the file browser)

                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        // Show which files (path + version) has been selected before linking them

                        StringBuilder userSelectionWVersion = new StringBuilder();
                        foreach (string fp in openFileDialog1.FileNames)
                        {
                            userSelectionWVersion.AppendLine(
                                fp.ToString()
                                + " which was created with " +
                                BasicFileInfo.Extract(fp).SavedInVersion.ToString().ToUpper());
                        }

                        // Recap the user with his selection + Revit version of the file

                        DialogResult linkCorrect = MessageBox.Show(
                            userSelectionWVersion.ToString(),
                            "You selected the files:",
                            MessageBoxButtons.OKCancel);

                        // Put paths of files selected by user into a list

                        if (linkCorrect == DialogResult.OK)
                        {

                            List<string> userSelectionNames = new List<string>();
                            foreach (string fp in openFileDialog1.FileNames)
                            {
                                userSelectionNames.Add(fp.ToString());
                            }

                            // Check which of the files that the user selected have the same name of the files linked in the project

                            IEnumerable<string> elementsToReload = userSelectionNames.Where(a => linkNames.Exists(b => a.Contains(b)));

                            // Show which files need to be reloaded

                            StringBuilder intersection = new StringBuilder();
                            foreach (string fp in elementsToReload)
                            {
                                intersection.AppendLine(fp.ToString());
                            }
                            DialogResult promptToLoad = MessageBox.Show(intersection.ToString(), "The following files need to be roloaded");

                            // Initialize + populate list of ModelPaths > path from where to reload

                            List<ModelPath> modPaths = new List<ModelPath>();

                            foreach (string fp in elementsToReload)
                            {
                                FileInfo filePath = new FileInfo(fp);
                                ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.ToString());
                                modPaths.Add(linkpath);
                            }

                            // Zip together file (as RevitLinkType) and the corresponding path to be reloaded from > Reload

                            foreach (var ab in revLinkType.Zip(modPaths, Tuple.Create))
                            {
                                ab.Item1.LoadFrom(ab.Item2, new WorksetConfiguration());
                            }
                        }

                return Result.Succeeded;
            }

            catch (Exception ex)
            {
                // If something went wrong return Result.Failed

                DialogResult genericException = MessageBox.Show(ex.Message, "Oops there was problem!");

                return Result.Failed;
            }
        }
    }
}

Does it make sense?

 

Thanks for the help!

 

Andrea

Message 11 of 11
jeremytammik
in reply to: ATassera

Looks better, could be further simplified. I would still skip the Zip, but that's up to you. Anything that works, works.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community