Wrapping revit elements to dynamo elements

I am trying to create an add-in that user selects elements and I want to convert them to dynamo elements.
I tried to use wrap method but I have this error which I have no idea of what to do

i think i need to intialize this first

i think this what causes the issue

Its most likely an exception thrown because Dynamo hasn’t been initialized. Try launching Dynamo then run your app and it will most likely work…which is why making a Revit add-in which references Dynamo’s libraries and object model is just a bad idea.

You’ve just found out one of the reasons why (your users will have to launch Dynamo first or you will have to use the Dynamo API to launch Dynamo which brings with it other problems) and there are many others problems beyond this too. To cut a long story short, there’s no reason to integrate Dynamo’s element wrapper in your app, just use the Revit API and save yourself a headache.

1 Like

i wanted to use some algorithm in dynamo which is ultra-efficient and it can not be converted to Revit API as i don’t own it so i have to use it as 3rd party. all that i need is to give it the proper data and it will do the rest.

i was trying to get smart on this one and I had this workaround
DocumentManager.Instance.CurrentUIDocument =uiDoc;

and it works for now !

the only new issue is that it opens a transaction without closing it !!

so even if I didn’t open the transaction, an error message will appear to the user :frowning: