Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

MicroStation Addins

$
0
0

I am using MicroStation Connect Edition Update 11 - Version 10.11.00.6, Windows 10, Visual Studio 2015 and .Net Framework for the project is set at 4.6.1.  I am trying to build the MicroStation Addin examples by Yongan Fu but I'm receiving errors on the example in Step 2.  My code is as follows:

using System;
using Bentley.MstnPlatformNET.InteropServices;
using Bentley.Interop.MicroStationDGN;
namespace csAddins
{
    class CreateElement
    {
        public static void LineAndLineString()
        {
            Application app = Utilities.ComApp;
            Point3d[] pntArray = new Point3d[5];
            pntArray[0] = app.Point3dZero();
            pntArray[1] = app.Point3dFromXY(1, 2);
            pntArray[2] = app.Point3dFromXY(3, -2);
            pntArray[3] = app.Point3dFromXY(5, 2);
            pntArray[4] = app.Point3dFromXY(6, 0);
            LineElement oLine = app.CreateLineElement1(null, ref pntArray);
            oLine.Color = 1;
            oLine.LineWeight = 2;
            app.ActiveModelReference.AddElement(oLine);
        }
    }
}
The program builds successfully but when I try to load the addIn into MicroStation, I get the follow error:
************** Exception Text **************
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.StubHelpers.MngdSafeArrayMarshaler.ConvertSpaceToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
   at Bentley.Interop.MicroStationDGN.Application.CreateLineElement1(Element Template, Point3d[]& Vertices)
   at csAddins.CreateElement.LineAndLineString() in C:\Users\larry.smart\OneDrive - Union Tank Car Company\Documents\MicroStation\C# Addins\Hello World\csAddins\csAddins\CreateElement.cs:line 19
   at csAddins.MyAddin.Run(String[] commandLine) in C:\Users\larry.smart\OneDrive - Union Tank Car Company\Documents\MicroStation\C# Addins\Hello World\csAddins\csAddins\MyAddin.cs:line 15
   at Bentley.MstnPlatformNET.AddIn.Load(String[] commandTail, IntPtr mdlDesc)
Line 19 is the following code from above:
LineElement oLine = app.CreateLineElement1(null, ref pntArray);
Does anyone know what this error message is?
Thanks,
Larry

Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>