Modeless Add-Ins and PDF Printing Speed

Today, I summarise a couple of topics discussed in the past week:

Simultaneous Add-In and Revit Interaction

A nice opportunity to reiterate some basic facts and consequences of the fundamental Revit add-in architecture is provided by the Revit API discussion forum thread on Revit Addin without blocking Revit UI:

Question: I would like to have my Revit add-in running without blocking the Revit UI. Should I use the MVVM design pattern for that?

In any case, how would you recommend me to make this shift and make my add-in not blocking the Revit UI? I followed the examples of @nice3point RevitTemplates/samples, but am not sure what is the best approach for me now.

Answer: The most important differentiation in this context is between modal and modeless.

Please be aware that the Revit API is single-threaded and only runs within a valid Revit API context:

A valid Revit API context is only provided by Revit in one of the numerous event handlers defined by the API and runs in the main thread of Revit. This blocks the UI, just as you say.

You can avoid this by executing parts of your add-in in a separate modeless thread. The modeless part can release the main thread, allow Revit to continue doing other stuff, and both Revit and the add-in can continue interacting with the user. However, this modeless part of your add-in has no access to the Revit API.

The preferred (and almost only) way for the modeless part of your add-in to interact with the Revit API and gain access to a valid Revit API context enabling it to do so is to implement an external event. The external event can be raised from the modeless part of the add-in. Revit then calls the corresponding event handler and provides it with a valid Revit API context.

This is discussed in great depth and with many examples by The Building Coder in the topic group on Idling and External Events for Modeless Access and Driving Revit from Outside.

The link you provided has an example "Single-project WPF Application (Modeless)", which is one way of interacting with a modeless WPF application and Revit, without blocking the UI.

Response: Thank you for the detailed explanation. What is modal though? Is it simply the pop up window using WPF? Is it related to a MVVM design pattern? What is the advantage of using MVVM in Revit plugins? So, basically the difference between the template of Single-project WPF Application (Modeless) and Single-project WPF Application (Modal) is that the latter blocks Revit UI?

Answer: Yes, modeless doesn't block Revit, modal does. As said and also stated in the samples Readme, in modeless variant you have to use IExternalEventHandler to modify the document. You don't need to use MVVM if you are just learning, but it is a good practice and should be considered for commercial plugin development.

Limited PDF Printing Speed

Colleagues share insights on PDF print time performance:

Question: I'm working on a Revit DA project to do sheet to PDF printing. However, I'm noticing that the Revit API export function is pretty slow; my current benchmark reports about 100 sheets / hour to a combined PDF. Does anyone have tips on how the export process could be sped up? Has anyone used an 3rd party library to plot the PDF's more quickly? I'm having a hard time accepting that 30 seconds / sheet is the fastest we can achieve.

Answer: I used to plan on 2 minutes per sheet when I was practicing... that meant that if we had to have the set ready on Friday we either had to have multiple people coordinating who's printing what, or the read deadline was Thursday and all day Friday my CPU was just making prints. Curious to hear what you would expect here – PDF encoding isn't quick in my experience.

Response: We're benchmarking against Clarity using the PDF-xchange print driver, which can do the same 300 sheet set in 1 hr; we're at 3; was hoping to get into a similar ballpark.

Answer: Maybe their print driver is a bit faster; could also be that it's using another method of generation so it doesn't allow a 1:1 comparison. Are they both all vector or is one doing raster output?

Family Instance Code Samples

Note to self: the help file provides some nice code samples for working with family instances that I was previously not aware of:

Apple Intelligence Foundation Language Models

Apple published a paper describing the Apple Intelligence Foundation Language Models:

We present foundation language models developed to power Apple Intelligence features, including a ∼3 billion parameter model designed to run efficiently on devices and a large server-based language model designed for Private Cloud Compute. These models are designed to perform a wide range of tasks efficiently, accurately, and responsibly. This report describes the model architecture, the data used to train the model, the training process, how the models are optimized for inference, and the evaluation results. We highlight our focus on Responsible AI and how the principles are applied throughout the model development.

LLM Arena

Are you interested in comparing results from various different LLMs?

The LMSYS Chatbot Arena supports benchmarking LLMs and VLMs in the wild and provides a chatbot arena leaderboard:

We've collected 1,000,000+ human votes to compute an LLM Elo leaderboard for 100+ models.

Find out who is the LLM Champion here!

Arena