Coder Social home page Coder Social logo

mitevpi / revit-wpf-template Goto Github PK

View Code? Open in Web Editor NEW
159.0 16.0 43.0 3.31 MB

Template for a Revit add-in using WPF and executing valid external commands within the Revit API context.

Home Page: https://revit-wpf-template-docs.now.sh

License: MIT License

C# 100.00%
revit autodesk wpf template boilerplate revit-wpf-template visual-studio dotnet dotnet-framework addin

revit-wpf-template's Introduction

Revit WPF Template

GitHub issues GitHub pull requests GitHub contributors

GitHub last commit GitHub Release Date GitHub All Releases

GitHub code size in bytes GitHub repo size GitHub

WPF Template for Revit Add-Ins including wrapped external methods for execution in a "Valid Revit API Context"

Window A Window B Window C Revit Ribbon

Usage

Build

  1. Clone/download this repository and open the .sln at the root of the repository with Microsoft Visual Studio.
  2. Re-link references to RevitAPI.dll and others which may be missing.
  3. Build the solution - Building the solution will automatically create and copy the add-in files to the folder for Revit 2019.
  4. Open Revit - Upon opening Revit 2019, there should be a tab called "Template" in Revit, with a button to launch the WPF add-in.

Customize

In order to use this as a starter for your application, make sure you first refactor the content in the application files (namespace, assembly name, classes, GUID, etc.) and remove the assets folder in this repository.

A guide to refactoring can be found in the docs folder.

Documentation

Documentation is created using Sandcastle Help File Builder by compiling the docstrings from the compiled .dll and .xml files generated by Visual Studio upon build. The Sandcastle project can be launched through the RevitTemplate.shfbproj file in the docs folder.

The documentation can be found in the docs folder in the root of this repository. The following documentation sources are created by Sandcastle Help File Builder:

  1. .chm - This is an interactive help file which can be launched by double-clicking on any Windows machine.
  2. index.html - This is the documentation compiled for web deployment. Please note that many of the supporting files needed to deploy the documentation to the web have been git-ignored due to their size and count. Make sure to compile documentation yourself using Sandcastle Help File Builder prior to trying to use/deploy the web version of the documentation. A preview of what this looks like can be found here.

revit-wpf-template's People

Contributors

mitevpi avatar sridharbaldava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revit-wpf-template's Issues

Enhancement: External Method Buttons

This enhancement allows user to click on different buttons to post different external methods. In my personal opinion buttons are more intuitive to use than checkbox + single button. I totally understand the current setup is for demo purpose and it's useful. This enhancement is to provide users with an additional way to post external methods.

image

I've added 3 buttons in the "Export" tab

                <Button x:Name="BExternalMethodProject" BorderBrush="#FFABADB3" Background="{x:Null}" Padding="5,0,5,0"
                        Click="BExternalMethodProject_Click" HorizontalAlignment="Left" Width="183" Height="26"
                        VerticalAlignment="Top" Margin="11,40,0,0" Grid.ColumnSpan="2" Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Project" Margin="5,0,0,0" />
                    </StackPanel>
                </Button>
                
                <Button x:Name="BExternalMethodWalls" BorderBrush="#FFABADB3" Background="{x:Null}" Padding="5,0,5,0"
                        Click="BExternalMethodWalls_Click" HorizontalAlignment="Left" Width="183" Height="26"
                        VerticalAlignment="Center" Margin="11,40,0,0" Grid.ColumnSpan="2" Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Walls" Margin="5,0,0,0" />
                    </StackPanel>
                </Button>
                <Button x:Name="BExternalMethodSheet" BorderBrush="#FFABADB3" Background="{x:Null}" Padding="5,0,5,0"
                        Click="BExternalMethodSheet_Click" HorizontalAlignment="Left" Width="183" Height="26"
                        VerticalAlignment="Bottom" Margin="11,40,0,0" Grid.ColumnSpan="2" Grid.Row="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Sheet" Margin="5,0,0,0" />
                    </StackPanel>
                </Button>

