<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with Jig in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685910#M81277</link>
    <description>Try tis code:&lt;BR /&gt;
[code]&lt;BR /&gt;
class InsertBlockJig : EntityJig&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
    Point3d mStartPt, acquiredPoint, CurvePoint;&lt;BR /&gt;
    Curve mCurve;&lt;BR /&gt;
    bool mFlip;&lt;BR /&gt;
    double mScale;&lt;BR /&gt;
    double UCSAngle;&lt;BR /&gt;
    Vector3d xAxis;&lt;BR /&gt;
    Matrix3d TextMatrix = new Matrix3d();&lt;BR /&gt;
    CoordinateSystem3d UCS = new CoordinateSystem3d();&lt;BR /&gt;
    Plane UCSPlane = new Plane();&lt;BR /&gt;
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
&lt;BR /&gt;
    double i;&lt;BR /&gt;
&lt;BR /&gt;
    public InsertBlockJig(Point3d Start, Curve Kurve, double Scale, bool Flip)&lt;BR /&gt;
        : base(new DBText())&lt;BR /&gt;
    {&lt;BR /&gt;
        mCurve = Kurve;&lt;BR /&gt;
        mStartPt = Start;&lt;BR /&gt;
        mScale = Scale;&lt;BR /&gt;
        mFlip = Flip;&lt;BR /&gt;
        i = 0;&lt;BR /&gt;
        ((DBText)Entity).Height = mScale;&lt;BR /&gt;
        ((DBText)Entity).VerticalMode = TextVerticalMode.TextBottom;&lt;BR /&gt;
        ((DBText)Entity).HorizontalMode = TextHorizontalMode.TextCenter;&lt;BR /&gt;
        ((DBText)Entity).SetDatabaseDefaults(HostApplicationServices.WorkingDatabase);&lt;BR /&gt;
        ((DBText)Entity).TextStyle = HostApplicationServices.WorkingDatabase.Textstyle;&lt;BR /&gt;
        Update();&lt;BR /&gt;
     }&lt;BR /&gt;
&lt;BR /&gt;
    protected override SamplerStatus Sampler(JigPrompts prompts)&lt;BR /&gt;
    {&lt;BR /&gt;
        JigPromptPointOptions jigOpts = new JigPromptPointOptions();&lt;BR /&gt;
        jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.InitialBlankTerminatesInput | UserInputControls.NullResponseAccepted);&lt;BR /&gt;
&lt;BR /&gt;
        jigOpts.Message = "\nEinfьgepunkt angeben oder neues";&lt;BR /&gt;
&lt;BR /&gt;
        PromptPointResult res = prompts.AcquirePoint(jigOpts);&lt;BR /&gt;
        if (res.Status == PromptStatus.Cancel | res.Status == PromptStatus.Keyword)&lt;BR /&gt;
            return SamplerStatus.Cancel;&lt;BR /&gt;
&lt;BR /&gt;
        acquiredPoint = res.Value;&lt;BR /&gt;
&lt;BR /&gt;
        if (mStartPt != acquiredPoint)&lt;BR /&gt;
        {&lt;BR /&gt;
            mStartPt = acquiredPoint;&lt;BR /&gt;
        }&lt;BR /&gt;
        else&lt;BR /&gt;
            return SamplerStatus.NoChange;&lt;BR /&gt;
