Author Topic: Drag jitters 2  (Read 14121 times)

0 Members and 1 Guest are viewing this topic.

Bryco

  • Water Moccasin
  • Posts: 1883
Drag jitters 2
« on: September 23, 2007, 07:54:18 PM »
Reading up   http://www.theswamp.org/index.php?topic=11340.msg143516#msg143516 I tried the two ways shown to drag. I want to draw a circle, that being a new entity I thought it would lend itself to EntityJig, but using both this and DrawJig give me say 10 degrees of the circle visible (1 oclock to 3 oclock) rather than the full monty. Does this happen to others?

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #1 on: September 24, 2007, 10:30:05 PM »
Same thing happens on my computor at work.

Does anyone else have a problem seeing a full circle as it is being dragged?

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters 2
« Reply #2 on: September 25, 2007, 11:53:10 AM »
What version of AutoCAD are you using?
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters 2
« Reply #3 on: September 25, 2007, 12:03:20 PM »
Same thing happens on my computor at work.

Does anyone else have a problem seeing a full circle as it is being dragged?
I had to change a few lines of code but that was probably due to AutoCAD version.

Yes, I also see only part of the circle.
It is the same problem that I mentioned in my original post. The jig image never stops redrawing and therefore never gets the  chance to redraw completely.
My original problem never really got resolved.
Funny thing, I was recently working on this problem again and the jig function was working fine. No jitters. I don't remember what happened but it reverted to the same old problem.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Drag jitters 2
« Reply #4 on: September 25, 2007, 12:44:48 PM »
I noticed with standard Acad commands that if you have running osnaps on then it will continue to redraw what you are dragging when the mouse moves, but if you turn them off and let it finish drawing the image of the object, it will always (almost depending on what all you have selected) be there.

Don't know if this applies to what you two are experiencing.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters 2
« Reply #5 on: September 25, 2007, 01:17:57 PM »
I noticed with standard Acad commands that if you have running osnaps on then it will continue to redraw what you are dragging when the mouse moves, but if you turn them off and let it finish drawing the image of the object, it will always (almost depending on what all you have selected) be there.

Don't know if this applies to what you two are experiencing.
The problem is the redraw keeps restarting even though the mouse is NOT moving.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Fatty

  • Guest
Re: Drag jitters 2
« Reply #6 on: September 25, 2007, 02:02:32 PM »
Just a shoot in the darkness... :|
take a look at WHIPTHREAD system variable

~'J'~

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters 2
« Reply #7 on: September 25, 2007, 03:32:06 PM »
Just a shoot in the darkness... :|
take a look at WHIPTHREAD system variable

~'J'~
mine is set to 1
setting it to 0 doesn't change the behavior

I did notice that using the CJIG command the full circle appears until you move your cursor. Then only part of the circle is shown.
« Last Edit: September 25, 2007, 03:34:36 PM by mohnston »
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Fatty

  • Guest
Re: Drag jitters 2
« Reply #8 on: September 25, 2007, 04:13:58 PM »
I have a got the same result
the circle was shown partially

~'J'~

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #9 on: September 25, 2007, 06:04:01 PM »
I'm doing this in 2006 at present.
Using the ellipsejig from the arx samples.net. I see no problem, the full ellipse shows all the time.
I also can't understand why they use an aligned dimension in the sample, it's almost like they are tricking it into showing.
Perhaps the update property of a dim does the tricking?
I'll try to convert that sample to a circle tonight.
Thanks for the replies, I was starting to wonder if the answer was so simple I shouldn't have asked.

Chuck Gabriel

  • Guest
Re: Drag jitters 2
« Reply #10 on: September 26, 2007, 08:52:18 AM »
Maybe you've got VIEWRES set too high.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #11 on: September 26, 2007, 10:24:11 AM »
Well viewres does indeed help, Chuck. For me a value of 10 worked for both the drawjig and entityjig method. However the circle looks like a decagon at that point, 50 started well but as the circle gets bigger it ends up about half bigger.
Here is the sample ellipse code that works.
I failed substituting the ellipse for a circle. It's a bit hard to follow as you can't really step through it.
I'ld love to know the purpose of  Dimension dim1 = new AlignedDimension();

