.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why does Editor.Drag return a PromptStatus.Other if tab key was pressed?

0 REPLIES 0
Reply
Message 1 of 1
meichtf
410 Views, 0 Replies

Why does Editor.Drag return a PromptStatus.Other if tab key was pressed?

I would like to create a line by using a Jig and an AlignedDimension and a Point3AngularDimension dynamic dimension, comparable what the PLINE command displays.

When I start the Jig with Editor.Drag(myJig), enter a value manually in the AlignedDimension and hit the Tab key the Drag method returns with a PromptStatus.Other status. I would like to behave it like the PLINE command where the tab key switches to the Point3AngularDimension and locks the AlignedDimension.

How can I avoid the Drag method from returning?

Regards,

Freddy


Code snippets:

Caller:

public LineString CreateLine(string prompt)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointResult pointResult = ed.GetPoint(prompt);
PromptStatus status = pointResult.Status;
if (status == PromptStatus.OK)
{
AddPoint(pointResult.Value);
}
try
{
while (status == PromptStatus.OK || status == PromptStatus.Keyword)
{
//LastPoint was previously added point
PointJig jig = new PointJig(prompt, LastPoint);
PromptResult res = ed.Drag(jig);
status = res.Status;
// A new point was added
if (res.Status == PromptStatus.OK)
{
//logic omitted
}
else if (res.Status == PromptStatus.Keyword)
{
//handle keyword logic omitted
}
if (res.Status == PromptStatus.Other)
{
Debug.Fail("Tab key was pressed in dyn dimension");
}
}
}
return lineString;
}


Jig

internal class PointJig : EntityJig
{

private readonly DynamicDimensionDataCollection dimensionDataCollection;


///
/// Initializes a new instance of the class.
///

/// The prompt.
/// The start point.
/// startPoint is null.
public PointJig(string prompt, Point3d startPoint)
: base(new Polyline())
{
this.prompt = prompt;
Line.AddVertexAt(Line.NumberOfVertices, new Point2d(startPoint.X, startPoint.Y), 0, 0, 0);
dimensionDataCollection = CreateDynamicDimensions(Line);

// Create polyline, set defaults, add dummy vertex
Polyline pline = Entity as Polyline;
pline.SetDatabaseDefaults();
pline.Normal = normal;
AddDummyVertex();

}

protected DynamicDimensionDataCollection CreateDynamicDimensions(Entity entity)
{
DynamicDimensionDataCollection m_dims = new DynamicDimensionDataCollection();
Dimension dim1 = new AlignedDimension();
dim1.SetDatabaseDefaults();
DynamicDimensionData alignedData = new DynamicDimensionData(dim1, true, true);
alignedData.Focal = true;
m_dims.Add(alignedData);
dim1.DynamicDimension = true;

Dimension dim2 = new Point3AngularDimension();
dim2.SetDatabaseDefaults();
DynamicDimensionData angleData = new DynamicDimensionData(dim2, true, true);
angleData.Focal = true;
m_dims.Add(angleData);
dim2.DynamicDimension = true;

return m_dims;
}

///
/// Gets the dynamic dimension data.
///

/// The dim scale.
///
protected override DynamicDimensionDataCollection GetDynamicDimensionData(double dimScale)
{
return dimensionDataCollection;
}

///
/// Updates this instance.
///

///
protected override bool Update()
{
// Update the dummy vertex to be our 3D point projected onto our plane

Polyline pline = Entity as Polyline;

pline.SetPointAt(pline.NumberOfVertices - 1, m_tempPoint.Convert2d(calculationPlane));

UpdateDimensions();

return true;
}

///
/// Samplers the specified prompts.
///

/// The prompts.
///
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptPointOptions jigOpts = new JigPromptPointOptions();
jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NullResponseAccepted | UserInputControls.NoNegativeResponseAccepted);

Polyline pline = Entity as Polyline;

// Get the point
PromptPointResult res = prompts.AcquirePoint(jigOpts);

if (res.Status == PromptStatus.Keyword)
{
return SamplerStatus.OK;
}

if (res.Status == PromptStatus.OK || res.Status == PromptStatus.Other)
{
// Check if it has changed or not (reduces flicker)
if (m_tempPoint == res.Value)
{
return SamplerStatus.NoChange;
}
m_tempPoint = res.Value;
return SamplerStatus.OK;
}

return SamplerStatus.Cancel;
}

private void UpdateDimensions()
{
//omited logic
}
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost