Using dynamo elementselector method at revit develop

i use the revitnodes.dll at revit develop,When I pick a object from revit application,and obtain the elementid

Here is the code screenshot:

but the VS Throw an exception: “Could not obtain element from the current document! The id may not be valid.”

the elementid is a real id, why this should suffice?

no body used the revitnodes.dll ?

@tmac33 Is this what your looking for?

hello,kuikui

I refer revitnodes.dll to my project,and i use the method from revitnodes.dll build is ok,but when i Use my own command
at revit application,then revit throw an exception: “Could not obtain element from the current document! The id may not be valid.”

i look for the all dynamo’s source code,There’s nothing wrong with that document。and the id exactly is right,
so i considered whether the current doc is the same,between revit application anddynamo?

Could you show us your complete code?

This command will done in revit!

@Kulkul have some Solutions?

Hi @tmac33 What are you attempting to achieve? The ElementSelector class selects elements from a Revit project and returns a wrapped Element from the Revit.Elements.Element class (Dynamo-owned library). If all you need is the wrapped element, call the ToDSType() method on e.

@Thomas_Mahon
the wrong is i CAN’T USING ElementSelector class,in revit project,

when i build it,is ok,

but when i use it at revit application throw a exception

could you show me your source code??

@Kulkul
@Thomas_Mahon

my question is why i use the elementselector class,i must open the dy application,

would i just open revit to use the .dll file?

My question would be…why? Why are you using a utility method from a Dynamo application for an External Command in Revit. Revit API already has sufficient API calls that select model elements, namely doc.getElement(). You are getting exceptions because ElementSelector class relies on things like DocumentManager to retrieve the appropriate Document from the model. Again, you are inside of the External Command and you have a valid document there to use. Just use it.

If you don’t tell us all, what you are trying to do, and why, we won’t be able to help. What we are all doing now, is guess.

@Konrad_K_Sobon
I just want to test to call the DY .dll file at revit project.

and now my question is

Whether to use dy method at revit project, i must open the dy application?