$dgn=$objustn.OpenDesignFile('C:\x.dgn') $objustn.CadInputQueue.SendKeyin('fit all') $objustn.CadInputQueue.SendDataPoint <<variablePoint3d>> #void SendDataPoint (Point3d, Variant, int)
how to declare a Point3d variable named "VariablePoint3d" and assign x,y,z values to this in PowerShell.
How are you creating the $objustn variable?
if after creating the variable you do:
Get-Member -InputObject $objustn
what does it list as the properties and methods?
Hi Kevin,
Kevin van Haaren said:How are you creating the $objustn variable?
$objustn = new-Object -ComObject MicroStationDGN.Application
Kevin van Haaren said:Get-Member -InputObject $objustn
Type: Point3d -------- Method: Point3dFromXY (double, double)
Type: Point3d -------- Method: Point3dFromXYZ (double, double, double)
i tried with below code; But, still no luck.
[double]$var0 = 100.0 [double]$var1 = 100.0 [double]$var2 = 100.0 [Point3d]$pt=$objustn.Point3dFromXYZ($var0,$var1,$var2) ##ERROR The specified record cannot be mapped to a managed value class. At line:1 char:1 + [Point3d]$pt=$objustn.Point3dFromXYZ($var0,$var1,$var2) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], ArgumentException + FullyQualifiedErrorId : System.ArgumentException
Vinoth Joseph
ATKINS
Bangalore, India
The workaround of $objustn.CadInputQueue.SendDataPoint ($objustn.Point3dFromXY(1,2)) is
$objustn.CadInputQueue.SendKeyin ('XY=1,2')
Hi Vinoth,
I did not try to access MicroStation from PowerShell, but I think the problem is that in PowerShell, you access MicroStation COM directly, not using Interop. The method returns Point3d struct, which is not known to PowerShell and cannot be converted to known NET type. I vaguely remember structs are annoying a bit in COM.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Yes, Jan. kind of incompatibility is there. This is the first time that I'm trying to do something with PowerShell script and Microstation. Not sounds too good.!!
But, for ProjectWise integration PS is quite OK
Thanks again for support..
Yes Yongan, its working fine from key-in commands.
Vinoth Joseph said:kind of incompatibility is there.
You know, COM is really old concept, so some features look weird today.
It's the reason why Interop is typically created to encapsulate COM and to hide these obstacles. In fact, PowerShell should use Interop when not stric param is used, but whether here it's the problem of PowerShell or MicroStation implementation is out from my knowledge.