Code: [Select]
// Copyright 2004 by Autodesk, Inc.
//
//Permission to use, copy, modify, and distribute this software in
//object code form for any purpose and without fee is hereby granted,
//provided that the above copyright notice appears in all copies and
//that both that copyright notice and the limited warranty and
//restricted rights notice below appear in all supporting
//documentation.
//
//AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
//AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
//MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
//DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
//UNINTERRUPTED OR ERROR FREE.
//
//Use, duplication, or disclosure by the U.S. Government is subject to
//restrictions set forth in FAR 52.227-19 (Commercial Computer
//Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
//(Rights in Technical Data and Computer Software), as applicable.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using System.Reflection;

using System.IO;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.GraphicsInterface;

//[assembly: CommandClass(typeof(JigSample.TestEntityJig))]


//This application implements a command called ellipsejig. It will help you
//create an ellipse from scratch by doing a jig. The user is first asked to
//enter the ellipse major axis followed by ellipse minor axis.

//To use ellipsejig.dll:
//1. Start AutoCAD and open a new drawing.
//2. Type netload and select ellipsejig.dll.
//3. Execute the ellipsejig command, defined by ellipsejig.dll.

//Please add the References acdbmgd.dll,acmgd.dll,
//Autodesk.AutoCAD.Interop.dll and Autodesk.AutoCAD.Interop.Common.dll
//before trying to build this project.

namespace JigSample
{
    public class TestEntityJig
    {
        class EllipseJig : EntityJig
        {
            Point3d mCenterPt, mAxisPt, acquiredPoint;
            Vector3d mNormal, mMajorAxis;
            double mRadiusRatio;

            int mPromptCounter;

            DynamicDimensionDataCollection m_dims;

            public EllipseJig(Point3d center, Vector3d vec)
                : base(new Ellipse())
            {
                mCenterPt = center;
                mNormal = vec;
                mRadiusRatio = 0.00001;
                mPromptCounter = 0;

                m_dims = new DynamicDimensionDataCollection();
                Dimension dim1 = new AlignedDimension();
                dim1.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim1, true, true));

                Dimension dim2 = new AlignedDimension();
                dim2.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim2, true, true));

            }

            protected override SamplerStatus Sampler(JigPrompts prompts)
            {
                JigPromptOptions jigOpts = new JigPromptOptions();
                jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted);

                if (mPromptCounter == 0)
                {
                    jigOpts.Message = "\nEllipse Major axis:";
                    PromptPointResult dres = prompts.AcquirePoint(jigOpts);

                    Point3d axisPointTemp = dres.Value;
                    if (axisPointTemp != mAxisPt)
                    {
                        mAxisPt = axisPointTemp;
                    }
                    else
                        return SamplerStatus.NoChange;

                    if (dres.Status == PromptStatus.Cancel)
                        return SamplerStatus.Cancel;
                    else
                        return SamplerStatus.OK;


                }
                else if (mPromptCounter == 1)
                {
                    jigOpts.BasePoint = mCenterPt;
                    jigOpts.UseBasePoint = true;
                    jigOpts.Message = "\nEllipse Minor axis:";
                    double radiusRatioTemp = -1;
                    PromptPointResult res = prompts.AcquirePoint(jigOpts);
                    acquiredPoint = res.Value;
                    radiusRatioTemp = mCenterPt.DistanceTo(acquiredPoint);

                    if (radiusRatioTemp != mRadiusRatio)
                        mRadiusRatio = radiusRatioTemp;
                    else
                        return SamplerStatus.NoChange;

                    if (res.Status == PromptStatus.Cancel)
                        return SamplerStatus.Cancel;
                    else
                        return SamplerStatus.OK;

                }
                else
                {
                    return SamplerStatus.NoChange;
                }


            }
            protected override bool Update()
            {
                double radiusRatio = 1.0;
                switch (mPromptCounter)
                {
                    case 0:
                        // At this time, mAxis contains the value of one
                        // endpoint of the desired major axis.  The
                        // AcDbEllipse class stores the major axis as the
                        // vector from the center point to where the axis
                        // intersects the ellipse path (such as half of the true
                        // major axis), so we already have what we need.
                        //
                        mMajorAxis = mAxisPt - mCenterPt;
                        break;
                    case 1:
                        // Calculate the radius ratio.  mRadiusRatio
                        // currently contains the distance from the ellipse
                        // center to the current pointer position.  This is
                        // half of the actual minor axis length.  Since
                        // AcDbEllipse stores the major axis vector as the
                        // vector from the center point to the ellipse curve
                        // (half the major axis), to get the radius ratio we
                        // simply divide the value currently in mRadiusRatio
                        // by the length of the stored major axis vector.
                        //

                        radiusRatio = mRadiusRatio / mMajorAxis.Length;
                        break;
                }

                try
                {
                    ((Ellipse)Entity).Set(mCenterPt, new Vector3d(0, 0, 1), mMajorAxis, radiusRatio, 0.0, 6.28318530717958647692);
                    UpdateDimensions();

                }
                catch (System.Exception)
                {
                    return false;
                }

                return true;

            }
            protected override DynamicDimensionDataCollection GetDynamicDimensionData(double dimScale)
            {
                return m_dims;
            }
            protected override void OnDimensionValueChanged(Autodesk.AutoCAD.DatabaseServices.DynamicDimensionChangedEventArgs e)
            {

            }
            void UpdateDimensions()
            {
                if (mPromptCounter == 0)
                {
                    Ellipse myellipse = (Ellipse)Entity;
                    AlignedDimension dim = (AlignedDimension)m_dims[0].Dimension;
                    dim.XLine1Point = myellipse.Center;
                    dim.XLine2Point = mAxisPt;
                    dim.DimLinePoint = myellipse.Center;
                }
                else
                {
                    Ellipse myellipse = (Ellipse)Entity;
                    AlignedDimension dim2 = (AlignedDimension)m_dims[1].Dimension;
                    dim2.XLine1Point = myellipse.Center;
                    dim2.XLine2Point = acquiredPoint;
                    dim2.DimLinePoint = myellipse.Center;
                }

            }
            public void setPromptCounter(int i)
            {
                mPromptCounter = i;
            }
            public Entity GetEntity()
            {
                return Entity;
            }

        }
        [CommandMethod("ellipsejig")]
        static public void DoIt()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions opts = new PromptPointOptions("\nEnter Ellipse Center Point:");
            PromptPointResult res = ed.GetPoint(opts);

            Vector3d x = Application.DocumentManager.MdiActiveDocument.Database.Ucsxdir;
            Vector3d y = Application.DocumentManager.MdiActiveDocument.Database.Ucsydir;
            Vector3d NormalVec = x.CrossProduct(y);


            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;

            //Create Ellipsejig
            EllipseJig jig = new EllipseJig(res.Value, NormalVec.GetNormal());
            //first call drag to get the major axis
            jig.setPromptCounter(0);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);
            // Again call drag to get minor axis
            jig.setPromptCounter(1);
            Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig);

            //Append entity.
            using (Transaction myT = tm.StartTransaction())
            {
                BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead, false);
                BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
                btr.AppendEntity(jig.GetEntity());
                tm.AddNewlyCreatedDBObject(jig.GetEntity(), true);
                myT.Commit();
            }


        }
    }

}

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters 2
« Reply #12 on: September 26, 2007, 12:53:29 PM »
Viewres did not help.
The objects I'm dragging have no arcs.