Then I've utilized the "IsMouseOver" property in the MethodsWrapper class to identify which button is clicked. (Open for suggestions and better ideas)

        if (ui.BExternalMethodProject.IsMouseOver)
        {
            Methods.DocumentInfo(ui, doc);
        }

        if (ui.BExternalMethodWalls.IsMouseOver)
        {
            Methods.WallInfo(ui, doc);
        }

        if (ui.BExternalMethodSheet.IsMouseOver)
        {
            Methods.SheetRename(ui, doc);
        }

Happy to create a pull request if you find this enhancement useful.

Thanks very much for sharing your template and make it open source!

Enhancement : Set parent to Revit

This keeps the window ontop of Revit when it is opened, minimises it with Revit and additionally stops the window showing on the task bar.

Test code originally from here https://stackoverflow.com/questions/55339082/is-this-a-way-to-show-a-modeless-dialog-from-a-dockable-pane-using-wpf (I'm sure you will improve it!)

public void ShowForm(UIApplication uiapp)
        {
            // If we do not have a dialog yet, create and show it
            if (_mMyForm != null && _mMyForm == null) return;
            //EXTERNAL EVENTS WITH ARGUMENTS
            EventHandlerWithStringArg evStr = new EventHandlerWithStringArg();
            EventHandlerWithWpfArg evWpf = new EventHandlerWithWpfArg();

            _mMyForm = new Ui(uiapp, evStr, evWpf);

            HwndSource hwndSource = HwndSource.FromHwnd(uiapp.MainWindowHandle);
            System.Windows.Window wnd = hwndSource.RootVisual as System.Windows.Window;
            if (wnd != null)
            {
                _mMyForm.Owner = wnd;
                _mMyForm.ShowInTaskbar = false;
                _mMyForm.Show();
            }
        }

Cheers,

Mark

Window Dock(Snap) to Revit UI

All the applications I build using this template do not dock into the Revit UI in the same way that other Revit panels do. Is it possible for an External Application using this template to snap into the Revit UI?

I haven't spent too much time looking into the IExternalApplication interface. Maybe it is just a simple limitation of being an External Application.

Revit EventHandlers

@mitevpi ,
In the context of this WPF template, where should Revit EventHandlers be placed?
For example, I am trying to use the Application.DocumentChanged event. Where should this be in order to be in the "Valid Revit API Context?"

Transactions Impossible?

I am writing new methods in the Methods.cs class. Everything works fine until I try to use a transaction to make a change to the active document. I can't get transactions to work at all. Are transactions not possible from a plugin?

App.InitializeComponent()

How come you don't initialize the App class?
App app = new App(); app.InitializeComponent(); app.Run();

Without doing this, its not possible to use Dispatcher

What version do we need to target?

First of all, thank you so much for creating this template!

Is this for .NET Framework 4.7? 4.5? .NET Core? (jk) I can't get the Microsoft.Dynamic or the Microsoft.Scripting libraries out of the box.

Googling led me here:
https://stackoverflow.com/questions/1681005/how-to-use-microsoft-scripting-hosting
which pointed me at
https://www.nuget.org/packages/DynamicLanguageRuntime.Net40.Unofficial

So I installed that but then I couldn't Reference Microsoft.Scripting.Metadata.
Couldn't find AdWindows either.

Will you please provide the target framework and whatever NuGet packages to install in the README? That would help me a lot.

Thanks!

//Ana

problem microsoft

When I clone your project I have a problem with a microsoft.scripting.metadata parser. You know the solution.I would appreciate.

Returning Data from Revit Model

I'm trying to retrieve information from the Revit Model, and display it in my plugin's UI.

However, the IExternalEventHandler only has one overload for Execute, which returns a void. So all of my methods that are wrapped in the ExternalEventHandler can not return anything.

This WPF Template clearly demonstrates how to modify a Revit Model, but is there a way to return information about the model?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.