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

Re: Switch focus to active view

$
0
0

Hi Jeremy,


Thank you for the reply. When I change the activeview the dockable panel that I created disappears and I have to reactivate it through ribbon. What am I doing wrong? 

 

The way I am changing view is, I first stored current view then switched to 3D view and switched back to original view.

 

Mangesh


Re: SpectrumBIM Gamut crashes Revit

Re: Program transfer from AutoCAD to Revit

$
0
0

You may be able to do refactoring of your original code to insert some abstraction layers for some parts and reimplement the interfaces for Revit. But in the end, most of the Revit API is completely different, and Revit is totally different as well. I have no idea what type of applications you like to port, but my guess is that most tools would be obsolete or otherwise useless anyway, since things are done differently in Revit.

Re: SpectrumBIM Gamut crashes Revit

$
0
0

"Ensure that you use the version of the DLL that has been loaded, if one already has. Otherwise, do as you please."

 

How can we possibly know what versions of many general purpose .NET libraries such as Google's Grpc are the other 100+ add-ons using? How can they know what version we are using?

 

I do not understand?

 

So I have to make sure I force-load my version of the .NET assembly as soon as possible as my add-on is loaded and if I have some luck my add-on to be loaded first, I will be the first one that does so and all other Revit add-ons, which use a different version of the same library should do as they please and maybe crash.

 

These are not .NET libraries used by Revit. These are general purpose .NET assemblies, i.e. Google Grpc, Log4net, etc. they can be hundreds.

 

Are the add-ons loaded in alphabetical order?

 

And what has CefSharp has got to do with this issue? We have two different add-ons and the one crashes because of the other. One is developed by us and the other one NOT by us. How does CefSharp  even come in play?

 

Should add-on developers communicate with each other and agree to use the same version of everything?

 

 

Re: SpectrumBIM Gamut crashes Revit

$
0
0

"Maybe splitting the conflicting add-ins into separate executables and using inter-process communication to let them cooperate will enable you to solve the problem?"

 

One is developed by Company A, the other by Company B. 

 

On these forums, no one is reading what is going on. We are simply provided with links to some existing posts which have almost nothing to do with the question in hand...

Re: Revit crashes when exiting add-in WPF application

$
0
0

I have managed to run WPF from Revit this way:

see this very minimal example.

see GIT here

WPFWindow.gif

basically you need to be aware of MVVM (Model View - View Model) structure, as this is the layer that communicates between the Interface (WPF Window) and the Revit works running on the back.

 

so this is what the sample does:

  • Create Revit Command Layer
    • Create a WPF Window
      • Create a Communication Layer( ModelView)
        • Register your Commands Action (used for binding Buttons"Controls" to the model View)
        • Register External Events, and Documents
    • Show WPF Window
    • Close Command (Return Result.Succeeded).

Now, as you have a button on a WPF thread that is connected to MVVM Layer,

  1. WPF will run smoothly in terms of Interface, and separated from Revit
  2. since you register External Events to the MV, then signals sent from the Button from the WPF interface to the MV layer, that will triggering the action.

However, there are some limitation to this:

for example, if you are running a very long process... the WPF window will be blocked till revit Finish its running works, hence, running a Progress bar on WPF doesn't work this way. Progress bar must be registered to a window that is running on a separate Thread from Revit.  Thread.Start(...) and ofcourse should be STAThread

 

I hope the above gives you some light on how this works.

 

Re: Program transfer from AutoCAD to Revit

$
0
0

Yes, thats what I am thinking now. The programs that we were using cannot be used in there current form.

What Programming Language ?

$
0
0

Hi

 

I just finished a Python Workshop. I haven been seeing options like Dynamo, PyRevit and Revit Python Shell. In order to create my own Routines and eventually my own Add ins? What Programming Language would be the Best? What does the Macro function in Revit? Can I create also Automatic Tasks with any Programming Language there ? 

I will really appreciate an Answer since I want to define my Path

 

Thanks in Advance


Re: SpectrumBIM Gamut crashes Revit

$
0
0

Dear Rossen,

 

I read your description carefully and understand the problem.

 

I am sorry that I cannot help.

 