In the code that does the inserting I noticed a line that checks to see if the cursor has moved.
Code: [Select]
if (position.DistanceTo(curPoint) > 1.0e-4)When dragging I can take my hand completely off the mouse and the image continues to flicker as if the sampler fires regardless of cursor movement.
In normal AutoCAD operation when a entities are dragged and you stop your cursor movement the image eventually catches up and is stable until the cursor moves again.
« Last Edit: September 26, 2007, 12:54:43 PM by mohnston »
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #13 on: September 26, 2007, 05:52:31 PM »
Mark that's another thing I can't get the grip of.
Point3d axisPointTemp = dres.Value;
if (axisPointTemp != mAxisPt)
{mAxisPt = axisPointTemp;}
this sequence from the ellipsejig compares mousepoints and if not the same changes the field (vba module level variable), if there is no change
I guess the update function must take care of it.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Drag jitters 2
« Reply #14 on: September 26, 2007, 06:10:40 PM »
From a graphical point of view, the application needs to tell the object to update and draw itself based on the current position as the mouse moves (the OnMouseMove() event say), when the mouse is not moving the app shouldn't call update/draw.
I'd imagine this all happens while the jig has a certain status set. If it is still sending messages to update/draw when the mouse isn't moving it will cause flickering or missing pixels as the frame buffer is continually swapping/updating itself which an 'interactive' application like acad doesn't handle so well.
I'd be looking for some flag or similar that controls the update of the image and make sure it's being used correctly.
Not much help but something to think about perhaps.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Glenn R

  • Guest
Re: Drag jitters 2
« Reply #15 on: September 26, 2007, 08:39:01 PM »
The 'aligned dimension' is for the dynamic dimensions that appear when you are creating objects (the DYN button in the application statusbar).

Glenn R

  • Guest
