Error in Dynamo Add-In for Revit 2022

Error in Dynamo Add-In for Revit 2022

elango_saramani
Explorer Explorer
706 Views
4 Replies
Message 1 of 5

Error in Dynamo Add-In for Revit 2022

elango_saramani
Explorer
Explorer

Hello,

I’m developing a Dynamo add-in for Revit 2022 and encountering errors on specific lines in my code. Here’s what I have:

Error Messages:

  • Line 20: [PushButton button = panel.AddPushButton("Run Dynamo", "RunDynamo", Assembly.GetExecutingAssembly().Location, "MyDynamoAddIn.RunDynamoCommand");]
  • Line 39: [var dynamoController = DynamoController.Instance;]
  • I’ve checked that:

    • The correct Revit and Dynamo API references are included.
    • Dynamo is installed properly.

    Can anyone help me figure out what might be going wrong? Thank you!

 

 

using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Dynamo.Applications;
using Dynamo.Services;
using System;
using System.Reflection;
using Dynamo.Graph.Workspaces;
using System.Linq;

namespace MyDynamoAddIn
{
public class MyAddIn : IExternalApplication
{
public Result OnStartup(UIControlledApplication application)
{
RibbonPanel panel = application.CreateRibbonPanel("My Dynamo Panel");
PushButton button = panel.AddPushButton("Run Dynamo", "RunDynamo", Assembly.GetExecutingAssembly().Location, "MyDynamoAddIn.RunDynamoCommand");
return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
}

public class RunDynamoCommand : IExternalCommand
{
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
string dynamoFilePath = @"C:\Path\To\Your\DynamoScript.dyn"; // Update with your path

// Start Dynamo and open the script
var dynamoController = DynamoController.Instance;
dynamoController.Open(dynamoFilePath);

return Result.Succeeded;
}
}
}

0 Likes
707 Views
4 Replies
Replies (4)
Message 2 of 5

moturi.magati.george
Autodesk
Autodesk

Hi @elango_saramani 

Kindly try asking the question on the Dynamo forum. There are more knowledgeable dynamo developers on the platform than here.

https://forum.dynamobim.com/

 

  Moturi George,     Developer Advocacy and Support,  ADN Open
0 Likes
Message 3 of 5

j0hnp
Advocate
Advocate

I have a thorough sample for using Dynamo graphs within a C# Revit plugin here:
https://github.com/johnpierson/Relay/blob/master/src/Methods/DynamoMethods.cs

 

Compare your methods to that, and I bet you can get it sorted.

john.pierson

expert elite / design technologist / dynamo package creator

designtechunraveled.com



0 Likes
Message 4 of 5

elango_saramani
Explorer
Explorer
Hi 

Thank you for your Reply. I have attached the image below. Could you kindly advise me on this?

elango_saramani_0-1728480062512.png

 

 

0 Likes
Message 5 of 5

Mohamed_Arshad
Advisor
Advisor

Hi @elango_saramani 

 

Have you check the below link?

Re: Dynamo script in Revit API - Page 2 - Autodesk Community  


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes