70001820 Support CmdMirror command

Article 70001820
Type Wish
Product WebJS
Version 8005
Date Added 9/2/2020
Fixed 8.8006.0.2 (9/8/2020)
Submitted by Brendan Fry

Summary

Support CmdMirror command

Solution

In version 8006.0.2 new methods vdcanvas .CmdMirror and vdcanvas.scriptCommand.mirror was added

1. CmdMirror

syntax : CmdMirrorentities, axisPoint, axisAngle)

Mirror an array of vdraw entities around a 2d axis.
entities: An array of vdraw entities or null so the user can pick the objects on screen.
axisPoint: A point object in World coordinates or null so the user can pick this point on screen. This point will be used as the mirro axis base point.
axisAngle: The angle (in radians) defines the direction of the mirror axis or null in order for the user to select it on screen.

This command does not write to UndoHistory and Script buffer. In order to do that use the vdcanvas.scriptCommand.mirror



example
Start a new mirror user action .
vdrawObj.CmdMirror(null, null, null);
Mirror around X Axis
vdrawObj.CmdMirror(null, [0,0,0],0);
Mirror around Y Axis
vdrawObj.CmdMirror(null, [0,0,0],vdgeo.HALF_PI);

2.scriptCommand.mirror

syntax: mirroraxisPoint, axisAngle, callback)

Mirror the passed entities around an Axis that defined from the passed axisPoint in worldcs and passed axisAngle in radians. It also write to UndoHistory and script buffer

axisPoint : A point in world CS or undefined for user prompt
axisAngle: A rotation angle in radians or undefined for user prompt
callback: A user defined function that will be called when the command finish



example
//1. prompt the user for selection
vdrawObj.scriptCommand.select(null,function (_vdcanvas) { _vdcanvas.scriptCommand.mirror(); } );
//2. No user prompt do this action for all active layout entities
var entities = [];
var layout = vdcanvas.GetActiveLayout();
for (var i = 0; i < layout.Entities.Items.length; i++) {
var h = layout.Entities.Items[i];
fig = vdrawObj.GetEntityItem(h);
entities.push(fig);
}
vdrawObj.scriptCommand.select(entities,function (_vdcanvas) { _vdcanvas.scriptCommand.mirror([0,0,0],vdgeo.HALF_PI);});//mirror around Y Axis

Send comments on this topic.