&lt;BR /&gt;
        return SamplerStatus.OK;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override bool Update()&lt;BR /&gt;
    {&lt;BR /&gt;
&lt;BR /&gt;
        try&lt;BR /&gt;
        {&lt;BR /&gt;
            CurvePoint = mCurve.GetClosestPointTo(mStartPt, ed.GetCurrentView().ViewDirection,false);&lt;BR /&gt;
            double parm = mCurve.GetParameterAtPoint(CurvePoint);&lt;BR /&gt;
            ((DBText)Entity).TextString = mCurve.GetDistanceAtParameter(parm).ToString();&lt;BR /&gt;
&lt;BR /&gt;
            xAxis = mCurve.GetFirstDerivative(CurvePoint).GetNormal();&lt;BR /&gt;
&lt;BR /&gt;
            ((DBText)Entity).Position = mStartPt;&lt;BR /&gt;
&lt;BR /&gt;
            if (i == 0)&lt;BR /&gt;
            {&lt;BR /&gt;
&lt;BR /&gt;
                Matrix3d UCSMatrix = ed.CurrentUserCoordinateSystem;&lt;BR /&gt;
                UCS = UCSMatrix.CoordinateSystem3d;&lt;BR /&gt;
                TextMatrix = Matrix3d.AlignCoordinateSystem(CurvePoint, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,&lt;BR /&gt;
                                   UCS.Origin, UCS.Xaxis, UCS.Yaxis, UCS.Zaxis);&lt;BR /&gt;
                ((DBText)Entity).TransformBy(TextMatrix);&lt;BR /&gt;
                UCSAngle = ((DBText)Entity).Rotation;&lt;BR /&gt;
                ++i;&lt;BR /&gt;
                UCSPlane = new Plane(CurvePoint, UCS.Xaxis, UCS.Yaxis);&lt;BR /&gt;
            }&lt;BR /&gt;
            ed.WriteMessage("\nWinkel: " + UCSPlane.GetCoordinateSystem().Xaxis.ToString());&lt;BR /&gt;
            Vector3d v = xAxis.ProjectTo(UCSPlane.Normal, ed.GetCurrentView().ViewDirection);&lt;BR /&gt;
            double Angle = v.AngleOnPlane(UCSPlane);&lt;BR /&gt;
            ed.WriteMessage("\nWinkel: " + Angle);&lt;BR /&gt;
            ed.WriteMessage("\nUCSAngle: " + UCSAngle);&lt;BR /&gt;
            ((DBText)Entity).Rotation =&lt;BR /&gt;
               ((Angle + UCSAngle) &amp;gt; Math.PI * 2.0) ? (Angle + UCSAngle - Math.PI * 2.0) : (Angle + UCSAngle);&lt;BR /&gt;
            ((DBText)Entity).AlignmentPoint = CurvePoint;&lt;BR /&gt;
            ((DBText)Entity).AdjustAlignment(HostApplicationServices.WorkingDatabase);&lt;BR /&gt;
        }&lt;BR /&gt;
        catch (System.Exception)&lt;BR /&gt;
        {&lt;BR /&gt;
            return false;&lt;BR /&gt;
        }&lt;BR /&gt;
&lt;BR /&gt;
        return true;&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override DynamicDimensionDataCollection GetDynamicDimensionData(double dimScale)&lt;BR /&gt;
    {&lt;BR /&gt;
        return base.GetDynamicDimensionData(dimScale);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override void OnDimensionValueChanged(DynamicDimensionChangedEventArgs e)&lt;BR /&gt;
    {&lt;BR /&gt;
        base.OnDimensionValueChanged(e);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    void UpdateDimensions()&lt;BR /&gt;
    {&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    public Entity GetEntity()&lt;BR /&gt;
    {&lt;BR /&gt;
        ((DBText)Entity).AlignmentPoint = CurvePoint;&lt;BR /&gt;
        return Entity;&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
[/code]</description>
    <pubDate>Sun, 25 Jun 2006 11:10:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-06-25T11:10:21Z</dc:date>
    <item>
      <title>Problem with Jig</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685908#M81275</link>
      <description>As you can see, this Class inserts a Text with the actual length of a curve&lt;BR /&gt;
at the cursorposition.&lt;BR /&gt;
All works without any problems in wcs. The text rotates like it should. When&lt;BR /&gt;
i try it in a ucs, the text sometimes rotates a little bit wrong, as i said,&lt;BR /&gt;
sometimes and not allways.&lt;BR /&gt;
I have no idea what i can do, any ideas?&lt;BR /&gt;
&lt;BR /&gt;
code&lt;BR /&gt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;
#region Using directives&lt;BR /&gt;
&lt;BR /&gt;
using System;&lt;BR /&gt;
&lt;BR /&gt;
using System.Collections.Generic;&lt;BR /&gt;
&lt;BR /&gt;
using System.Text;&lt;BR /&gt;
&lt;BR /&gt;
using System.Threading;&lt;BR /&gt;
&lt;BR /&gt;
using System.Globalization;&lt;BR /&gt;
&lt;BR /&gt;
using Autodesk.AutoCAD.EditorInput;&lt;BR /&gt;
&lt;BR /&gt;
using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;
&lt;BR /&gt;
using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;
&lt;BR /&gt;
using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;
&lt;BR /&gt;
using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;
&lt;BR /&gt;
#endregion&lt;BR /&gt;
&lt;BR /&gt;
[assembly: CommandClass(typeof(RSNNAcadApp.ExtendedCommands.TestText))]&lt;BR /&gt;
&lt;BR /&gt;
namespace RSNNAcadApp.ExtendedCommands&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
class TestText&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
private double ScaleFaktor = 2.5;&lt;BR /&gt;
&lt;BR /&gt;
private Curve CurveObj;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[CommandMethod("TestTextEinfüge")]&lt;BR /&gt;
&lt;BR /&gt;
public void TestTextInsert()&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");&lt;BR /&gt;
&lt;BR /&gt;
Database db = HostApplicationServices.WorkingDatabase;&lt;BR /&gt;
&lt;BR /&gt;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
&lt;BR /&gt;
int Luprec = Application.DocumentManager.MdiActiveDocument.Database.Luprec;&lt;BR /&gt;
&lt;BR /&gt;
try&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
#region User Input&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
bool RightObject = false;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
//Selection of a Curve&lt;BR /&gt;
&lt;BR /&gt;
PromptEntityOptions CurveOptions = new PromptEntityOptions("Objekt wählen,&lt;BR /&gt;
an dem augerichtet werden soll");&lt;BR /&gt;
&lt;BR /&gt;
PromptEntityResult CurveResult = null;&lt;BR /&gt;
&lt;BR /&gt;
while (!RightObject)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
bool PromptCancel = false;&lt;BR /&gt;
&lt;BR /&gt;
do&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
CurveResult = ed.GetEntity(CurveOptions);&lt;BR /&gt;
&lt;BR /&gt;
} while (CurveResult.Status == PromptStatus.Error);&lt;BR /&gt;
&lt;BR /&gt;
if (CurveResult.Status == PromptStatus.Cancel)&lt;BR /&gt;
&lt;BR /&gt;
return;&lt;BR /&gt;
&lt;BR /&gt;
else if (CurveResult.Status == PromptStatus.OK)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
ObjectId entid = CurveResult.ObjectId;&lt;BR /&gt;
&lt;BR /&gt;
Entity tmpEnt = null;&lt;BR /&gt;
&lt;BR /&gt;
using (Transaction myT2 = db.TransactionManager.StartTransaction())&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
tmpEnt = (Entity)myT2.GetObject(entid, OpenMode.ForRead);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
CurveObj = tmpEnt as Curve;&lt;BR /&gt;
&lt;BR /&gt;
if (CurveObj != null)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
string ScaleFaktorPrompt = ScaleFaktor.ToString("F" + Luprec.ToString());&lt;BR /&gt;
&lt;BR /&gt;
ed.WriteMessage(String.Format("\nFaktor = {0}", ScaleFaktorPrompt));&lt;BR /&gt;
&lt;BR /&gt;
//highlight the entity&lt;BR /&gt;
&lt;BR /&gt;
CurveObj.Highlight();&lt;BR /&gt;
&lt;BR /&gt;
bool Flip = false;&lt;BR /&gt;
&lt;BR /&gt;
while (true)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
//Ask for StartPoint&lt;BR /&gt;
&lt;BR /&gt;
#region Get InsertPoint&lt;BR /&gt;
&lt;BR /&gt;
InsertBlockJig jig = new&lt;BR /&gt;
InsertBlockJig(CurveObj.GetClosestPointTo(CurveResult.PickedPoint, false),&lt;BR /&gt;
CurveObj, ScaleFaktor, Flip);&lt;BR /&gt;
&lt;BR /&gt;
PromptPointResult InsertResult = (PromptPointResult)ed.Drag(jig);&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
if (InsertResult.Status == PromptStatus.Cancel | InsertResult.Status ==&lt;BR /&gt;
PromptStatus.Error)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
PromptCancel = true;&lt;BR /&gt;
&lt;BR /&gt;
break;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
else if (InsertResult.Status == PromptStatus.OK)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
DBText TextObj = (DBText)jig.GetEntity();&lt;BR /&gt;
&lt;BR /&gt;
using (Transaction myT = db.TransactionManager.StartTransaction())&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
BlockTableRecord btr = (BlockTableRecord)myT.GetObject(CurveObj.OwnerId,&lt;BR /&gt;
OpenMode.ForWrite, false);&lt;BR /&gt;
&lt;BR /&gt;
btr.AppendEntity(TextObj);&lt;BR /&gt;
&lt;BR /&gt;
myT.AddNewlyCreatedDBObject(TextObj, true);&lt;BR /&gt;
&lt;BR /&gt;
myT.Commit();&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
else if (InsertResult.Status == PromptStatus.Keyword)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
else&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
PromptCancel = true;&lt;BR /&gt;
&lt;BR /&gt;
break;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
#endregion&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
CurveObj.Unhighlight();&lt;BR /&gt;
&lt;BR /&gt;
if (PromptCancel)&lt;BR /&gt;
&lt;BR /&gt;
break;&lt;BR /&gt;
&lt;BR /&gt;
RightObject = false;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
else&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
CurveOptions.Message = "Falsches Objekt!\nObjekt wählen, das gemessen werden&lt;BR /&gt;
soll";&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
#endregion&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
finally&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
class InsertBlockJig : EntityJig&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Point3d mStartPt, acquiredPoint;&lt;BR /&gt;
&lt;BR /&gt;
Curve mCurve;&lt;BR /&gt;
&lt;BR /&gt;
bool mFlip;&lt;BR /&gt;
&lt;BR /&gt;
double mScale;&lt;BR /&gt;
&lt;BR /&gt;
Vector3d xAxis;&lt;BR /&gt;
&lt;BR /&gt;
Matrix3d TextMatrix = new Matrix3d();&lt;BR /&gt;
&lt;BR /&gt;
CoordinateSystem3d UCS = new CoordinateSystem3d();&lt;BR /&gt;
&lt;BR /&gt;
Plane UCSPlane = new Plane();&lt;BR /&gt;
&lt;BR /&gt;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
&lt;BR /&gt;
double i;&lt;BR /&gt;
&lt;BR /&gt;
//DynamicDimensionDataCollection m_dims;&lt;BR /&gt;
&lt;BR /&gt;
public InsertBlockJig(Point3d Start, Curve Kurve, double Scale, bool Flip)&lt;BR /&gt;
&lt;BR /&gt;
: base(new DBText())&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
mCurve = Kurve;&lt;BR /&gt;
&lt;BR /&gt;
mStartPt = Start;&lt;BR /&gt;
&lt;BR /&gt;
mScale = Scale;&lt;BR /&gt;
&lt;BR /&gt;
mFlip = Flip;&lt;BR /&gt;
&lt;BR /&gt;
i = 0;&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).Height = mScale;&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).VerticalMode = TextVerticalMode.TextBottom;&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).HorizontalMode = TextHorizontalMode.TextCenter;&lt;BR /&gt;
&lt;BR /&gt;
Update();&lt;BR /&gt;
&lt;BR /&gt;
/*&lt;BR /&gt;
&lt;BR /&gt;
m_dims = new DynamicDimensionDataCollection();&lt;BR /&gt;
&lt;BR /&gt;
Dimension dim1 = new AlignedDimension();&lt;BR /&gt;
&lt;BR /&gt;
dim1.SetDatabaseDefaults();&lt;BR /&gt;
&lt;BR /&gt;
m_dims.Add(new DynamicDimensionData(dim1, true, true));&lt;BR /&gt;
&lt;BR /&gt;
*/&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
protected override SamplerStatus Sampler(JigPrompts prompts)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
JigPromptPointOptions jigOpts = new JigPromptPointOptions();&lt;BR /&gt;
&lt;BR /&gt;
jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates |&lt;BR /&gt;
UserInputControls.InitialBlankTerminatesInput |&lt;BR /&gt;
UserInputControls.NullResponseAccepted);&lt;BR /&gt;
&lt;BR /&gt;
jigOpts.Message = "\nEinfügepunkt angeben oder neues";&lt;BR /&gt;
&lt;BR /&gt;
//jigOpts.Keywords.Add("Objekt");&lt;BR /&gt;
&lt;BR /&gt;
//jigOpts.Keywords.Add("Faktor");&lt;BR /&gt;
&lt;BR /&gt;
//jigOpts.Keywords.Add("Spiegeln");&lt;BR /&gt;
&lt;BR /&gt;
//jigOpts.Keywords.Default = "Objekt";&lt;BR /&gt;
&lt;BR /&gt;
PromptPointResult res = prompts.AcquirePoint(jigOpts);&lt;BR /&gt;
&lt;BR /&gt;
if (res.Status == PromptStatus.Cancel | res.Status == PromptStatus.Keyword)&lt;BR /&gt;
&lt;BR /&gt;
return SamplerStatus.Cancel;&lt;BR /&gt;
&lt;BR /&gt;
acquiredPoint = res.Value;&lt;BR /&gt;
&lt;BR /&gt;
if (mStartPt != acquiredPoint)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
mStartPt = acquiredPoint;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
else&lt;BR /&gt;
&lt;BR /&gt;
return SamplerStatus.NoChange;&lt;BR /&gt;
&lt;BR /&gt;
return SamplerStatus.OK;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
protected override bool Update()&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
try&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Point3d CurvePoint = mCurve.GetClosestPointTo(mStartPt, false);&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).TextString = mCurve.GetDistAtPoint(CurvePoint).ToString();&lt;BR /&gt;
&lt;BR /&gt;
xAxis = mCurve.GetFirstDerivative(CurvePoint).GetNormal();&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).Position = mStartPt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
if (i == 0)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
Matrix3d UCSMatrix = ed.CurrentUserCoordinateSystem;&lt;BR /&gt;
&lt;BR /&gt;
UCS = UCSMatrix.CoordinateSystem3d;&lt;BR /&gt;
&lt;BR /&gt;
TextMatrix = Matrix3d.AlignCoordinateSystem(mStartPt, Vector3d.XAxis,&lt;BR /&gt;
Vector3d.YAxis, Vector3d.ZAxis, mStartPt, UCS.Xaxis, UCS.Yaxis, UCS.Zaxis);&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).TransformBy(TextMatrix);&lt;BR /&gt;
&lt;BR /&gt;
++i;&lt;BR /&gt;
&lt;BR /&gt;
UCSPlane = new Plane(mStartPt, UCS.Xaxis, UCS.Yaxis);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
ed.WriteMessage("\nWinkel: " +&lt;BR /&gt;
UCSPlane.GetCoordinateSystem().Xaxis.ToString());&lt;BR /&gt;
&lt;BR /&gt;
double Angle = xAxis.AngleOnPlane(UCSPlane);&lt;BR /&gt;
&lt;BR /&gt;
ed.WriteMessage("\nWinkel: " + Angle);&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).Rotation = Angle;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
catch (System.Exception)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
return false;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
return true;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
protected override DynamicDimensionDataCollection&lt;BR /&gt;
GetDynamicDimensionData(double dimScale)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
return base.GetDynamicDimensionData(dimScale);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
protected override void&lt;BR /&gt;
OnDimensionValueChanged(DynamicDimensionChangedEventArgs e)&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
base.OnDimensionValueChanged(e);&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
void UpdateDimensions()&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
/*&lt;BR /&gt;
&lt;BR /&gt;
DBText MyLine = (DBText)Entity;&lt;BR /&gt;
&lt;BR /&gt;
AlignedDimension dim = (AlignedDimension)m_dims[0].Dimension;&lt;BR /&gt;
&lt;BR /&gt;
dim.XLine1Point = MyLine.Position;&lt;BR /&gt;
&lt;BR /&gt;
dim.XLine2Point = MyLine.Position;&lt;BR /&gt;
&lt;BR /&gt;
dim.DimLinePoint = MyLine.Position;&lt;BR /&gt;
&lt;BR /&gt;
*/&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
public Entity GetEntity()&lt;BR /&gt;
&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
((DBText)Entity).AlignmentPoint = mStartPt;&lt;BR /&gt;
&lt;BR /&gt;
return Entity;&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</description>
      <pubDate>Fri, 23 Jun 2006 17:42:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685908#M81275</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-23T17:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Jig</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685909#M81276</link>
      <description>Is your text insert point xformed to wcs? this can give you incorrect results when working in different ucs's.</description>
      <pubDate>Sun, 25 Jun 2006 02:53:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685909#M81276</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-25T02:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Jig</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685910#M81277</link>
      <description>Try tis code:&lt;BR /&gt;