Sorry I mentioned the other aspects, that are of no use at all in your situation, just as you correctly point out.

 

Re: Support for .net framework or .net core for building Revit plugin / ribbion.

$
0
0

Hi :

.NET implementation support

The following table lists the minimum platform versions that support each .NET Standard version. That means that later versions of a listed platform also support the corresponding .NET Standard version. For example, .NET Core 2.2 supports .NET Standard 2.0 and earlier.

.NET Standard           1.0    1.1      1.2     1.3     1.4      1.5         1.6       2.0         2.1
.NET Core1.01.01.01.01.01.01.02.03.0
.NET Framework 14.54.54.5.14.64.6.14.6.1 24.6.1 24.6.1 2N/A3

 

I think the target .NET Standard version should be:

2016: 1.0, 1.1

2017: 1.3

2018: 1.3

2019: 2.1 or later? (I'm not sure about this version, Cuz Miscrosoft has not yet determined it)

2020: 2.1 or later?

 

Besides:

If you want to build a Revit addin into .NET Standard, as well as to include some WPF solution, things will get much more complicated.

In our solution, we manually edited our .props file, which describes the solution and project. It's a new way that Microsoft supplies, for their new .NET Core & .NET Standard VS solutions.

You might need to read lots of MSBuild documents if you want to manually edit the .props files.

https://docs.microsoft.com/zh-cn/visualstudio/msbuild/msbuild?view=vs-2017 

 

Considering that you were asking about .NET Core questions, so I suppose that you must have known well about the new <Project> .props file 🙂

 

Re: Worksharing Monitor for Revit 2019

$
0
0

Is this a Revit API issue, or an end user question?

 

Are you doing anything programmatically yourself, or just using the standard Revit user interface?

 

If you are not doing anything programmatically, this is not the best place to ask such a question.

 

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

 

Therefore, you cannot expect an answer to a question such as yours relating to installation, product usage or end user support issues here.

 

You should try one of the non-API Revit product support discussion forums instead for that:

 

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

 

The people there are much better equipped to answer your question than us programming nerds.

 

I hope this clarifies.

 

Thank you for your cooperation and understanding.

 

Best regards,

 

Jeremy

 

Re: Parameter Bindings

$
0
0

Hello Jeremy,

 

thx for the link I was aware of this, and I was trying to adapt the code provided. The parameter I want to bind to the new category (wall) is part of the project and currently only bound to rooms. I simply want to assign a new category to an existing binding. 
The provided code works well with parameters I insert via the api as shared parameters but it always fails when I want to update the categories of parameters that where added manually via the UI.

Re: Parameter Bindings

$
0
0

I thought this kind of binding of parameters to categories only works for shared parameters anyway.

 

Can you achieve the desired result manually in the user interface?

 

If not, you probably cannot do it in the API either.

 

If yes, then the code provided should achieve exactly that.

 

Re: Revit crashes when exiting add-in WPF application

$
0
0

Hey,
thank you for your tutorial suggestions. I will certainly have a look at it.
Currently I am not using xaml generated controls, but I am considering it. That's why I currently don't have a reference to Windows.xaml.

Re: Worksharing Monitor for Revit 2019

$
0
0

Hi Jeremy - U are probaly right :)! I'm sorry, but I was submitting in a hurry and the menu "slipped" and selected the wrong Forum before Posting.

Have a nice day!


Re: Revit crashes when exiting add-in WPF application

$
0
0

Thank you for your example very much aswell, Moustafa Khalil! It gives a very nice and compact insight on Revit WPF structure.

Re: Revit crashes when exiting add-in WPF application

$
0
0

Now to give this thread an answer:


The basic problem I see through all the examples, lies in creating a new Application to Run() the window like:
var application = new Application();

var window = new MyWindow();
int returnCode = application.Run(window);

 

Instead Revit seems to bring its own application with it so you can just open your windows without creating a new Application like:
var window = new MyWindow();
window.Show();

 

I hope I will be able to troubleshoot my other problems aswell, but these don't contribute to the original question of this thread. I thank everybody who gave me hints and tipps.

Re: SpectrumBIM Gamut crashes Revit

$
0
0

