2 Replies Latest reply on May 24, 2014 5:43 AM by Artem Taturevych

    c# / Inherit Properites from SolidWorks Objects

    Brian Catanzaro

      I am trying to add methods to existing objects (interfaces?) from the SolidWorks API.  For example, I want to make my own SketchPoint object called "SketchPointWriter".  This object will have a method to write its X, Y, Z, coordinates to an XML file.  It will also be able to convert its coordinates from the Sketch Coordinate system to the Model Coordinate system.

       

      I tried these two variations:

       

       

      The object SketchPointWriter has the problem that the compiler does not think that this. has the property of .X .  This doesn't make much sense to me.  When I create my own objects in C#, the can inherit methods and properties from the superclass.  These show up in the auto-complete in the list of properties and methods of this.

       

      The object SketchPointWriterWithTemp tries to recast this as a temporary SketchPoint.  By recasting it, now the compiler assumes it must have the .X property.  However, now the compiler demands that I explicitly implement all the interfaces causing me to lose all the benefits of inheritance.

       

      Is there something about the API that prevents us from inheriting properties / methods of API objects or is it my code?