Re: Drag jitters 2
« Reply #16 on: September 26, 2007, 08:40:56 PM »
There ya go mate:

Code: [Select]
// (C) Copyright 2002-2007 by TCGSoftware.

using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(Bryco.tcgsBrycoJiggy))]

namespace Bryco {
/// <summary>
/// Summary description for tcgsClass.
/// </summary>
public class tcgsBrycoJiggy {
/// <summary>
/// Default ctor.
/// </summary>
public tcgsBrycoJiggy( ) {
// Does nothing in this implementation.
}

#region Circle jigging class
/// <summary>
/// Circle jig class to allow jigging of circle
/// </summary>
public class CircleJig : EntityJig {

private Point3d _centerPt, _radiusPt;
private Vector3d _normal;

private ObjectId _dashLtId = ObjectId.Null;
private double _radius;

private DynamicDimensionDataCollection _dims;

public CircleJig(Point3d centre, Vector3d vec, ObjectId dashLtId) : base(new Circle()) {
_centerPt = centre;
_normal = vec;
_dashLtId = dashLtId;

_dims = new DynamicDimensionDataCollection();
Dimension dim1 = new AlignedDimension();
dim1.SetDatabaseDefaults();
_dims.Add(new DynamicDimensionData(dim1, true, true));

}

public double Radius {
get { return _centerPt.DistanceTo(_radiusPt); }
}

protected override SamplerStatus Sampler(JigPrompts prompts) {
JigPromptOptions jigOpts = new JigPromptOptions();
jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates |
UserInputControls.NoZeroResponseAccepted |
UserInputControls.NoNegativeResponseAccepted);

//*******************************************************************
// Required by 2007 - changed name from line above
//JigPromptPointOptions jigOpts = new JigPromptPointOptions();
//jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates |
// UserInputControls.NoZeroResponseAccepted |
// UserInputControls.NoNegativeResponseAccepted);
//*******************************************************************

jigOpts.Message = "\nSpecify radius of circle:";
jigOpts.BasePoint = _centerPt;
jigOpts.UseBasePoint = true;
jigOpts.Cursor = CursorType.RubberBand;
PromptPointResult dres = prompts.AcquirePoint(jigOpts);


Point3d radiusPointTemp = dres.Value;
if(radiusPointTemp != _radiusPt) {
_radiusPt = radiusPointTemp;
} else
return SamplerStatus.NoChange;

if(dres.Status == PromptStatus.Cancel)
return SamplerStatus.Cancel;
else
return SamplerStatus.OK;

}

protected override bool Update( ) {
_radius = _radiusPt.DistanceTo(_centerPt);

try {
((Circle)Entity).Center = _centerPt;
((Circle)Entity).Radius = _radius;
((Circle)Entity).LinetypeId = _dashLtId;
UpdateDimensions();

} catch(System.Exception) {
return false;
}

return true;

}

protected override DynamicDimensionDataCollection GetDynamicDimensionData(double dimScale) {
return _dims;
}

protected override void OnDimensionValueChanged(Autodesk.AutoCAD.DatabaseServices.DynamicDimensionChangedEventArgs e) {
// base.OnDimensionValueChanged(e);
}

void UpdateDimensions( ) {
Circle myCircle = (Circle)Entity;
AlignedDimension dim = (AlignedDimension)_dims[0].Dimension;
dim.XLine1Point = myCircle.Center;
dim.XLine2Point = _radiusPt;

Vector3d xvec = dim.XLine2Point - dim.XLine1Point;
xvec = xvec.GetNormal();
Vector3d zvec = myCircle.Normal;
zvec = zvec.GetNormal();
Vector3d yvec = zvec.CrossProduct(xvec);
yvec = yvec.GetNormal();

yvec *= myCircle.Radius / 2;

dim.DimLinePoint = myCircle.Center + yvec;
}

public Entity GetEntity( ) {
return Entity;
}

}// class CircleJig

#endregion


#region Command Declarations

// Define Command "BrycesRidgyDidgeCircle"
[CommandMethod("BrycesRidgyDidgeCircle")]
public void BrycesRidgyDidgeCircleCommand( ) {

Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;

Transaction tr = null;

try {

tr = db.TransactionManager.StartTransaction();

// Set up the prompting...
PromptPointOptions opts = new PromptPointOptions("\nSpecify centre point for circle:");
PromptPointResult res = ed.GetPoint(opts);

// Calulate our normal vector...
Vector3d NormalVec;

if(IsPaperSpace(db)) {
Vector3d x = db.Pucsxdir;
Vector3d y = db.Pucsydir;
NormalVec = x.CrossProduct(y);
} else {
Vector3d x = db.Ucsxdir;
Vector3d y = db.Ucsydir;
NormalVec = x.CrossProduct(y);
}

Point3d pickPt = res.Value.TransformBy(GetUcsMatrix(db));

//Create Circle jig...
CircleJig jig = new CircleJig(pickPt, NormalVec.GetNormal(), db.ContinuousLinetype);
//first call drag to get the radius
if(ed.Drag(jig).Status != PromptStatus.OK)
return;

BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, false) as BlockTableRecord;
btr.AppendEntity(jig.GetEntity());
jig.GetEntity().Draw();
tr.AddNewlyCreatedDBObject(jig.GetEntity(), true);

tr.Commit();

} catch(System.Exception ex) {
tr.Abort();
ed.WriteMessage("\nError: " + ex.Message);
} finally {
if(tr != null) {
tr.Dispose();
}
}

}

