AssembyDocClass inheritance

Hi. i,'m workig with solidworks 2006 api. I have builded a dll library for my application that use solidworks api procedurally (using c# language)... Now i want to rewrite this library using the object paradigm. First i have wrote a class XXX that inherits AssembyDocClass. Well... but how can I instantiate my XXX class?

If i need to instantiate an AssembyDoc procedurally i can use:

SldWorks.SldWorks sw = new SldWorks.SldWorks(); AssemblyDoc ad = sw.NewAssembly()

But how can i instantiate the XXX base class AssemblyDocClass?

internal class XXX : AssemblyDocClass { public XXX () : base()

Reply to
e7r3m
Loading thread data ...

You just cannot. If the base class does not have a public constructor, there is no sense at all in inheriting a such class. If SW should use your inherited class instead of it's own, how could _it_ know to instantiate the inherited class? It would require some kind of factory pattern or callback function.

If a class does not have a public constructor, it is most propably intentional. It may even be - and I believe so - that the AssemblyDoc class is just an interface or proxy class, and the very internals of SolidWorks are much more complicated.

To solve the problem, write a wrapper class instead of inherited one.

-h-

Reply to
Heikki Leivo

Thank you for answering. Effectively the AssemblyDocClass object that i'm getting is an object that .NET interop has generated based on the interfaces in the sldworks.tlb type library. The only object that is createtable is the SldWorksClass.

Regards. Efrem

Reply to
e7r3m

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.