[code]&lt;BR /&gt;
class InsertBlockJig : EntityJig&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
    Point3d mStartPt, acquiredPoint, CurvePoint;&lt;BR /&gt;
    Curve mCurve;&lt;BR /&gt;
    bool mFlip;&lt;BR /&gt;
    double mScale;&lt;BR /&gt;
    double UCSAngle;&lt;BR /&gt;
    Vector3d xAxis;&lt;BR /&gt;
    Matrix3d TextMatrix = new Matrix3d();&lt;BR /&gt;
    CoordinateSystem3d UCS = new CoordinateSystem3d();&lt;BR /&gt;
    Plane UCSPlane = new Plane();&lt;BR /&gt;
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
&lt;BR /&gt;
    double i;&lt;BR /&gt;
&lt;BR /&gt;
    public InsertBlockJig(Point3d Start, Curve Kurve, double Scale, bool Flip)&lt;BR /&gt;
        : base(new DBText())&lt;BR /&gt;
    {&lt;BR /&gt;
        mCurve = Kurve;&lt;BR /&gt;
        mStartPt = Start;&lt;BR /&gt;
        mScale = Scale;&lt;BR /&gt;
        mFlip = Flip;&lt;BR /&gt;
        i = 0;&lt;BR /&gt;
        ((DBText)Entity).Height = mScale;&lt;BR /&gt;
        ((DBText)Entity).VerticalMode = TextVerticalMode.TextBottom;&lt;BR /&gt;
        ((DBText)Entity).HorizontalMode = TextHorizontalMode.TextCenter;&lt;BR /&gt;
        ((DBText)Entity).SetDatabaseDefaults(HostApplicationServices.WorkingDatabase);&lt;BR /&gt;
        ((DBText)Entity).TextStyle = HostApplicationServices.WorkingDatabase.Textstyle;&lt;BR /&gt;
        Update();&lt;BR /&gt;
     }&lt;BR /&gt;