#endregion

#region Function to return the current UCS matrix

private Matrix3d GetUcsMatrix(Database db) {

Point3d origin;
Vector3d xAxis, yAxis, zAxis;

if(IsPaperSpace(db)) {
origin = db.Pucsorg;
xAxis = db.Pucsxdir;
yAxis = db.Pucsydir;
} else {
origin = db.Ucsorg;
xAxis = db.Ucsxdir;
yAxis = db.Ucsydir;
}

zAxis = xAxis.CrossProduct(yAxis);

return Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
origin, xAxis, yAxis, zAxis);
}//GetUcsMatrix

#endregion

#region Function to check if we're in Paperspace

private bool IsPaperSpace(Database db) {
if(db.TileMode)
return false;

Document doc = acadApp.DocumentManager.GetDocument(db);
Editor ed = doc.Editor;

if(db.PaperSpaceVportId == ed.CurrentViewportObjectId)
return true;

return false;
}//IsPaperSpace

#endregion
}
}

I'm still not happy with the dynamic dimension that shows up - it doesn't seem to be editable like the AutoCAD circle one is.
Somebody else might be able to fill that bit in.

Cheers,
Glenn.
« Last Edit: September 26, 2007, 10:02:45 PM by Glenn R »

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #17 on: September 26, 2007, 11:02:59 PM »
Beauty, it's a ripper. Now to try figure out why it works.

Glenn R

  • Guest
Re: Drag jitters 2
« Reply #18 on: September 26, 2007, 11:06:17 PM »
You're welcome. Compare them side by side, so to speak - something will leap out.
Let us know what you find.

Cheers,

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #19 on: September 27, 2007, 12:35:26 AM »
First up, peanuts are in order.
It's a difficult for me getting the whole concept.
1)public CircleJig(Point3d centre, Vector3d vec, ObjectId dashLtId)
                : base(new Circle())
Seeing the new word, I imagine we are making a new circle here (not sure at all.) and because we are in an Entity jig perhaps there is a circle added to the current space at this time, that doesn't need a radius value (perhaps it is zero)
2) public Entity GetEntity() is this exposing the Protected internal entity from the jig?

Glenn R

  • Guest
Re: Drag jitters 2
« Reply #20 on: September 27, 2007, 12:41:57 AM »
1. CircleJig is derived from EntityJig hence you see a call like so:
Code: [Select]
:base(new Circle())

This is a call to the base class's constructor. If you were to look up the constructor for EntityJig, you would find that it requires a DatabaseServices.Entity. The 'new' keyword is creating a circle, but it's NOT database resident and is handled and used by the EntityJig class for graphical purposes amongst other things.

2. yes - spot on.

LE

  • Guest
Re: Drag jitters 2
« Reply #21 on: September 27, 2007, 11:15:55 AM »
How about if we use (using Glenn class):

Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedGrDraw")]
public

Code: [Select]
void UpdateDimensions()
{
    Circle myCircle = (Circle)Entity;
    //AlignedDimension dim = (AlignedDimension)_dims[0].Dimension;
    //dim.XLine1Point = myCircle.Center;
    //dim.XLine2Point = _radiusPt;

    Point3d ctr = myCircle.Center, radiusPt = _radiusPt;
    double[] fromPoint = new double[2], toPoint = new double[2];
    fromPoint[0] = ctr.X;
    fromPoint[1] = ctr.Y;
    fromPoint[2] = ctr.Z;
    toPoint[0] = radiusPt.X;
    toPoint[1] = radiusPt.Y;
    toPoint[2] = radiusPt.Z;
    acedGrDraw(fromPoint, toPoint, 7, 7);

    //Vector3d xvec = dim.XLine2Point - dim.XLine1Point;
    //xvec = xvec.GetNormal();
    //Vector3d zvec = myCircle.Normal;
    //zvec = zvec.GetNormal();
    //Vector3d yvec = zvec.CrossProduct(xvec);
    //yvec = yvec.GetNormal();

    //yvec *= myCircle.Radius / 2;

    //dim.DimLinePoint = myCircle.Center + yvec;
}
« Last Edit: September 27, 2007, 11:19:16 AM by LE »

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #22 on: September 27, 2007, 04:32:17 PM »
I'll look at that tonight Luis.

