[Bug] [Regression] Set CurrentType cause SEH Exception

[Bug] [Regression] Set CurrentType cause SEH Exception

nice3point
Advocate Advocate
393 Views
7 Replies
Message 1 of 8

[Bug] [Regression] Set CurrentType cause SEH Exception

nice3point
Advocate
Advocate

Unexpected error when calling the CurrentType setter in FamilyManager. System.Runtime.InteropServices.SEHException (0x80004005):

 

nice3point_3-1740486623618.png

 

Versions affected: Revit 2025.4.

 

Note: Revit 2024 and older works fine.

 

Code sample:

 

[UsedImplicitly]
[Transaction(TransactionMode.Manual)]
public class StartupCommand : ExternalCommand
{
public override void Execute()
{
var documentsPath = $@"C:\Program Files\Autodesk\Revit {Application.VersionNumber}\Samples";
foreach (var documentPath in Directory.EnumerateFiles(documentsPath, "*.rfa"))
{
var document = Application.OpenDocumentFile(new FilePath(documentPath), new OpenOptions
{
AllowOpeningLocalByWrongUser = true,
OpenForeignOption = OpenForeignOption.Open,
Audit = false
});

try
{
using var transaction = new Transaction(document);
transaction.Start("Set CurrentType");

var familyManager = document.FamilyManager;
foreach (FamilyType familyType in familyManager.Types)
{
familyManager.CurrentType = familyType;
}

transaction.Commit();
}
finally
{
document.Close(false);
}
}
}
}

 

0 Likes
394 Views
7 Replies
Replies (7)
Message 2 of 8

nice3point
Advocate
Advocate

@jeremytammikhi Jeremy, can you track this issue ?

0 Likes
Message 3 of 8

jeremy_tammik
Alumni
Alumni

Dear Roman,

 

Thank you for your report and clear description. Sorry to hear about this.

 

I logged the issue REVIT-234047 [Set familyManager.CurrentType throws SEHException] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

  

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

  

This information is crucial. Our engineering team has limited resources and must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

  

Best regards,

 

Jeremy

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 8

nice3point
Advocate
Advocate
  • Impact on your application and/or your development.

This is used for the main functions of the application

 

  • The number of users affected.

Over 100k, including the big businesses

 

  • The potential revenue impact to you.

We can use the 2024 version where it works, but it won't cover models created in Revit 2025 and newer

 

  • The potential revenue impact to Autodesk.

Reputational impact only

 

  • Realistic timescale over which a fix would help you.

Next minor patch

0 Likes
Message 5 of 8

jeremy_tammik
Alumni
Alumni

Thank you! Noted.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 8

nice3point
Advocate
Advocate

Stacktrace

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at _CxxThrowException(Void*, _s__ThrowInfo*)
   at Autodesk.Revit.Proxy.DB.Steel.ISteelModelCallbackBridge.onPasteElements_(ISteelModelCallbackBridge*, ADocument* pTargetDoc, GUIDvalue cutId, Map<ElementId\,ElementId\,std::less<ElementId>\,tnallc<std::pair<ElementId const \,ElementId> > >* idsMap)
   at FamilyTypeAPI.setCurrentFamilyType(ADocument*, FamilyTypePair*)
   at Autodesk.Revit.DB.FamilyManager.set_CurrentType(FamilyType familyType)
   at RevitAddIn1.Commands.StartupCommand.Execute() in C:\RevitAddIn1\RevitAddIn1\Commands\StartupCommand.cs:line 35
   at Nice3point.Revit.Toolkit.External.ExternalCommand.Execute(ExternalCommandData commandData, String& message, ElementSet elements)
   at apiManagedExecuteCommand(AString* assemblyName, AString* className, AString* vendorDescription, MFCApp* pMFCApp, DBView* pDBView, AString* message, Set<ElementId\,std::less<ElementId>\,tnallc<ElementId> >* ids, Map<AString\,AString\,std::less<AString>\,tnallc<std::pair<AString const \,AString> > >* data, AString* exceptionName, AString* exceptionMessage)
0 Likes
Message 7 of 8

derek.strattonGP3G9
Autodesk
Autodesk

Hi @nice3point,

 

I was looking into this issue, but I wasn't able to reproduce the exception when I tried to run this addin in Revit 2025. I had a couple more questions to help try and figure out what's going on. 

 

I see the exception is an SEHException, which is usually thrown by a separate native exception. In the debugger when the exception is hit, is there any more information about the SEHException, such as an InnerException field?

 

I was also wondering if this only occurs on the rac_advanced_sample_family.rfa file. If you temporarily remove that file from the Samples folder and run the addin, does it work or are there other samples that throw this exception?

 

Finally, I did slightly modify the addin code to run it on my side, could you please also try this version to double check that this also produces the exception?

[Transaction(TransactionMode.Manual)]
public class StartupCommand : IExternalCommand
{
   public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
   {
      var documentsPath = $@"C:\Program Files\Autodesk\Revit {commandData.Application.Application.VersionNumber}\Samples";
      foreach (var documentPath in Directory.EnumerateFiles(documentsPath, "*.rfa"))
      {
         var document = commandData.Application.Application.OpenDocumentFile(new FilePath(documentPath), new OpenOptions
         {
            AllowOpeningLocalByWrongUser = true,
            OpenForeignOption = OpenForeignOption.Open,
            Audit = false
         });

         try
         {
            using var transaction = new Transaction(document);
            transaction.Start("Set CurrentType");

            var familyManager = document.FamilyManager;
            foreach (FamilyType familyType in familyManager.Types)
            {
               familyManager.CurrentType = familyType;
            }

            transaction.Commit();
         }
         finally
         {
            document.Close(false);
         }
      }
      return Result.Succeeded;
   }

 

Thank you!

0 Likes
Message 8 of 8

jeremy_tammik
Alumni
Alumni

The development team have not heard back on this and are unable to reproduce the problem with the information supplied, so they have now closed the ticket REVIT-234047 [Set familyManager.CurrentType throws SEHException] that we submitted for the exploration.

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes