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?
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.
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.