I use microstation 08.11.09.578, 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. Syntax Point2d = object.Point2dFromXY (X, Y)
ba ranh said:I see the manual but don't see the method 'Point2dFromXY'
What programming language are you using?
Regards, Jon Summers LA Solutions
I use C#
ba ranh said:I use C# with MicroStation 08.11.09.578
You're calling the VBA COM InterOp from C# from a separate process (i.e. a EXE).
ba ranh said:I want to get the 2D coordinates of the element
All DGN coordinates are 3D, even when in a 2D model. The Z value is zero in 2D.
I strongly suggest that you write a prototype of your app. using VBA. Move it to C# once the VBA is working correctly.
Different element types have different ways of getting coordinates. A TextElement or CellHeaderElement has an Origin property. Linear elements implement the IVertexList interface.
TextElement
CellHeaderElement
Origin
IVertexList
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(); _MSesc.ExcludeAllTypes(); _MSesc.IncludeType(MsdElementType.msdElementTypeLine); //_MSesc.IncludeType(MsdElementType.msdElementTypeLineString); _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); } }