Quantcast
Channel: All Revit API Forum posts
Viewing all 67020 articles
Browse latest View live

Re: Automatically OpenAndActivate a cloud model on Revit startup

$
0
0

Maybe it's Idling, it's usually not safe to run long processes in there.

 

You could use ExternalEvent and verify if that works.

 

Some sample code like this:

using Autodesk.Revit.DB; using Autodesk.Revit.UI; using System; namespace RevitAddin.Forum { public class AppCloud : IExternalApplication { public Result OnStartup(UIControlledApplication application) { var region = ModelPathUtils.CloudRegionUS; var projectGuid = Guid.Parse("00000000-0000-0000-0000-000000000000"); var modelGuid = Guid.Parse("00000000-0000-0000-0000-000000000000"); // Create ExternalEvent and Raise to execute in the next idle cycle ExternalEvent.Create(new CloudOpenExternalEvent(region, projectGuid, modelGuid)).Raise(); return Result.Succeeded; } public Result OnShutdown(UIControlledApplication application) { return Result.Succeeded; } } public class CloudOpenExternalEvent : IExternalEventHandler { private string Region; private Guid ProjectGuid; private Guid ModelGuid; public CloudOpenExternalEvent(string region, Guid projectGuid, Guid modelGuid) { Region = region; ProjectGuid = projectGuid; ModelGuid = modelGuid; } public void Execute(UIApplication uiapp) { try { var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(Region, ProjectGuid, ModelGuid); var options = new OpenOptions(); uiapp.OpenAndActivateDocument(modelPath, options, false); } catch (Exception ex) { TaskDialog.Show(GetName(), ex.ToString()); } } public string GetName() { return nameof(CloudOpenExternalEvent); } } }

 

 

 

 


Re: Creating an Electrical System by selecting voltage and phase (instance parameters)

$
0
0

@saugat_karki wrote:

Jeremy, 

I still cannot find the method where I can specify voltage and phase. Could you please direct me to where that is?

 


There is no method to specify the voltage and phase.

 

The only way would be selection the instance family, find the instance parameter for the voltage and phase, change the values and execute the method to create the ElectricalSystem.

 

[BUG] Hiding not working when exporting images

$
0
0

When using the OpenDocumentFile() method to open a document in memory, the ExportImage() method ignores hidden elements. Specifically, methods such as HideCategoriesTemporary(), HideElements(), and HideElementsTemporary() do not have any effect on the visibility of elements during the image export process

 

Steps to Reproduce:

  1. Open a document in memory using the OpenDocumentFile() method.

  2. Use any of the hiding methods (HideCategoriesTemporary(), HideElements(), HideElementsTemporary()) to hide specific elements or categories.

  3. Call the ExportImage() method to export an image of a view.

 

 

Workaround:

 

Interestingly, if the view.Outline property is accessed before calling ExportImage(), the hidden elements are correctly excluded from the exported image. The fact that accessing view.Outline resolves the issue suggests that there may be an internal state or initialization step that is not being triggered correctly when ExportImage() is called directly. view.get_BoundingBox(null); also works in the same way

Impact:

 

This behavior disrupts the expected CodeFlow, as the document visibility is changed unintentionally. This issue is particularly critical for one application with over 100,000 users, as it can lead to inconsistent user experiences and potential workflow interruptions.

 

Affected Revit Versions:

2022-2025, Preview

回复: How to get only visible elements in active view

$
0
0

Hello @scgq425 !

Sorry for the late reply and thank you for your suggesion.

When I use BoundingBoxIsInsideFilter(), it doesn't work for me that I wanted.

 

But thank you for your helps!

Re: How to get only visible elements in active view

$
0
0

Hello @jeremy_tammik !

 

Thank you for your help.

It was difficult to solve my problem with what you sent me.

 

I will continue to look for other ways.

 

But thank you for your helps!

 

Re: Automatically OpenAndActivate a cloud model on Revit startup

$
0
0

Perfect thank you so much. I needed to seperate it out of OnStartup, however its essentally the same:

Private Shared _externalEvent As ExternalEvent Public Sub CreateAndRaiseExternalEvent(filePath As String) _externalEvent = ExternalEvent.Create(New ExternalEvent(filePath)) _externalEvent.Raise() End Sub

Re: Automatically OpenAndActivate a cloud model on Revit startup

Re: RevitAPI typo - PresureLossReport ViewType?

$
0
0

Hi @jmcouffin,

 

Thank you for reporting this. I will raise the matter with the Revit Engineering team and ensure it is resolved.


Re: How to get only visible elements in active view

$
0
0

Oh dear, sorry that it remains tricky. I asked Gemini for you, as described in my blog, and it replies:

   

Let's dive into efficiently retrieving visible elements in the active Revit view. You're right, VisibleInViewFilter and WhereElementIsViewIndependent alone aren't sufficient when crop regions or other visibility overrides are in play. They indicate potential visibility, not actual, rendered visibility within the current view's context. We need a more robust approach.

Here's a breakdown of the problem and a practical solution, combining best practices and leveraging the Revit API:

The Challenge:

The Revit API doesn't offer a single, direct method to get precisely what's visually rendered in the active view, especially considering crop regions, temporary view templates, and element overrides. VisibleInViewFilter only checks if an element could be visible in some view, not the current one with its specific settings. WhereElementIsViewIndependentfilters elements that are view-specific, but it doesn't filter based on visibility.

The Solution: Combining Filters and Bounding Box Intersections

The most reliable approach involves a combination of filtering and geometric checks. We'll use the view's crop box (or its equivalent if it's not rectangular) to define the visible region and then check if element bounding boxes intersect with this region. This approach is accurate and handles crop boxes effectively.

C#
 
using Autodesk.Revit.DB;using Autodesk.Revit.UI;using System.Collections.Generic;using System.Linq;publicclassVisibleElementsInView
{publicstatic List<Element> GetVisibleElements(Document doc, View activeView)
    {
        List<Element> visibleElements = new List<Element>();// 1. Get the View's Crop Box (or its equivalent for non-rectangular crops)// For simplicity, assuming a rectangular crop box here.  Adapt as needed for more complex shapes.
        BoundingBoxXYZ cropBox = activeView.CropBox;
        XYZ minPt = cropBox.Min;
        XYZ maxPt = cropBox.Max;// Create an outline for the cropbox.
        Outline cropOutline = new Outline(minPt, maxPt);// 2. Collect all elements in the view (filtering can improve performance)// You can add more specific filters here if you know element categories you are interested in.
        FilteredElementCollector collector = new FilteredElementCollector(doc, activeView.Id);// Example: Filter for model elements only:
        collector.OfClass(typeof(FamilyInstance)); // Or other relevant classes// 3. Iterate and check for intersectionforeach (Element element in collector)
        {// Get the element's bounding box (handles various element geometries)
            BoundingBoxXYZ elementBox = element.get_BoundingBox(activeView);if (elementBox != null) // Handle cases where bounding box is null
            {// Check for intersection with the crop boxif (cropOutline.Intersects(new Outline(elementBox.Min, elementBox.Max)))
                {
                    visibleElements.Add(element);
                }

            }
        }

        return visibleElements;
    }// Example usage (in an external command or application):publicvoidExecute(ExternalCommandData commandData, refstring message, ElementSet elements)
    {
        Document doc = commandData.Application.ActiveUIDocument.Document;
        View activeView = doc.ActiveView;

        List<Element> visibleElements = GetVisibleElements(doc, activeView);

        TaskDialog.TaskDialog.Show("Visible Elements", $"Found {visibleElements.Count} visible elements.");// Do something with the visibleElements list...
    }
}

Explanation and Key Improvements:

  1. Crop Box Retrieval: We retrieve the CropBox of the active view. For non-rectangular crop regions, you'll need to get the CurveLoop representing the crop boundary and use more advanced geometric intersection methods.

  2. Efficient Element Collection: The FilteredElementCollector with the activeView.Id is crucial. This limits the initial collection to elements in the view, significantly improving performance compared to collecting all elements in the model. You can further refine this collector with additional filters (e.g., OfClass, OfCategory) to target specific element types for even better performance.

  3. Bounding Box Intersection: The core logic uses Outline.Intersects. This checks if the element's bounding box intersects with the view's crop box. This is a robust way to determine visibility within the cropped region.

  4. Null Bounding Box Handling: The code now includes a check for elementBox != null. Some elements (like annotation elements far from the view) might have null bounding boxes. Handling this prevents exceptions.

  5. Example Usage: The provided Execute method demonstrates how to use the GetVisibleElements function within a Revit command.

Further Considerations:

  • Performance: For extremely large models, you might consider spatial partitioning techniques (e.g., using the SpatialElement classes) to further optimize the intersection checks.

  • Non-Rectangular Crops: For complex crop shapes, you'll need to work with the CurveLoop of the crop region and implement more sophisticated geometric intersection tests (e.g., using the XYZ.DistanceTo method or other geometric utilities).

  • Temporary View Modes: Be aware that temporary view modes (like Reveal Hidden Elements) can affect visibility. You might need to adjust your logic based on the current view's temporary view mode if your add-in needs to handle these cases.

This approach provides a practical and reliable way to get truly visible elements in the active Revit view, addressing the limitations of simpler visibility filters. Remember to adapt the crop region handling for non-rectangular shapes if needed. Let me know if you have any other questions!

  

I hope that this explanation can prove useful in your further research. Please let us know how it goes. Thank you and good luck! 

   

Re: Drawing Sheet Automation

$
0
0

Automating drawing creation in Revit is definitely possible and a powerful way to boost productivity. It involves a combination of techniques, from simple scripting to more advanced add-in development. Let's explore the options and I'll point you to resources that demonstrate these techniques.

Methods for Drawing Sheet Automation in Revit:

  1. Revit API (Add-in Development): This is the most flexible and powerful approach. Using the Revit API (C# or Python), you can programmatically create views, place them on sheets, set parameters, and even control annotations. This is ideal for complex, customized workflows.

  2. Dynamo: Dynamo is a visual programming tool that integrates with Revit. It allows you to create scripts (graphs) to automate tasks, including drawing creation. Dynamo is great for less complex automations where you don't want to dive into full add-in development.

  3. Built-in Revit Features (Less Automated): Revit itself has some features that assist in drawing creation, like view templates and the ability to duplicate views. While not fully automated, these can streamline parts of the process.

Example Scenario (Revit API - C#):

Let's outline a simplified C# example using the Revit API to create sheets and place views on them. This is a basic illustration, but it can be extended for more complex scenarios.

C#
 
using Autodesk.Revit.DB;using Autodesk.Revit.UI;using System.Collections.Generic;using System.Linq;publicclassCreateDrawings
{publicvoidExecute(ExternalCommandData commandData, refstring message, ElementSet elements)
    {
        Document doc = commandData.Application.ActiveUIDocument.Document;// 1. Get or create a Title Block family
        FamilySymbol titleBlock = GetTitleBlock(doc, "YourTitleBlockName"); // Replace with your title block name// 2. Define view information (e.g., view names, view types, levels)
        List<ViewInfo> viewInfos = GetViewInformation(); // Function to define your views// 3. Create sheets and place viewsusing (Transaction t = new Transaction(doc, "Create Drawings"))
        {
            t.Start();foreach (ViewInfo viewInfo in viewInfos)
            {// Create a new sheet
                ViewSheet newSheet = ViewSheet.Create(doc, titleBlock.Id);
                newSheet.Name = viewInfo.SheetName;
                newSheet.SheetNumber = viewInfo.SheetNumber;// Get the view to place (assuming it exists)
                View viewToPlace = doc.GetElement(viewInfo.ViewId) as View;if (viewToPlace != null)
                {// Place the view on the sheet (adjust location as needed)
                    XYZ viewLocation = new XYZ(2, 2, 0); // Example location
                    Viewport.Create(doc, newSheet.Id, viewToPlace.Id, viewLocation);
                }
            }

            t.Commit();
        }
    }

    // Helper functions (implementation omitted for brevity - you'll need to define these)private FamilySymbol GetTitleBlock(Document doc, string titleBlockName) { /* ... */ }private List<ViewInfo> GetViewInformation() { /* ... */ }// Inner class to hold view informationpublicclassViewInfo
    {publicstring SheetName { get; set; }publicstring SheetNumber { get; set; }public ElementId ViewId { get; set; }
    }
}

Key Concepts and Improvements:

  • Transaction: All Revit API modifications must be within a transaction.
  • Title Block: You need to get a title block family to create sheets.
  • View Information: The ViewInfo class (or a similar structure) is essential to organize the data for each sheet and the views to be placed. You'll need to populate this with your specific view names, sheet numbers, and view IDs.
  • View Placement: The Viewport.Create method places the view on the sheet at a specified location.
  • Error Handling: Production-ready code should include robust error handling (e.g., checking if views exist, handling exceptions).

Dynamo Approach:

Dynamo offers a more visual way to achieve similar automation. You would use nodes to:

  1. Select views.
  2. Create sheets (potentially with title block selection).
  3. Place views on sheets.
  4. Set sheet parameters (number, name, etc.).

Dynamo is generally easier to learn for basic automation tasks, while the Revit API provides more flexibility for complex scenarios.

Video Demonstration and Resources:

Searching YouTube for "Revit drawing automation" or "Revit API sheet creation" will yield numerous tutorials and demonstrations. Look for videos covering both the Revit API and Dynamo approaches.

Recommendation:

  • Start with Dynamo: If you're new to automation, Dynamo is a great starting point. You can quickly create simple scripts to automate basic drawing creation tasks.
  • Move to the Revit API: For more complex and customized workflows, learning the Revit API (C# or Python) is essential. This will give you complete control over the drawing creation process.

    

I hope this helps you get started with drawing sheet automation in Revit!

     

Let us know if you have more questions.

   

Re: Revit can not find my gpu nvidea

$
0
0

Please note that this discussion forum is dedicated to programming desktop Revit using the desktop Revit API.

      

However, in spite of the wrong place for this discussion, I quickly posted your query to Gemini for you, and it replies:

   

Let's troubleshoot why Revit 2023 isn't recognizing your NVIDIA 940, even though you have DirectX 12. This is a common issue, and we'll go through the likely causes and solutions step by step.

1. Driver Issues (Most Likely Culprit):

  • Clean Install of Drivers: A corrupted or outdated driver is the most frequent cause. Don't just update; perform a clean install:

    1. Download the latest driver for your NVIDIA 940 from the official NVIDIA website. Make sure it's the correct driver for your Windows version (e.g., Windows 10 64-bit, Windows 11).
    2. Uninstall the current NVIDIA driver completely. Use Display Driver Uninstaller (DDU) for a thorough removal. This tool is highly recommended for a clean slate. You can find it with a quick web search.
    3. Reboot your computer.
    4. Install the newly downloaded driver. Choose the "Custom Installation" option and select "Perform a clean installation."
  • Driver Compatibility: Although you have DirectX 12, Revit might be looking for specific driver features related to DirectX 11. Ensure you're using a driver that's compatible with both DirectX 11 and 12. The latest drivers usually are, but sometimes older ones can cause conflicts.

2. Revit Hardware Acceleration Settings:

  • Check Revit Options:

    1. Open Revit.
    2. Go to File > Options > Hardware.
    3. Make sure "Use Graphics Card" is checked.
    4. Under "Graphics Display," check that your NVIDIA 940 is selected (if it appears in the list). If it doesn't, that's a key indicator of the driver problem.
    5. If DirectX 11 is flagged, don't worry too much about it yet. We'll address this after the driver reinstall.
  • Advanced Graphics Settings (If Available):Some Revit versions have an "Advanced Graphics" button.1 If you see it, click it and ensure your NVIDIA card is selected there as well.

3. Windows Graphics Settings:

  • Graphics Settings in Windows 10/11:
    1. Search for "Graphics settings" in the Windows search bar.
    2. Click "Graphics settings."
    3. In the dropdown, select "Desktop app" and click "Browse."
    4. Navigate to the Revit executable (usually C:\Program Files\Autodesk\Revit 2023\Revit.exe).
    5. Select the Revit executable and click "Add."
    6. Once Revit is added, click "Options."
    7. Choose "High performance" to force Windows to use your NVIDIA GPU for Revit.

4. BIOS Settings (Less Common):

  • Integrated Graphics: In rare cases, your BIOS might have the integrated graphics of your CPU enabled, which could be conflicting. Check your BIOS settings (usually accessed by pressing DEL, F2, or F10 during startup) and disable the integrated graphics if it's on. (Only do this if you're comfortable working in the BIOS; otherwise, skip this step.)

5. DirectX Installation (Unlikely, but Check):

  • DirectX 12 is Backward Compatible: DirectX 12 should include all the necessary components for DirectX 11. However, to be absolutely sure:
    1. Download the DirectX End-User Runtime Web Installer from Microsoft's website.
    2. Run the installer. It will check for any missing DirectX 11 components and install them if needed.

6. Revit Installation (Last Resort):

  • Repair or Reinstall: If all else fails, there might be a problem with your Revit installation. Try repairing Revit first. If that doesn't work, a full reinstall might be necessary.

Troubleshooting Steps:

  1. Prioritize Drivers: The driver issue is the most likely cause. Focus on the clean driver reinstall using DDU first.
  2. Revit Options: Double-check the Revit hardware acceleration settings.
  3. Windows Graphics Settings: Configure Windows to use the NVIDIA GPU for Revit.
  4. DirectX Check: Run the DirectX installer.
  5. Revit Reinstall: If nothing else works, try repairing or reinstalling Revit.

Regarding DirectX 11 Flag:

The red flag on DirectX 11 in Revit's hardware configuration might not be a major concern initially. Revit often uses DirectX 11 for certain tasks even if your system supports DirectX 12. The key is to get Revit to recognize your NVIDIA card. Once that's done, the DirectX 11 flag might disappear, or it might remain, but the hardware acceleration should still work correctly.

    

After each step, restart Revit to see if the changes take effect. If you still have problems, please provide more details about your system (Windows version, exact NVIDIA driver version you're trying, etc.) and raise your issue in one of the more appropriate non-API, product related forums:

   

https://forums.autodesk.com/t5/revit-api-forum/this-forum-is-for-revit-api-programming-questions-not-for/td-p/5607765
   

Thank you!

   

Re: [BUG] Hiding not working when exporting images

$
0
0

Dear Roman,

  

Thank you for your report, clear description and sample material.

 

Sorry to hear about this.

 

I logged the issue REVIT-232472 [OpenDocumentFile + ExportImage ignores hidden elements] 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.

  

If it is especially important and urgent for you, you might also want to mention this ticket number in the preview discussion forum, where you have more access to chat directly with the development team.

 

Best regards,

 

Jeremy

  

Re: [BUG] ExportImage breaks the in-memory model

$
0
0

Dear Roman,

 

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

  

I logged the issue REVIT-232473 [ExportImage unintentionally displays BIM to user violating official docs] 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.

  

If it is especially important and urgent for you, you might also want to mention this ticket number in the preview discussion forum, where you have access to chat directly with the development team.

 

Best regards,

 

Jeremy

   

"Ignore All" Button Not Stopping Spell Check Process in WPF

$
0
0

Hi All,

I am implementing a spell check feature in my Revit add-in using WPF. The issue I am facing is that when I click "Ignore All", the spell check window still opens for each word instead of stopping immediately.

 

External Command

 

public bool stopProcessing = false; // Flag to stop processing public void OpenSpellCheckWindowForWord(List<string> incorrectWords) { // Create a new SpellCheckWindow for the current word SpellCheckWindow spellCheckWindow = new SpellCheckWindow(incorrectWords, ref stopProcessing); // Make a copy of the list to loop over List<string> wordsToProcess = new List<string>(incorrectWords); // Loop through the list of incorrect words and open a window for each foreach (string word in wordsToProcess) { // If stopProcessing flag is true, stop processing if (stopProcessing) { break; } // Set the word to display in the UI elements (TextBoxes) spellCheckWindow.IncorrectWordsTextBox.Text = word; spellCheckWindow.NotInDictionaryTextBox.Text = word; // Show the window and block further execution until it is closed bool dialogResult = (bool)spellCheckWindow.ShowDialog(); // If "Ignore All" was clicked, stop processing if (stopProcessing) { break; } } }

 

 

WPF Spell Check Window Code (Behind Code)

 

 

// For Ignore Button click private void IgnoreButton_Click(object sender, RoutedEventArgs e) { if (IncorrectWords.Any()) { // Remove the current word from the list IncorrectWords.RemoveAt(0); // Close the current window to show the next word this.Close(); } } // For Ignore All Button click private void IgnoreAllButton_Click(object sender, RoutedEventArgs e) { // Clear all incorrect words IncorrectWords.Clear(); // Set the stopProcessing flag to true to signal external command to stop processing _stopProcessing = true; // Close the current spell check window this.Close(); }

 

Expected Behavior:

 

  • Clicking "Ignore" should move to the next word.
  • Clicking "Ignore All" should immediately stop the spell check process and close all windows. (Not working)

Issue:

Even after setting _stopProcessing = true, the spell check window still opens for each remaining word instead of stopping immediately.

Question:

How can I ensure that clicking "Ignore All" stops the process immediately and prevents additional spell check windows from opening?

Would love to hear any suggestions or best practices! Thanks.

Re: Corner point of two walls

$
0
0

Thanks. 🙂
What about the GetFaceMidpoint(face) method, do you have its code or is it something from Revit API?


Re: Corner point of two walls

$
0
0

Oh dear. That was part of the first answer, and I did not keep it. I'll check for you later, or you can ask Gemini yourself.

   

Re: "Ignore All" Button Not Stopping Spell Check Process in WPF

$
0
0

I asked Gemini for you, and it replies:

   

You've hit a classic WPF and threading issue combined with the modal dialog behavior. The ShowDialog() method blocks the execution of your loop, and even though you set the stopProcessing flag in the IgnoreAllButton_Clickevent, the loop only checks this flag after the dialog is closed. This is why the next window still opens. Here's a breakdown of the problem and a robust solution:

Problem:

  1. ShowDialog() Blocking:spellCheckWindow.ShowDialog() is a modal call. Your OpenSpellCheckWindowForWord method is stuck waiting for the dialog to close before it can check the stopProcessing flag.

  2. Event Handling on UI Thread: WPF events (like IgnoreAllButton_Click) are typically handled on the UI thread. While the flag is set on the UI thread, the blocking ShowDialog() call prevents the loop on the same thread from checking it.

Solution:

The core idea is to use asynchronous programming to avoid blocking the UI thread and allow the loop to respond to the stopProcessing flag change. We'll leverage Task and async/await for this:

C#
 
using System.Threading.Tasks;// In your External Commandpublicbool stopProcessing = false;publicasync Task OpenSpellCheckWindowForWord(List<string> incorrectWords)
{// Make a copy to avoid modifying the original list during iteration
    List<string> wordsToProcess = new List<string>(incorrectWords);foreach (string word in wordsToProcess)
    {if (stopProcessing)
        {break; // Exit the loop if stopProcessing is true
        }

        SpellCheckWindow spellCheckWindow = new SpellCheckWindow(word, ref stopProcessing); // Pass the word directly// Show the dialog asynchronously and get the resultbool? dialogResult = await Task.Run(() => spellCheckWindow.ShowDialog());// Check the result and the stopProcessing flag AFTER the dialog closesif (stopProcessing || dialogResult == false) // dialogResult can be null if the window is closed by the user clicking the X
        {break; // Exit the loop if Ignore All was clicked or the window was closed
        }
    }
}// In your SpellCheckWindow.xaml.cs (Code-behind)privatevoidIgnoreAllButton_Click(object sender, RoutedEventArgs e)
{
    _stopProcessing = true;this.DialogResult = true; // Set DialogResult to true so that the await in the external command will be unblocked.this.Close(); // Close the window
}privatevoidIgnoreButton_Click(object sender, RoutedEventArgs e)
{if (IncorrectWords.Any())
    {
        IncorrectWords.RemoveAt(0);
    }this.DialogResult = true; // Important to unblock the loopthis.Close();
}// Instead of bool, use a nullable bool to handle the case where the user closes the window with the X.// The result can be true, false or null.publicbool? ShowDialog();

Explanation and Key Improvements:

  1. async and await: The OpenSpellCheckWindowForWord method is now async. The await Task.Run(() => spellCheckWindow.ShowDialog()) line is crucial. It allows the code execution to "yield" while the dialog is open without blocking the UI thread. This means the UI thread remains responsive and can process the IgnoreAllButton_Click event. Crucially, the loop continues after the dialog is closed.

  2. Task.Run: The ShowDialog() is wrapped in Task.Run(). This ensures that the dialog is shown and handled on a background thread, preventing it from blocking the UI thread.

  3. Passing word Directly: The OpenSpellCheckWindowForWord method now passes the word directly to the SpellCheckWindow constructor, simplifying the code.

  4. DialogResult: Setting this.DialogResult = true; in both button click handlers is essential. This sets the result of the ShowDialog() method, unblocking the await call in your external command. If you don't set the DialogResult and the user just closes the window with the X, the result will be null. You should handle this case to avoid an exception.

  5. Nullable bool?: The ShowDialog() method returns a bool? (nullable boolean). This is important to handle the case where the user closes the dialog by clicking the 'X' instead of using the buttons. In this case, the DialogResult will be null.

  6. Checking stopProcessingafterawait: The if (stopProcessing) check now happens after the await, ensuring that the loop can immediately react to the flag change.

  7. Simplified IgnoreButton_Click: The IgnoreButton_Click now also sets the DialogResult to true and closes the window. This is important to unblock the loop and allow the next word to be displayed.

Practical Demonstration:

  1. Create a simple Revit add-in with a button that triggers the spell check.
  2. Implement the SpellCheckWindow (WPF) with the provided code.
  3. Test thoroughly. Clicking "Ignore All" should now immediately stop the spell check process.

This revised approach leverages asynchronous programming to solve the blocking issue and provides a clean and efficient way to handle the "Ignore All" functionality in your WPF spell check dialog. This is the standard pattern for handling modal dialogs in WPF applications when you need to react to events that might occur while the dialog is open.

    

LoadFamilySymbol() return false (type catalog)

$
0
0

Hi everyone,

I'm experiencing a strange issue. A specific family fails to load using the .LoadFamilySymbol() method.

However, when I load the family manually, it works without any problems.

This is a type catalog family, and other catalogs are working fine. I tried rebuilding the family, but the issue persists.

 

 

/// <summary> /// Methode hoe de family ingeladen moet worden. /// Als family gevonden wordt dan overschrijft de family de parameters. /// Als Shared family gevonden worden de subcomponenten ook overschrijven. /// </summary> [Transaction(TransactionMode.Manual)] public class FamilyLoadOptionsService : IFamilyLoadOptions { public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues) { // Als de familie al in gebruik is, beslissen we hier of we deze willen overschrijven of niet. // In dit voorbeeld zullen we de familie altijd overschrijven, zelfs als deze in gebruik is. overwriteParameterValues = true; return true; } public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues) { // Als een gedeelde familie wordt gevonden, kunnen we hier beslissen of we deze willen laden of niet. // In dit voorbeeld zullen we de gedeelde familie altijd laden, zelfs als deze al in gebruik is. source = FamilySource.Family; overwriteParameterValues = true; return true; } } // FamilyLoadOptions inladen FamilyLoadOptionsService loadOptions = new(); if (File.Exists(familyType.FamilyPath)) { bool loadSucceed = doc.LoadFamilySymbol(familyType.FamilyPath, familyType.Name, loadOptions, out FamilySymbol);

 

 

Note: The .txt file contains the "Ø" symbol. I tried removing it, but that didn’t resolve the problem.

Does anyone have any ideas?

Download link:
https://we.tl/t-bmIRcNAejM

Thanks in advance!

Re: LoadFamilySymbol() return false (type catalog)

$
0
0

Solved:

The problem was the .txt format, some how there was an unknown symbol in the txt.

Importation tableur gratuit

$
0
0

Bonjour
Je cherche une solution pour importer des tableurs type excel directement sur Revit (sans passer par autocad).
Avez-vous des solutions?
Avant c'était possible avec diroots mais c'est devenu payant depuis quelques mois...

Merci d'avance pour votre aide.

Viewing all 67020 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>