Glenn R

  • Guest
Re: Drag jitters 2
« Reply #23 on: September 27, 2007, 07:40:02 PM »
How about if we use (using Glenn class):

Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedGrDraw")]
public

Code: [Select]
void UpdateDimensions()
{
    Circle myCircle = (Circle)Entity;
    //AlignedDimension dim = (AlignedDimension)_dims[0].Dimension;
    //dim.XLine1Point = myCircle.Center;
    //dim.XLine2Point = _radiusPt;

    Point3d ctr = myCircle.Center, radiusPt = _radiusPt;
    double[] fromPoint = new double[2], toPoint = new double[2];
    fromPoint[0] = ctr.X;
    fromPoint[1] = ctr.Y;
    fromPoint[2] = ctr.Z;
    toPoint[0] = radiusPt.X;
    toPoint[1] = radiusPt.Y;
    toPoint[2] = radiusPt.Z;
    acedGrDraw(fromPoint, toPoint, 7, 7);

    //Vector3d xvec = dim.XLine2Point - dim.XLine1Point;
    //xvec = xvec.GetNormal();
    //Vector3d zvec = myCircle.Normal;
    //zvec = zvec.GetNormal();
    //Vector3d yvec = zvec.CrossProduct(xvec);
    //yvec = yvec.GetNormal();

    //yvec *= myCircle.Radius / 2;

    //dim.DimLinePoint = myCircle.Center + yvec;
}

Not going to work Luis, as that call to acedGrDraw is just going to draw a vector - you need to draw the dimension with extension lines just like AutoCAD does.

LE

  • Guest
Re: Drag jitters 2
« Reply #24 on: September 27, 2007, 09:19:04 PM »
Not going to work Luis, as that call to acedGrDraw is just going to draw a vector - you need to draw the dimension with extension lines just like AutoCAD does.

I guess, I missread the original request..... and do not use the dyn stuff - slap on my face sorry...  :oops:

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #25 on: September 27, 2007, 10:05:25 PM »
KnownasLuis has a great ring to it.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #26 on: September 27, 2007, 11:17:22 PM »
The way things go, my next step was to apply this to all the different kinds of entities. Line worked without a hitch until I looked at the dynamic dims (never have used those things personally). so now I have a whole new field of pain to investigate.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Drag jitters 2
« Reply #27 on: September 28, 2007, 11:14:58 AM »
KnownasLuis has a great ring to it.
I was almost expecting "TheCoderFormerlyKnownAsLuis" :-)

LE

  • Guest
Re: Drag jitters 2
« Reply #28 on: September 28, 2007, 01:35:40 PM »
KnownasLuis has a great ring to it.
I was almost expecting "TheCoderFormerlyKnownAsLuis" :-)

That's a great suggestion.... granted! (and thanks)  :)

Was a good suggestion, but the name is too long and does not appear in full .... so, went back to the previous one....  :-P
« Last Edit: September 28, 2007, 01:55:10 PM by KnownAsLuis »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Drag jitters 2
« Reply #29 on: September 28, 2007, 01:45:31 PM »
How about WillDeletePostsForFood?

:lmao:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

LE

  • Guest
Re: Drag jitters 2
« Reply #30 on: September 28, 2007, 01:47:39 PM »
How about WillDeletePostsForFood?

:lmao:

I can make (good) money doing that..... for sure!

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Drag jitters 2
« Reply #31 on: October 02, 2007, 01:26:01 AM »
I've stalled on the arc jig at present.
As far as I can tell the startangle is the angle from the Center point from 0,0 to the arc startpoint.
However when you get into odd ucs's, I've found the angle is more like the angle from the center to the ocs xaxis vector to the startpoint. (This is how the blockrotation works), however sometimes I need to add pi, Still working on that.
Any thoughts?
« Last Edit: October 02, 2007, 01:27:04 AM by Bryco »