Get Point X Y 2D

I use microstation, DGN 2D V7 Upgrade V8

I want to get the 2D coordinates of the element, I see the manual but don't see the method 'Point2dFromXY'

Point2dFromXY Method
Returns a point with specified x and y components. 

Point2d = object.Point2dFromXY (X, Y) 

  • I get the element's X Y coordinate but it returns null

    Code C#

    void Test(string sPath)
        MicroStationDGN.Application app = new MicroStationDGN.Application();
        DesignFile dgnfile = app.OpenDesignFile(sPath, true);
        ElementScanCriteria _MSesc = new ElementScanCriteria();
        _Element ele;
        ElementEnumerator ee = app.ActiveModelReference.Scan(_MSesc);
        while (ee.MoveNext())
            ele = ee.Current;
            int iVectorCount = ele.AsLineElement.VerticesCount;
            Array xPoint = ele.AsLineElement.GetVertices();
            string sTEXT = ""; 
            for (int i = 0; i < iVectorCount; i++)
                sTEXT += ", i = " + i 
                + " : X = " + xPoint.GetValue(0)
                + ", Y = " + xPoint.GetValue(1)
                + ", Z = " + xPoint.GetValue(2)
            MessageBox.Show("sTEXT = " + sTEXT);

  • Hi,

    I want to get the X Y coordinates of the line element

    Line or LineString element?

    I convert to c# code

    But, unfortunately, you did it wrongly.

    As was discussed already in another thread, when you choose to wrote external application (and not in-process addin), you have to meet more requirements and the code is (a bit) more complex. In the discussed case, as described in VBA documentation, you should use CreateObjectInMicroStation method. But, I assume the error is not caused by this omission.

    I get the element's X Y coordinate but it returns null

    Did you read the error message? The problem is not it returns null.

    How it is possible that MicroStation data type is to be loaded from WindowsFormsApp1 assembly? Without knowing how complete project is set (what assemblies are referenced etc.) it's hard to say.

    Array xPoint = ele.AsLineElement.GetVertices();

    Why this declaration is used?

    GetVertices() returns Point3d[]



Reply Children