&lt;BR /&gt;
    protected override SamplerStatus Sampler(JigPrompts prompts)&lt;BR /&gt;
    {&lt;BR /&gt;
        JigPromptPointOptions jigOpts = new JigPromptPointOptions();&lt;BR /&gt;
        jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.InitialBlankTerminatesInput | UserInputControls.NullResponseAccepted);&lt;BR /&gt;
&lt;BR /&gt;
        jigOpts.Message = "\nEinfьgepunkt angeben oder neues";&lt;BR /&gt;
&lt;BR /&gt;
        PromptPointResult res = prompts.AcquirePoint(jigOpts);&lt;BR /&gt;
        if (res.Status == PromptStatus.Cancel | res.Status == PromptStatus.Keyword)&lt;BR /&gt;
            return SamplerStatus.Cancel;&lt;BR /&gt;
&lt;BR /&gt;
        acquiredPoint = res.Value;&lt;BR /&gt;
&lt;BR /&gt;
        if (mStartPt != acquiredPoint)&lt;BR /&gt;
        {&lt;BR /&gt;
            mStartPt = acquiredPoint;&lt;BR /&gt;
        }&lt;BR /&gt;
        else&lt;BR /&gt;
            return SamplerStatus.NoChange;&lt;BR /&gt;
&lt;BR /&gt;
        return SamplerStatus.OK;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override bool Update()&lt;BR /&gt;
    {&lt;BR /&gt;
&lt;BR /&gt;
        try&lt;BR /&gt;
        {&lt;BR /&gt;
            CurvePoint = mCurve.GetClosestPointTo(mStartPt, ed.GetCurrentView().ViewDirection,false);&lt;BR /&gt;
            double parm = mCurve.GetParameterAtPoint(CurvePoint);&lt;BR /&gt;
            ((DBText)Entity).TextString = mCurve.GetDistanceAtParameter(parm).ToString();&lt;BR /&gt;
&lt;BR /&gt;
            xAxis = mCurve.GetFirstDerivative(CurvePoint).GetNormal();&lt;BR /&gt;
&lt;BR /&gt;
            ((DBText)Entity).Position = mStartPt;&lt;BR /&gt;
&lt;BR /&gt;
            if (i == 0)&lt;BR /&gt;
            {&lt;BR /&gt;
&lt;BR /&gt;
                Matrix3d UCSMatrix = ed.CurrentUserCoordinateSystem;&lt;BR /&gt;
                UCS = UCSMatrix.CoordinateSystem3d;&lt;BR /&gt;
                TextMatrix = Matrix3d.AlignCoordinateSystem(CurvePoint, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,&lt;BR /&gt;
                                   UCS.Origin, UCS.Xaxis, UCS.Yaxis, UCS.Zaxis);&lt;BR /&gt;
                ((DBText)Entity).TransformBy(TextMatrix);&lt;BR /&gt;
                UCSAngle = ((DBText)Entity).Rotation;&lt;BR /&gt;
                ++i;&lt;BR /&gt;
                UCSPlane = new Plane(CurvePoint, UCS.Xaxis, UCS.Yaxis);&lt;BR /&gt;
            }&lt;BR /&gt;
            ed.WriteMessage("\nWinkel: " + UCSPlane.GetCoordinateSystem().Xaxis.ToString());&lt;BR /&gt;
            Vector3d v = xAxis.ProjectTo(UCSPlane.Normal, ed.GetCurrentView().ViewDirection);&lt;BR /&gt;
            double Angle = v.AngleOnPlane(UCSPlane);&lt;BR /&gt;
            ed.WriteMessage("\nWinkel: " + Angle);&lt;BR /&gt;
            ed.WriteMessage("\nUCSAngle: " + UCSAngle);&lt;BR /&gt;
            ((DBText)Entity).Rotation =&lt;BR /&gt;
               ((Angle + UCSAngle) &amp;gt; Math.PI * 2.0) ? (Angle + UCSAngle - Math.PI * 2.0) : (Angle + UCSAngle);&lt;BR /&gt;
            ((DBText)Entity).AlignmentPoint = CurvePoint;&lt;BR /&gt;
            ((DBText)Entity).AdjustAlignment(HostApplicationServices.WorkingDatabase);&lt;BR /&gt;
        }&lt;BR /&gt;
        catch (System.Exception)&lt;BR /&gt;
        {&lt;BR /&gt;
            return false;&lt;BR /&gt;
        }&lt;BR /&gt;
&lt;BR /&gt;
        return true;&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override DynamicDimensionDataCollection GetDynamicDimensionData(double dimScale)&lt;BR /&gt;
    {&lt;BR /&gt;
        return base.GetDynamicDimensionData(dimScale);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    protected override void OnDimensionValueChanged(DynamicDimensionChangedEventArgs e)&lt;BR /&gt;
    {&lt;BR /&gt;
        base.OnDimensionValueChanged(e);&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    void UpdateDimensions()&lt;BR /&gt;
    {&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    public Entity GetEntity()&lt;BR /&gt;
    {&lt;BR /&gt;
        ((DBText)Entity).AlignmentPoint = CurvePoint;&lt;BR /&gt;
        return Entity;&lt;BR /&gt;
    }&lt;BR /&gt;
}&lt;BR /&gt;
[/code]</description>
      <pubDate>Sun, 25 Jun 2006 11:10:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685910#M81277</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-25T11:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Jig</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685911#M81278</link>
      <description>Thank you very much, Alexander!&lt;BR /&gt;
I've learned so many thing from your example that i was searching for for so &lt;BR /&gt;
long.&lt;BR /&gt;
It works like i wanted, no, it is much better.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
Roland Feletic&lt;BR /&gt;
Ingenieurbuero A. Pauser Ges.m.b.H.&lt;BR /&gt;
http://www.pauser.at&lt;BR /&gt;
&lt;BR /&gt;
hp workstation xw4200, 3GB&lt;BR /&gt;
quadro fx1400&lt;BR /&gt;
AutoCAD 2007, 3DSMax 8.0 SP 2</description>
      <pubDate>Mon, 26 Jun 2006 06:26:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-with-jig/m-p/1685911#M81278</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-26T06:26:31Z</dc:date>
    </item>
  </channel>
</rss>

