Creating a link between Dynamo input and pyRevit

Hi all,

I am aware there was a previous topic (called Dyanmo “is input” through pyRevit) on converting Dynamo inputs into pyRevit. However my dynamo code has 2 inputs, one is select the element you want to rotate and the other is the number of deg to rotate.

Is this possible?
And if it is how would it work?

Thank you for your help in advance

Cam

Hello @Wilko1306

Select your elements before running the script and use this function to get the elements:

    def get_current_selection():
        sel_ids = uidoc.Selection.GetElementIds()
        return [doc.GetElement(id) for id in sel_ids]

On my opinion the faster and more user friendly approach.

If elements are selected just run a datashapes userinterface for your rotation input.
But maybe someone has a better idea?..

IMHO data-shapes, while being if great help to design UI in dynamo, it is largely overkill in the pyrevit context

That being said

For the selection, @Gerhard.P option is a good one, it all depends on the UX you are trying to provide.
You could also use this
pick_element_by_category(cat_name_or_builtin, message=‘’)

For the rotation:
https://pyrevit.readthedocs.io/en/latest/pyrevit/forms.html#pyrevit.forms.ask_for_number_slider

So you can use pyRevit libraries in a dynamo script?
How?

Does not work for me, nothing happens.

No, you can’t,
But what you can do is ‘translate’ it. What I mean by that is that you can reuse bits and pieces of code from one to reuse in the other.
Replacing the frameworks specific items like the IN and OUT variable from dynamo, or the dynamoDS bits

Hi @Gerhard.P

That was exactly my plan, to get the user to select the elements first and then somehow have an input through either pyrevit itself or a datashapes node

Please excuse me if this is a stupid question but i am fairly fresh to all this but how exactly would i use that code? I assume i would put into a python node inside of the dynamo script? if so i have tried with the following code however do not appear to be having any luck
image

OK so you just suggested to not use dynamo at all @Jean-Marc .
That leads us to the question why do you want to use a dynamo script and not a pyRevit script @Wilko1306 ?

Oh sorry, you have to first define uidoc to use the function:

uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

I am very fresh to the scene of coding and pyrevit. I have various existing dynamo script that works and i am trying to integrate them into pyRevit and that is why i currently am working with a dynamo script rather than python

In this specific case i am trying to make it possible to take any number of columns (that are selected) and rotate them around there centroid as currently you would have to do that individually for each column using the normal rotate command

Ok, so if this is ‘just’ a dynamo script that you want to run behind a pushbutton, then:

Any question regarding data-shapes usage is better suited for the dynamo forum