0

I want to create a class and have it inherit from the Autodesk.Revit.DB.Element class

public class MyElement : Autodesk.Revit.DB.Element 
{
  //...
}

But when I compile the code I get the following error

The type Autodesk.Revit.DB.Element has no constructors defined.

skeletank
  • 2,880
  • 5
  • 43
  • 75
user3451925
  • 33
  • 2
  • 6

2 Answers2

4

The Element class is having an internal constructor. You cannot inherit from a class with internal ctor in another assembly. See the answer here

Community
  • 1
  • 1
alital
  • 411
  • 5
  • 15
1

You can't really do that. But you can use extension methods to define new methods on the Element class - I have had some good results with this in the Revit context. See my blog post here: http://darenatwork.blogspot.ch/2009/12/using-c-extension-methods-to-extend.html

You can't really add any fields to the Element class like this, but you can use properties that save to either the new storage feature or the older parameters feature of Revit Elements, so if all you want to do is make an Element have some nicer interface, this is a way to do it.

Daren Thomas
  • 67,947
  • 40
  • 154
  • 200