Giter Site home page Giter Site logo

simplerevit's Introduction

Simple Revit

A toolkit for simplifying your Revit plugin development.

Installation

  1. Install Revit Templates.

  2. Add this as a submodule to your project:

    git submodule add https://github.com/ArchiDog1998/SimpleRevit
  3. Add it to your plugin's CSProj file:

    <ItemGroup>
    	<ProjectReference Include="..\SimpleRevit\SimpleRevit\SimpleRevit.csproj"/>
    </ItemGroup>

Features

Here is an example of this repo.

External command

All these commands are inherited from ExternalCommand. So for further usage, please check this wiki.

CmdBase

CmdBase contains some definitions of Revit.Async. If you want to use it, please set UseRevitAsync to true.

using Autodesk.Revit.Attributes;
using SimpleRevit;

[Cmd(Name = "Easy One")]
[Cmd(Panel = "Commands")]
[Transaction(TransactionMode.Manual)]
public class CommandEasy : CmdBase
{
    protected override bool UseRevitAsync => false;

    public override void ExecuteMain()
    {
    }
}

If your UseRevitAsync is true, please make all your writing stuff to RevitTask.RunAsync.

CmdBaseMvvm<TView, TViewModel>****

CmdBaseMvvm is an mvvm-ready command class. The View it created will not be irresponsible while the command is running. Please don't forget to define your view and your view model.

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Serilog;
using SimpleRevit;
using Tests.ViewModels;
using Tests.Views;

[Cmd(Name = "Normal One")]
[Cmd(Image = "Resources/Icons/RibbonIcon16.png")]
[Cmd(LargeImage = "Resources/Icons/RibbonIcon32.png")]
[Cmd(Panel = "Commands")]
[Transaction(TransactionMode.Manual)]
public class CommandNormal : CmdBaseMvvm<TestsView, TestsViewModel>
{
    protected override bool UseRevitAsync => false;

    public override void ExecuteMain()
    {
        using var trans = new Transaction(Document);
        trans.Start("Test");
        foreach (var wall in Document.GetInstances(BuiltInCategory.OST_Walls))
        {
            var param = wall.GetParameter(BuiltInParameter.WALL_BASE_OFFSET);
            param.Set(0.2);
            UpdatePercent(100);

            Task.Delay(1000).Wait();
            Log.Debug("Succeed!");
        }

        trans.Commit();
    }
}

External application

All these commands are inherited from ExternalApplication. So for further usage, please check this wiki.

AppBase

Almost everything is down here, don't forget to create one application that is inherited from this.

Attributes

There are two attributes for you to create the ribbon ui easily.

The Cmd attribute is designed for ui showing in the ribbon panel. And the Priority attribute is designed for changing the order of the loading button in the ribbon panel.

Extensions

There are also some extensions for parameter writing and creating. Try them by yourself!

simplerevit's People

Contributors

archidog1998 avatar

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.