Article | 60000532 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 5/29/2008 |
Submitted by | Levi Azevedo |
Keywords |
It is possible to create your own custom cmdScale command. See this sample code in C# :
vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;
doc.Prompt("Select objects:");
doc.CommandAction.CmdSelect("user");
doc.Prompt(null);
if (!success) return;
vdSelection documentSelection = doc.Selections.Add("VDRAW_PREVIOUS_SELSET");
if (documentSelection.Count == 0) return;
doc.Prompt("Specify base point:");
gPoint origin = doc.ActionUtility.getUserPoint() as gPoint;
doc.Prompt(null);
if (origin == null) return;
bool copymode = false;
vdSelection set = null;
double scalevalue = 1.0d;
do
{
doc.Prompt("Specify scale factor or [Copy/Reference]:");
VectorDraw.Professional.CommandActions.ActionGetTranfromSelection AScale = new VectorDraw.Professional.CommandActions.ActionGetTranfromSelection(origin, doc.ActiveLayOut, documentSelection, VectorDraw.Professional.CommandActions.ActionTransformParameter.ScaleXY);
AScale.SetAcceptedStringValues(new string[] { "Copy;c;C", "Reference;r;R" }, null);
doc.ActionAdd(AScale);
StatusCode scode = AScale.WaitToFinish();
doc.Prompt(null);
if (scode != StatusCode.Success) return;
if (AScale.Value is double)
{
set = documentSelection;
scalevalue = (double)AScale.Value;
break;
}
else if (AScale.Value.Equals("Copy"))
{
copymode = true;
}
else if (AScale.Value.Equals("Reference"))
{
doc.Prompt("Specify reference length:");
object aret = doc.ActionUtility.getUserDist(null);
doc.Prompt(null);
if (aret is double)
{
double referencelength = (double)aret;
doc.Prompt("Specify new length:");
aret = doc.ActionUtility.getUserDist(null);
doc.Prompt(null);
if (aret is double)
{
double newlength = (double)aret;
set = documentSelection;
scalevalue = newlength / referencelength;
break;
}
}
}
else
{
return;
}
} while (true);
if (set != null)
{
if (copymode)
{
set = new vdSelection();
set.SetUnRegisterDocument(doc);
foreach (vdFigure fig in documentSelection)
{
vdFigure clonefig = fig.Clone(doc) as vdFigure;
doc.ActiveLayOut.LayoutOrViewPortEntities().AddItem(clonefig);
set.AddItem(clonefig, false, vdSelection.AddItemCheck.Nochecking);
}
}
doc.CommandAction.CmdScale(set, origin, scalevalue);
}