Mtext Jig Issue or an alternative Mtext Jig getting Base point only

Mtext Jig Issue or an alternative Mtext Jig getting Base point only

kite15
Advocate Advocate
719 Views
2 Replies
Message 1 of 3

Mtext Jig Issue or an alternative Mtext Jig getting Base point only

kite15
Advocate
Advocate

Hi,

I have Mtext Jig whereas, having some error during long time run in while loop. Can you please, suggest the correct one or how can it make as bugs free ?

        public class MTextJig : EntityJig
        {
            MText mtext;
            Point3d basePt, dragPt;

            public MTextJig(MText mtext)
                : base(mtext)
            {
                this.mtext = mtext;
                basePt = mtext.Location;
            }

            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                var options = new JigPromptPointOptions("\nInsertion point: ");
                options.BasePoint = basePt;
                options.UseBasePoint = true;
                options.UserInputControls =
                    UserInputControls.Accept3dCoordinates |
                    UserInputControls.NullResponseAccepted | 
                    UserInputControls.UseBasePointElevation;
                var result = prompts.AcquirePoint(options);
                if (result.Value.IsEqualTo(dragPt))
                    return SamplerStatus.NoChange;
                dragPt = result.Value;
                return SamplerStatus.OK;
            }

            protected override bool Update()
            {
                mtext.Location = dragPt;
                return true;
            }
        }

Thanks in Advance...

0 Likes
720 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant

Hi,

 

I do not see anythung wrong wrong in the code you posted, the issue is certainly due the way you call the Jig.

You should post the calling method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 3

kite15
Advocate
Advocate

Hi,

Here is the calling code and the error message......Smiley Sad

 

using (DocumentLock acLckDoc = doc.LockDocument())
{
using (var tr = db.TransactionManager.StartTransaction())
{
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
ObjectId Tstyleid = db.Textstyle;
while (true)
{
using (var mtext = new MText())
{
mtext.Contents = OutTXTCompile(startVal);
mtext.Rotation = 0.0;
mtext.TextStyleId = Tstyleid;
curSpace.AppendEntity(mtext);
tr.AddNewlyCreatedDBObject(mtext, true);
MTextJig jig = new MTextJig(mtext);
var result = ed.Drag(jig);
if (result.Status != PromptStatus.OK)
{
mtext.Erase();
textBox_StrtVal.Text = (startVal - incrVal).ToString();
db.Textsize = txtSz;
break;
}
count++;
db.TransactionManager.QueueForGraphicsFlush();
startVal = startVal + incrVal;
}
}
tr.Commit();
}

}

Thanks....

0 Likes