Debugging Revit Plugin

Debugging Revit Plugin

oguzkomcu
Enthusiast Enthusiast
1,411 Views
7 Replies
Message 1 of 8

Debugging Revit Plugin

oguzkomcu
Enthusiast
Enthusiast

I want to create an error in the Revit plugin, but this is a ready-made template. I want to make a revit.exe for this, but I couldn't see an option for it. How should I do this?

 

 

 

oguzkomcu_0-1658725030060.png

 

0 Likes
Accepted solutions (1)
1,412 Views
7 Replies
Replies (7)
Message 2 of 8

ricaun
Advisor
Advisor
Accepted solution

Hello,

 

I'm using this on the csproj.

  <!-- DebugRevitVersion -->
  <PropertyGroup Condition="$(Configuration.Contains('Debug'))">
    <DebugRevitVersion>$(RevitVersion)</DebugRevitVersion>
    <StartAction>Program</StartAction>
    <StartProgram>C:\Program Files\Autodesk\Revit $(DebugRevitVersion)\Revit.exe</StartProgram>
  </PropertyGroup>

 

You could set your version if you are not using a multi-version csproj.

 

Something like this for Revit 2021

  <!-- DebugRevitVersion -->
  <PropertyGroup Condition="$(Configuration.Contains('Debug'))">
    <DebugRevitVersion>2021</DebugRevitVersion>
    <StartAction>Program</StartAction>
    <StartProgram>C:\Program Files\Autodesk\Revit $(DebugRevitVersion)\Revit.exe</StartProgram>
  </PropertyGroup>

There is a condition to only add if your configuration contains the 'Debug'.

 

See yaa.

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 3 of 8

s193801T3FQ5
Participant
Participant

Hello, 

I hope it's okay that I bump this old forum post.

 

I did as @ricaun suggested, and Revit now boots up when I begin the debugging. However, no variables show up in any of the tabs in Visual Studio (i.e.  "Autos", "Locals", etc.)

 

What might be the cause of this issue? Thanks!

 

 

0 Likes
Message 4 of 8

ricaun
Advisor
Advisor

Only gonna appear variables if you add a break point in your code which makes your application and Revit to stop.

 

 I create this video yesterday with events and debug: Debug and Events 

 

See yaa

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 8

s193801T3FQ5
Participant
Participant

Hello, thanks for the reply.

 

At 06:05 in your video, the variables and logs start appearing at the bottom of your screen. However, this does not happen when I debug with the breakpoints on (see screenshot below). 

 

s193801T3FQ5_0-1666267229175.png

 

0 Likes
Message 6 of 8

ricaun
Advisor
Advisor

Probably is some configuration in your project. I suppose you started debugging with the Debug configuration.

 
This is my configuration for the debug version.
 

 

<!-- Debug -->
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
  <DebugSymbols>true</DebugSymbols>
  <OutputPath>bin\Debug\</OutputPath>
  <DefineConstants>DEBUG;TRACE;REVIT$(RevitVersion)</DefineConstants>
  <DebugType>Full</DebugType>
</PropertyGroup>

 

 
Make sure that the 'Optimize code' is disabled in the debug mode.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 7 of 8

s193801T3FQ5
Participant
Participant

I now have the following code in my .csproj:

 

	<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
		<StartAction>Program</StartAction>
		<StartProgram>C:\Program Files\Autodesk\Revit 2022\Revit.exe</StartProgram>
		<DebugSymbols>true</DebugSymbols>
		<OutputPath>bin\Debug\</OutputPath>
		<DefineConstants>DEBUG;TRACE;REVIT2022</DefineConstants>
		<DebugType>Full</DebugType>
	</PropertyGroup>

 

But it still doesn't show me the variables. Any clue as to what is not working? Thanks!

0 Likes
Message 8 of 8

ricaun
Advisor
Advisor

I still think is some configuration in the csproj, but without all the csproj is kinda hard to make sure, I know the order of the configuration matters.


I'm used to my template and never had this kinda a problem., you could use this csproj as a reference.

 

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes