Access to EnvDTE80.DTE2 from IronPython
Hi all,Sorry if this is off topic, please say so if it is more suited in an IP forum.
I've been playing around with the IronPython integration sample and scripting VS and would like to access objects/properties defined by the EnvDTE80 namespace.
I can import the namespace and have access to the types but cannot get the dte object to behave as a DTE2. Is it possible? How could I implement the below VB macro code in IP?
Dim bpAs EnvDTE80.Breakpoint2
bp = DTE.Debugger.Breakpoints.Item(1)
Dim macAsString
mac = bp.Macro
I have tried many variations of the below
import clr
clr.AddReferenceToFileAndPath(r"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\EnvDTE80.dll")
import EnvDTE80
def PrintBreakPointCount(dte):
dte.Debugger.Breakpoints.Item(1).Macro
pass
But all I get is :-'<type '__ComObject'>' object has no attribute 'Macro'
Any Ideas?Many thanks
Bart
Hi,
I don't know about IronPython but in general you can get a DTE or DTE2 in the following ways:
- From a macro, using the DTE intrinsic instance.
- From an add-in, casting the app passed in the OnConnection method
- From an external program, using objTE = CreateObject("VisualStudio.DTE.8.0")
- From a VS package, calling the GetService(typeof(EnvDTE.DTE)) method.
If the IDE is VS 2005, the DTE object can be cast to EnvDTE80.DTE2
The BreakPoint interface does not have a Macro member, according to http://msdn2.microsoft.com/en-us/library/envdte.breakpoint_members.aspx
Are you expecting it to have a such a member defined?
You can use the IronPython console to access the dte object directly and instantly. It comes with the IronPython integration and it is accessible from the View\Other Windows\ menu. The console has auto completion and is very useful when writing macros.
Hi,
The IronPython console has access to the DTE object and "sees" as the EnvDTE series of interfaces. The problem I have is that I want to be able to use the EnvDTE80 series of interfaces as they expose the cool VS2005 features.
http://msdn2.microsoft.com/en-us/library/0e105c68.aspx
http://msdn2.microsoft.com/en-us/library/envdte80.breakpoint2.macro.aspx
To do this is trivial in C# or VB as you just cast the objects and get access to the members and values. In the IronPython console I have access to the types once the EnvDTE80 namespace is imported but cant get the access to them from the dte object. From every thing I have read IronPython does not have this casting ability but the members should be available at runtime. They don't seem to be, unfortunatley I am a IP newbie don't know how to go about forcing different interface members to be visible.
Cheers
Bart