Hi community,
What would be your best way to scale a newly created line based on a user input?
I am thinking of creating a small program which let's the user input a *.txt file with coordinates from a point with old and new coordinates, draw a line between old and new coordinates (using the Application.CreateLineElement2 function) and then scale this newly line based on a user input
Assume the following:
Program then draws a line between XYZ_old to XYZ_new and then scales the line based on the user input. E.g. if the user inputs "500" the program shall scale this created line 500 times, with the origin on the XYZ_old coordinates.
I am not after the entire code itself at this stage. More about the ideas or say tools Microstation VBA has available? Are there functions available for 2D and/or 3D-scaling available?
Google hasn't found me something useful, neither the learning Microstation VBA handbook.
Thanks in advance
I believe Point3dScale method is what you want.
The VBA code can be something like this:
Sub Point3dScaleTest() Dim oldPt As Point3d, newPt As Point3d, vec As Point3d, scaledNewPt As Point3d oldPt = Point3dFromXYZ(X_old, Y_old, Z_old) newPt = Point3dFromXYZ(X_new, Y_new, Z_new) vec = Point3dSubtract(newPt, oldPt) scaledNewPt = Point3dScale(vec, myScale) End Sub
Hello Yongan, thank you for your input. What I am after is scaling a line, not a point unfortunately.
Answer Verified By: Marco W
Hi Marco. In MicroStation (and in any other software really), Lines have 2 points, a start and end point. A point element is actually a line element with length =0 , therefore a point element has its start and end points in the same location. Yongan’s example is creating a vector from a line’s start & end points by subtracting them, then scaling that vector by a scale factor. Try his sample code with a single line and you can compare the results doing the same with the scale tool and looking at the start and endpoint coordinates via the element properties or XYZ text.
Hi Barry, ah I see! makes sense. Thanks for your explanation.