Linkbutton/Invokebutton does not work - ModPlus Addin

Hello.
I created a linkbutton, but it doesn’t work and I don’t know why.
I would like to add a button from the ModPlus addin to my own toolbar.

The linkbutton is called: OpenBrowserViewsCommand.linkbutton

In this path is a bundle.yaml file with this content:
title: “Open\nviews”
author: ModPlus - Open Views
assembly: mprTools_2021.dll
command_class: OpenBrowserViewsCommand

Here is the text from the journal file:
’ 0:< API_SUCCESS { Added pushbutton Id: 6633, name: OpenBrowserViewsCommand, text: Open
'views, class: mprTools.Commands.OpenBrowserViewsCommand, assembly: C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\mprTools_2021.dll, parentId: CustomCtrl_%ModPlus%Utils }

When I click the link button I get this message.
image
What’s weird is that the .dll has a different name than the beginning of the class. The assembly is “mprTools_2021.dll” and the beginning of the class is “mprTools”. How do I get this to work?
Greets
Manuel486

try it with .invokebutton instead

1 Like

if i rename the file to .invokebutton
this is shown at the start of revit


I have not changed the content of the bundle.yaml

When I click the button I get this message:
image

is it possible you have the command class incorrect? or in the wrong spot

assembly: mprTools_2021.dll
command_class: OpenBrowserViewsCommand

Here is the text from the journal file:
’ 0:< API_SUCCESS { Added pushbutton Id: 6633, name: OpenBrowserViewsCommand, text: Open’views, class: mprTools.Commands.OpenBrowserViewsCommand, assembly: C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\ mprTools_2021.dll, parentId: CustomCtrl_%ModPlus%Utils }

Here is another example with an addin that works (its named "ElementSelector .linkbutton "):
assembly: ElementSelectorPro.dll
command_class: Selector

’ 0:< API_SUCCESS { Added pushbutton Id: 6550, name: Element Selector, text: ElementSelector, class: ElementSelectorPro.Selector, assembly: C:\ProgramData\Autodesk\ApplicationPlugins\ElementSelectorPro.bundle\Contents\ ElementSelectorPro.dll, parentId: CustomCtrl_%TwentyTwo%Free Add-Ins }

Two things I see here:
The output windows mentions it cannot find the assembly, so the dll path could be wrong.

Also, if I read your sample the same way the one that worked, i would invoke the command Commands.OpenBrowserViewsCommand

I renamed the file “pyRevit.addin” to “ZZZ_pyRevit.addin”
Now the pyRevit error is no longer displayed.

I renamed my yaml file in the invokebutton:

I still get this message:
image

this is the path where the dll file is located:

even if I specify the exact path in the yaml file it says it can’t find the target


image

I have now renamed the invokebutton to linkbutton and also have it as a
command_class: Commands.OpenBrowserViewsCommand entered.

then this message comes up:
image

I also contacted the developer of ModPlus and got this message:

I’ve considered almost every conceivable possibility now, but it just won’t work. Too bad.
I’m happy about every idea and every suggestion what I can do now.
Could it also be that it is a bug in pyRevit?

Greets
Manuel486

context: zero-doc
assembly: "C:\\ProgramData\\Autodesk\\Revit\\Addins\\2022\\DiRoots.ProSheets1.2.13.0\\diroots.prosheets.dll"
command_class:

try the full path with “” and escape characters
notice I did not invoke a command class for this one, and that was my first try
If not working and you are looking for assembly path loaded in Revit use the Find All Loaded Assemblies command under pyRevit panel, Spy

I tried it like you said, without command_class, but nothing happens when I click on my invokebutton.

If I see it correctly, there are several commands in one dll.
In the Addin ModPlus there are various tools under Utils which are summarized in the mprTools_2021.dll.
image

Part of Find All Loaded Assemblies for mprTools_2021.dll:
mprTools_2021 2.19.3.0 C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\mprTools_2021.dll
External Applications:

External Commands:
[‘mprTools.Commands.CategoryShow’, ‘mprTools.Commands.WallsShow’, ‘mprTools.Commands.WindowsShow’, ‘mprTools.Commands.DoorsShow’, ‘mprTools.Commands.TagsShow’, ‘mprTools.Commands.FloorsShow’, ‘mprTools.Commands.ColumnsShow’, ‘mprTools.Commands.GridsShow’, ‘mprTools.Commands.LevelsShow’, ‘mprTools.Commands.RampsShow’, ‘mprTools.Commands.StairsShow’, ‘mprTools.Commands.StairsRailingShow’, ‘mprTools.Commands.RoofsShow’, ‘mprTools.Commands.CeilingsShow’, ‘mprTools.Commands.ElevationsShow’, ‘mprTools.Commands.SectionsShow’, ‘mprTools.Commands.ComponentsShow’, ‘mprTools.Commands.GenericModelsShow’, ‘mprTools.Commands.ReferencePlanesShow’, ‘mprTools.Commands.StructuralFramingShow’, ‘mprTools.Commands.StructuralFoundationShow’, ‘mprTools.Commands.ReinforcementShow’, ‘mprTools.Commands.LinesShow’, ‘mprTools.Commands.MassShow’, ‘mprTools.Commands.AnalyticalShow’, ‘mprTools.Commands.DuctsShow’, ‘mprTools.Commands.FlexDuctsShow’, ‘mprTools.Commands.PipesShow’, ‘mprTools.Commands.WiresShow’, ‘mprTools.Commands.CableTraysShow’, ‘mprTools.Commands.ConduitsShow’, ‘mprTools.Commands.PointCloudsShow’, ‘mprTools.Commands.EquipmentShow’, ‘mprTools.Commands.CategoryHide’, ‘mprTools.Commands.WallsHide’, ‘mprTools.Commands.WindowsHide’, ‘mprTools.Commands.DoorsHide’, ‘mprTools.Commands.TagsHide’, ‘mprTools.Commands.FloorsHide’, ‘mprTools.Commands.ColumnsHide’, ‘mprTools.Commands.GridsHide’, ‘mprTools.Commands.LevelsHide’, ‘mprTools.Commands.RampsHide’, ‘mprTools.Commands.StairsHide’, ‘mprTools.Commands.StairsRailingHide’, ‘mprTools.Commands.RoofsHide’, ‘mprTools.Commands.CeilingsHide’, ‘mprTools.Commands.ElevationsHide’, ‘mprTools.Commands.SectionsHide’, ‘mprTools.Commands.ComponentsHide’, ‘mprTools.Commands.GenericModelsHide’, ‘mprTools.Commands.ReferencePlanesHide’, ‘mprTools.Commands.StructuralFramingHide’, ‘mprTools.Commands.StructuralFoundationHide’, ‘mprTools.Commands.ReinforcementHide’, ‘mprTools.Commands.LinesHide’, ‘mprTools.Commands.MassHide’, ‘mprTools.Commands.AnalyticalHide’, ‘mprTools.Commands.DuctsHide’, ‘mprTools.Commands.FlexDuctsHide’, ‘mprTools.Commands.PipesHide’, ‘mprTools.Commands.WiresHide’, ‘mprTools.Commands.CableTraysHide’, ‘mprTools.Commands.ConduitsHide’, ‘mprTools.Commands.PointCloudsHide’, ‘mprTools.Commands.EquipmentHide’, ‘mprTools.Commands.LinesLengthCommand’, ‘mprTools.Commands.OpenBrowserViewsCommand’, ‘mprTools.Commands.PickAnnotationsCommand’, ‘mprTools.Commands.RebarsWithoutHost’, ‘mprTools.Commands.RemoveDimZeroSegmentsCommand’, ‘mprTools.Commands.RestoreViewsCommand’, ‘mprTools.Commands.ZoomSelectionCommand’, ‘mprTools.Commands.GridsMode.GridsModeCommand’, ‘mprTools.Commands.GridsBubbles.GridsBubblesCommand’, ‘mprTools.Commands.CopingDistance.CopingDistanceCommand’, ‘mprTools.Commands.Brush.CopyGraphicOverridesCommand’, ‘mprTools.Commands.Brush.CopyTypeAndParametersCommand’]

So I thought i need to specify the command_class.
This is my current yaml file:

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: "C:\\Users\\faust\\AppData\\Roaming\\ModPlus\\Functions\\Revit\\mprTools\\mprTools_2021.dll"
command_class: Commands.OpenBrowserViewsCommand

If I click on my button now, nothing happens again. no error message and no execution of the command.

It all makes sense.

  • I would try it with/without the Commands prefix again.
  • I would also try another command as this one may not entirely be callable without an argument.
  • try it with the escape character in the path?
title: “Open\nviews”
author: ModPlus - Open Views
context: zero-doc
assembly: “C:\\Users\\faust\\AppData\\Roaming\\ModPlus\\Functions\\Revit\\mprTools\\mprTools_2021.dll”
command_class: Commands.OpenBrowserViewsCommand

I tried this:

command_class: mprTools.Commands.OpenBrowserViewsCommand

that

command_class: Commands.OpenBrowserViewsCommand

and that

command_class: OpenBrowserViewsCommand

Nothing happends again.

can you explain: " * try it with the escape character in the path?"
the german translation doesn’t make any sense to me and in english i don’t know what you mean.
Do you mean instead of 2x\ 1x?

Yes that is it. I would not be good at explaining the ground reason as of to why, but it is pretty common to use the \ to ‘escape’ a forbidden character in a filepath.
I will give it a try at explaining without Google or chatgpt :grin:

'' being itself a reserved character, you need to escape it’s interpretation by telling python the character after this one should not be interpreted

I have now tested it with another tool from ModPlus in an invoke button.
This is the yaml file:

title: "Find and\nReplace"
author: ModPlus - Find and Replace
context: zero-doc
assembly: "C:\\Users\\faust\\AppData\\Roaming\\ModPlus\\Functions\\Revit\\mprFindAndReplace\\mprFindAndReplace_2021.dll"
command_class:

This is from Loaded Assemblies search:
mprFindAndReplace_2021 2.0.0.0 C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprFindAndReplace\mprFindAndReplace_2021.dll
External Applications:

External Commands:
[‘mprFindAndReplace.Command’]

Now he opens the ModPlus Tool with the invokebutton:

But if I now go to this command in the ModPlus addin, this message comes up:
image

That worked.
Here is the code that works:

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: "C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\mprTools_2021.dll"
command_class: OpenBrowserViewsCommand

Many thanks for your commitment.
It is not a matter of course for me that someone takes so much time to help others free of charge.

Greets

1 Like

It still worked this morning. After restarting Revit I get this message. It is to despair.

the error mentions it cannot process the " character, which is weird in itself.
Try this one and restart revit every time you try

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: "C:\\Users\\faust\\AppData\\Roaming\\ModPlus\\Functions\\Revit\\mprTools\\mprTools_2021.dll"
command_class: OpenBrowserViewsCommand

and that one

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\mprTools_2021.dll
command_class: OpenBrowserViewsCommand

If i paste this in my yaml:

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: C:\Users\faust\AppData\Roaming\ModPlus\Functions\Revit\mprTools\mprTools_2021.dll
command_class: OpenBrowserViewsCommand

There is no error.
But my button looks like this and i get this messsage after executing.

Actually, “Open View” should be there.

This is the structure for my panel:


The other buttons are all displayed correctly. Just not the invokebutton.

The same thing happens if i use this code:

title: "Open\nviews"
author: ModPlus - Open Views
context: zero-doc
assembly: "C:\\Users\\faust\\AppData\\Roaming\\ModPlus\\Functions\\Revit\\mprTools\\mprTools_2021.dll"
command_class: OpenBrowserViewsCommand

I’ve tested a lot back and forth now.
I think it’s a pyRevit thing going wrong.
Maybe one of the developers will test what goes wrong in the invokebutton with ModPlus.
Unfortunately I can’t reproduce why it worked this morning and two hours later it didn’t.
Maybe @eirannejad can help in this case?!
Greets

a regular pushbutton with script.py code as follow:

from pyrevit import revit, UI
doc = revit.doc
Command_ID = UI.RevitCommandId.LookupCommandId('CustomCtrl_%CustomCtrl_%ModPlus%Utils%OpenBrowserViewsCommand')
UI.UIApplication(doc.Application).PostCommand(Command_ID)

have a nice weekend @Manuel486 !

You are the man.
Unfortunately, this path takes about 10x longer to load.
Have a nice weekend too.