I'm using Microstation COM in a .Net app (I'm porting my Vehicle Turning Simulation MSTurn from classic VB6). I've noticed that creating Linestrings is a rather slow process since I need to provide data with the Point3DfromXYZ. My calculated values for the linestring are stored in a Array and it would be nice if I could eliminate looping through the array to create points using Point3DfromXYZ
I've seen functions in other CAD systems (Intellicad) that has functions for converting arrays of doubles to collections. I can't find anything similar in Microstation (COM). Is it possible to build a LineString from a array of doubles?
Unknown said:It would be nice if I could eliminate looping through the array to create points using Point3DfromXYZ
MicroStation APIs (MDL, VBA) work with 3D data. The Point3d data type is the foundation of 3D geometry. If source data is in some other format (e.g. parallel arrays of X,Y coordinates) then you must convert those to an array of Point3d.
Unknown said:I've seen functions in other CAD systems for converting arrays of doubles
It's simple enough to write your own conversion. If another API provides something similar you will recognise that it's just a convenience function.
Unknown said:I've seen functions for converting arrays to collections
Collection means a particular type of data container. The collection provided by VB/VBA is notoriously slow. For what you want to achieve, a collection is unhelpful. If you already have an array of data, then looping through that set is quicker than using a collection...
Sub ConvertDoubleToPoint3dArray ( _ ByRef points() As Point3d, _ ByRef x() As Double, _ ByRef y() As Double, _ ByVal nPoints As Long) Redim points (0 to nPoints-1) Dim i As Long For i = 0 To nPoints -1 points(i) = Point3dFromXY (x(i), y(i)) Next i End Sub
Regards, Jon Summers LA Solutions
Unknown said:I was hoping for one call to the COM object instead of hundreds
OK — I can imagine that would be slow. Is your .NET application an exe or a dll? An exe will be calling MicroStation VBA using Microsoft COM's marshalling across the process boundary, which adds substantially to the overhead.
But why not build the array of Point3d in your .NET app.? If the Point3dFromXY call is slowing things down, then do it directly to avoid that COM call...
Sub ConvertDoubleToPoint3dArray ( _ ByRef points() As Point3d, _ ByRef x() As Double, _ ByRef y() As Double, _ ByVal nPoints As Long) Redim points (0 to nPoints-1) Dim i As Long For i = 0 To nPoints -1 points(i).X = x(i) points(i).Y = y(i) points(i).Z = 0 Next i End Sub
Answer Verified By: Lars Karlsson