Coder Social home page Coder Social logo

mitevpi / revit-wpf-template Goto Github PK

View Code? Open in Web Editor NEW
160.0 160.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%
addin autodesk boilerplate dotnet dotnet-framework revit revit-wpf-template template visual-studio wpf

revit-wpf-template's Issues

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.

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!

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?"

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

problem microsoft

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

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

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?

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

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.