I'm using v8 2004 Ver08.05.02.70 And V8i 08.11.09.459
There is a difference of time's execution of this simple vba:
Sub speed_test2()Dim Lg1 As LineElementActiveSettings.Scale.X = 2ActiveSettings.Scale.Y = 2ActiveSettings.Scale.Z = 2For i = 0 To 100Set Lg1 = CreateLineElement2(Nothing, Point3dFromXY(i, 0), Point3dFromXY(i, 100))ActiveModelReference.AddElement Lg1CadInputQueue.SendCommand ("scale")CadInputQueue.SendDataPointForLocate Lg1, Point3dZeroCadInputQueue.SendDataPoint Point3dFromXY(i, 0)CadInputQueue.SendResetNext iEnd Sub
Can you tell me why it's so longer with v8i ? Location ?? sendcommand ?
It's just an simple example, and I know it's not "pure vba" but what I am missing?
what does it mean "so longer"? Is it ten times longer or even a hundred times? There is no guarantee API has the same speed in different versions. Many things has changed from V8 2004 Edition inside MicroStation, which is probably the reson of the different speed.
Because there is no profiler available in MicroStation VBA, you should add a time counter to your code to check what step takes the most of the time.
In my opinion your code is not very realistic, to use SendCommand, which simulates a user interaction, in a loop is nothing than should be found in well written code.
So I think the target is not to discuss why one version is different to another (well, if it's hundreds time slower, of course report is as a bug), but if you will be able to identify what line is slower, to find a way how to optimize the code or to do the same thing in a different faster way.
Labyrinth Technology | dev.notes() | cad.point
in Microstation -VBA manner I would
replace the scaling "CadInputQueue.SendCommand" with the MVBA equivalent tool set. Ther are plenty of examples in the help-file and indeed in the forum.
since 1985: CAD/GIS : [Esri ArcMap , Bentley MS V4 - V8i, GeoGraphics, Map, InRoads ; AutoCAD , HHK Geograf , IBr DAVID, AED-SICAD ] Dev: [C, C++, Basic , Java, SQL, FORTRAN, UML][direct quote by: http://en.wikipedia.org/wiki/Helmut_Schmidt]: "Wer Kritik übel nimmt, hat etwas zu verbergen"
Ok Jan and Frank,
In my real vba, i use the command "construct line minimum" between two elements: a point (lineelement in fact) and a ComplexStringElement ( Which I get subelements )
So I Apply this command (construct line element) to each subelement
getLastValidGraphicalElement and compare the lenght of each lines ( keep the minimum length and the endpoint of the line)
So I don't find the good way in vba to place a minimum line between a point and a element
Sorry for my poor English, Merci
LaurentD said:In my real vba, i use the command "construct line minimum" between two elements: a point (lineelement in fact) and a ComplexStringElement ( Which I get subelements )
I think (but have not tried it) you can use mdlMinDist_betweenElms VBA wrapper.
LaurentD said:So I don't find the good way in vba to place a minimum line between a point and a element
Function mdlMeasure_closestPointOnElement can be the solution.
LaurentD said:Sorry for my poor English, Merci
Don't worry about English, there is no English native speaker in this discussion involved so far :-)
Answer Verified By: LaurentD
I 'll try
May be ProjectPointOnPerpendicular2 can help too