I found the SpectrumBIM Gamut Code that crashes Revit:

 

private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            string directoryName = Path.GetDirectoryName(typeof(GamutApp).Assembly.Location);
            string str = string.Concat(args.Name.Substring(0, args.Name.IndexOf(",", StringComparison.Ordinal)), ".dll");
            string str1 = Path.Combine(directoryName, str);
            if (!File.Exists(str1))
            {
                return null;
            }
            return Assembly.LoadFrom(str1);
        }

The call to Substring causes System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length

 

I contacted them SpectrumBIM. Unfortunately no one responds yet.

Re: What Programming Language ?

$
0
0

Re: Element Selection Changed Event - Implementation Struggles

$
0
0

there is a 4th workaround.

Every time  the selection changes, a button has the option to check if it should be enabled via the  AvailabilityClassName property. The downside of this mechanisme is, that the button needs to visible. This can easily be accomplished by adding the button to the QuickAccessToolBar.

 

Define the button in the OnStartup method

public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
{
    application.CreateRibbonTab("FAIR");
    RibbonPanel m_ribbonPanel = application.CreateRibbonPanel("FAIR", "ModifyPanel");
    string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
    PushButtonData buttonData = new PushButtonData("cmd_Dummy",
               string.Format("X"), thisAssemblyPath, "FAIR_Space.cmd_Dummy");
    buttonData.AvailabilityClassName = "FAIR_Space.CommandEnabler";
    m_ribbonPanel.AddItem(buttonData);

    application.ControlledApplication.ApplicationInitialized+=ControlledApplication_ApplicationInitialized;
    return Result.Succeeded;
}

with the CommandExecute-method and AvailabilityClass

    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmd_Dummy : IExternalCommand
{
    public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
     ref string message, ElementSet elements)
    {
        return Result.Succeeded;
    }
}
public class CommandEnabler : IExternalCommandAvailability
{
    public bool IsCommandAvailable(UIApplication uiApp, CategorySet catSet)
    {
        UIDocument uidoc = uiApp.ActiveUIDocument;
        if (uidoc == null) return false;

        Autodesk.Revit.UI.Selection.Selection sel = uidoc.Selection;
        // Raise the SelectionChangedEvent
        return false; // disable button
    }
}

In the ControlledApplication_ApplicationInitialized-method move the button to the QuickAccessToolBar.

       void ControlledApplication_ApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
       {
           adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
           adWin.RibbonTab FAIRTab = null;
           adWin.RibbonPanel MyPanel = null;
           adWin.RibbonItem MyButton = null;
           // find MyPanel and MyButton
           foreach (var tab in ribbon.Tabs)
           {
               if (tab.Id == "FAIR")
               {
                   FAIRTab = tab;
                   foreach (var panel in tab.Panels)
                   {
                       if (panel.Source.Title == "ModifyPanel")
                       {
                           MyPanel = panel;
                           foreach (var item in panel.Source.Items)
                           {
                               if (item.Id == "CustomCtrl_%CustomCtrl_%FAIR%ModifyPanel%cmd_Dummy")
                               {
                                   MyButton = item;
                                   break;
                               }
                           }
                       }
                   }
                   break;
               }
           }
           if (MyPanel != null && MyButton != null && FAIRTab != null )
           {
               // find a "nice"position for the button
               int position = 0;
               foreach (var item in adWin.ComponentManager.QuickAccessToolBar.Items)
               {
                   if (string.IsNullOrWhiteSpace(item.Id)) continue;
                   position++;
                   if (item.Id == "ID_REVIT_FILE_PRINT") break;
               }
               // place button on QuickAccessToolBar
               if (position < adWin.ComponentManager.QuickAccessToolBar.Items.Count)
               {
                   adWin.ComponentManager.QuickAccessToolBar.InsertStandardItem(position, MyButton);
               }
               else adWin.ComponentManager.QuickAccessToolBar.AddStandardItem(MyButton);

               // remove button from MyPanel and hide tab if no panels 
               FAIRTab.Panels.Remove(MyPanel);
               if (FAIRTab.Panels.Count == 0) FAIRTab.IsVisible = false;
           }
       }
Viewing all 66719 articles
Browse latest View live