Hi!
I'm not sure whether this is the right forum but I don't know of any better one.
The problem is this:
I've just started to use microsoft powershell for accessing COM objects.
Now, powershell is a .net program and does some interop stuff.
I've got two programs I want to access (CAD programs).
Both can be readily customized using VBScript, but I'd like to
have the command prompt capabilities of powershell.
Now, with one program, everything works perfect, but with the other,
VBScript and powershell give different results.
Here's the VBScript program:
set App=getobject(,"ViewDraw.Application")
set View=App.ActiveView
App.AppendOutput "Output",View.Query(128,0).Count
and here the equivalent powershell program:
$App=[System.Runtime.InteropServices.Marshal]::GetActiveObject("ViewDraw.Application")
$View=$App.ActiveView
$App.AppendOutput("Output",$View.Query(128,0).Coun t)
The VBScript correctly executes the Query and gives the proper result
but the powershell script outputs nothing.
What I also saw is that for /some/ objects (like $App), powershell
has type info, but for others (notable the collection) it doesn't.
Is there a way I can tell powershell the rest of the types?
Here's the output for an object the powershell has type info about:
PS R:\$App
Documents : {System.__ComObject}
Visible : True
Application : System.__ComObject
FullName : C:\Mentor\2005EXP\SDD_HOME\wv\win32\bin\viewdraw.e xe
Name : DxDesigner
Parent : System.__ComObject
Interactive : True
ActiveView : System.__ComObject
ClientAdvisorFlags : 880260
ActiveViewHandle : 6031506
CommandBars : System.__ComObject
CurrentProject :
Q:\projects_test\hetzer\D2594-andreas\WGS01\schem\d2594wgs01\
PrimaryDirectory :
Q:\projects_test\hetzer\D2594-andreas\WGS01\schem\d2594wgs01
StatusBarText : For Help, press F1
BusyCursor : False
Version : 2005.1.0
Addins : {System.__ComObject, System.__ComObject,
System.__ComObject, System.__ComObject...}
ViewBaseSession : System.__ComObject
SynchronizesViewBase : True
OptionLevel :
CommandLineArguments :
SourceDocuments : {}
ProjMan : System.__ComObject
SilentMode : 0
LicenseMode : 1
ShellCmd : System.__ComObject
Cookies : System.__ComObject
ActiveDocument : System.__ComObject
Flows : {Library Manager Central Library, Expedition PCB,
DxBoardLink}
HTMLDocuments : {}
QueueSelectEvents : False
Project : System.__ComObject
CnsFileString :
w:\MGC_ADMIN_HOME\share\2005_SP1\standard\isis\ces _expedition.cns
And here for one it hash't:
PS R:\$V=$App.ActiveView
PS R:\$V
Viewport Block
TopBlock
-------- -----
--------
System.__ComObject System.__ComObject
System.__ComObject
Can I make the types known to powershell?
By the way, when I open the vb editor in Excel and load "ViewDraw.Application"
in "Extras->References" I can see the members and properties of the View
object perfectly well.
Lots of Greetings!
Volker
--
For email replies, please substitute the obvious.