70001919 Add Ellipse on ScriptCommands

Article 70001919
Type Wish
Product WebJS
Version 8006
Date Added 2/9/2021 12:00:00 AM
Fixed 9.9001.0.3 (2/10/2021 12:00:00 AM)
Submitted by Bogumil Styczen

Summary

I would like to be able to create ellipses through ScriptCommands.

Solution

In version 9001.0.3 user is able to an vdEllipse on WebControl through ScriptCommands by using the scriptCommand.ellipse(object[] parameters, ScriptEntityDelegate callback) method.

If passed parameters not exist or it is null then start a new user action and prompts the user to draw an ellipse. If parameters are not null then a new ellipse is added synchronously depend on the passed parameters.
The command adds the action to undo history and also to script lines "getCommands" If parameters are not null and after this command is finished the object is not drawn on screen.
In order to display it call "vdrawObj.DrawEntity" and "vdrawObj.Refresh" inside the user define callback function.

"parameters": An array of parameters in the following order, used for no user action.
1."center": The ellipse's center point in world coordinate system, as an array of 3 numbers(X,Y,Z).
2."MajLen": The ellipse's major length in drawin units.
3."MinLen": The ellipse's minor length in drawin units.
4."MajAngle": The ellipse's rotation angle in radians.
5."SAngle": The angle at which the ellipse start drawing its periphery in radians.
6."EAngle": The angle at which the ellipse stops drawing its periphery in radians.
"callback": A user function of "ScriptEntityDelegate" type, that will be called when the command finish successfully.It can be ignored.
If the command is not finished succesfully then the entity may be null.Also user must check the vdraw.ActiveAction().IsCanceled() to determine if the command is canceled by user.

Example 1: Start a user action to draw an ellipse.

vdrawobj.scriptCommand.ellipse();

Example 2: Create and display a new ellipse object with center(0,0,0), MajLen:5.0, MinLen:2.0, MajAngle:45degrees and EAngle:0degrees.

After this command is finished the object is not drawn on screen so we will call a redraw on the finished callback of the function.

vdrawobj.scriptCommand.ellipse([ [0, 0, 0], 5.0, 2.0, vdgeo.DegreesToRadians(45), vdgeo.DegreesToRadians(0) ], addedEllipse);

function addedEllipse(vdraw, entity) {
vdraw.DrawEntity(entity);
setTimeout(vdraw.redraw); //post a redraw command
}

Send comments on this topic.