Author Topic: How to use the DrawVectors function?  (Read 8883 times)

0 Members and 1 Guest are viewing this topic.

csharpbird

  • Newt
  • Posts: 64
How to use the DrawVectors function?
« on: October 30, 2008, 12:26:54 PM »
public void DrawVectors(
    ResultBuffer rb,
    Matrix3d transform
);

How to use?
Thanks in advance!

TonyT

  • Guest
Re: How to use the DrawVectors function?
« Reply #1 on: October 30, 2008, 05:37:24 PM »
public void DrawVectors(
    ResultBuffer rb,
    Matrix3d transform
);

How to use?
Thanks in advance!

See the docs for acedGrVecs() or the (grvecs) LISP function.

csharpbird

  • Newt
  • Posts: 64
Re: How to use the DrawVectors function?
« Reply #2 on: October 30, 2008, 10:35:13 PM »
Code: [Select]
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            TypedValue[] values = { new TypedValue((int)DxfCode.Color,1),
                                    new TypedValue((int)DxfCode.XCoordinate,new Point3d(0,0,0)),
                                    new TypedValue((int)DxfCode.XCoordinate,new Point3d(100,100,0))
                                  };
            ResultBuffer buffer = new ResultBuffer(values);
            ed.DrawVectors(buffer, Matrix3d.Identity);
No Effect!!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use the DrawVectors function?
« Reply #3 on: October 31, 2008, 04:17:54 AM »


Should that be in this order .. ?
StartPoint,
Endpoint,
Color

?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

csharpbird

  • Newt
  • Posts: 64
Re: How to use the DrawVectors function?
« Reply #4 on: October 31, 2008, 05:19:37 AM »


Should that be in this order .. ?
StartPoint,
Endpoint,
Color

?

No effect.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use the DrawVectors function?
« Reply #5 on: October 31, 2008, 07:00:56 AM »

I'll have a look ... Give me a little while ...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use the DrawVectors function?
« Reply #6 on: October 31, 2008, 07:16:54 AM »
Have a play with something like this perhaps ...
Code: [Select]
namespace kdub.Testing.Commands
{
    /// <summary>
    /// Summary description for TestCommands Class.
    /// </summary>
    public class TestCommands
    {
        // CodeHimBelonga kwb@theSwamp 20081031
        //
        [CommandMethod("Cmd1")]
        static public void test()
        {           
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            // create  a new resbuf
            ResultBuffer resBuff = new ResultBuffer();
            // create a start point, end point, then color -
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(0.0, 0.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(100, 100,0)));
 
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(100.0, 100.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200, 100, 0)));

            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200.0, 100.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200, 200, 0)));
            resBuff.Add(new TypedValue((int)DxfCode.Color, 1));

            ed.DrawVectors(resBuff, Matrix3d.Identity);

        }
    }
}

and a piccy to titillate the senses ...

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

csharpbird

  • Newt
  • Posts: 64
Re: How to use the DrawVectors function?
« Reply #7 on: October 31, 2008, 08:54:33 AM »
Seems the following
resBuff.Add(new TypedValue((int)DxfCode.Color, 1));
should be:
resBuff.Add(new TypedValue((int)LispDataType.Int16, 1));
« Last Edit: October 31, 2008, 09:12:05 AM by csharpbird »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use the DrawVectors function?
« Reply #8 on: October 31, 2008, 06:08:13 PM »
From the docs
Quote
Result-buffer elements in the vlist can be as follows:

A pair of points (RTPOINT or RT3DPOINT) that specify the endpoints of the vector, expressed in the current UCS; these can be three-dimensional points.
Note You must pass these points as pairs--that is, in two successive result buffers--or the acedGrVecs() call will fail.

A color value that applies to all succeeding vectors until vlist specifies another color. The color is specified as a short integer (RTSHORT). AutoCAD colors are in the range 0-255. If the color value is greater than 255, succeeding vectors are drawn in XOR ink, which complements anything it draws over and erases itself when overdrawn. If the color value is less than 0, the vector is highlighted.


.. so yes, the color should be LispDataType.Int16, or RTSHORT's value of 5003

The Points can be either
LispDataType.Point3d  .. (5009 .. RT3DPOINT)
or
LispDataType.Point2d  .. (5002 .. RTPOINT )
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use the DrawVectors function?
« Reply #9 on: October 31, 2008, 06:15:02 PM »
also. I note that if the color is added prior to the points the nominated color will be used.

Code: [Select]
             ResultBuffer resBuff = new ResultBuffer();
           
            resBuff.Add(new TypedValue((int)LispDataType.Int16, 1));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(0.0, 0.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(100, 100,0)));
            resBuff.Add(new TypedValue((int)LispDataType.Int16, 2));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(100.0, 100.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200, 100, 0)));
            resBuff.Add(new TypedValue((int)LispDataType.Int16, 3));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200.0, 100.0, 0.0)));
            resBuff.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(200, 200, 0)));

            ed.DrawVectors(resBuff, Matrix3d.Identity);


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TonyT

  • Guest
Re: How to use the DrawVectors function?
« Reply #10 on: November 01, 2008, 01:43:02 AM »
Kerry seems to have unraveled that for you.

FWIW, DrawVectors/acedGrVecs is legacy, and that's probably why
you can only draw using the 256 colors.

In ObjectARX, you can use the Editor's MonitorInputPoint event to
draw temporary graphics as well, and you're not limited to drawing
only vectors or to 256 colors, and they aren't wiped out by a REDRAW.

Code: [Select]
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            TypedValue[] values = { new TypedValue((int)DxfCode.Color,1),
                                    new TypedValue((int)DxfCode.XCoordinate,new Point3d(0,0,0)),
                                    new TypedValue((int)DxfCode.XCoordinate,new Point3d(100,100,0))
                                  };
            ResultBuffer buffer = new ResultBuffer(values);
            ed.DrawVectors(buffer, Matrix3d.Identity);
No Effect!!

sinc

  • Guest
Re: How to use the DrawVectors function?
« Reply #11 on: November 01, 2008, 12:06:19 PM »
Do you mean Editor.PointMonitor?  How do you use that, Tony?  What methods do we use to draw the temporary graphics, and how do the temporary graphics get removed when we're finished with them?

Spike Wilbury

  • Guest
Re: How to use the DrawVectors function?
« Reply #12 on: November 01, 2008, 01:55:41 PM »
Do you mean Editor.PointMonitor?  How do you use that, Tony?  What methods do we use to draw the temporary graphics, and how do the temporary graphics get removed when we're finished with them?

Something like: ?

Code: [Select]
PointMonitorEventArgs e

Circle circle = new Circle(e.Context.RawPoint, Vector3d.ZAxis, 10);

e.Context.DrawContext.Geometry.Draw(circle);

circle.Radius = 20;

e.Context.DrawContext.Geometry.Draw(circle);

sinc

  • Guest
Re: How to use the DrawVectors function?
« Reply #13 on: November 01, 2008, 02:59:48 PM »
Yeah, like that...  Thanks!

Spike Wilbury

  • Guest
Re: How to use the DrawVectors function?
« Reply #14 on: November 01, 2008, 03:25:48 PM »
Yeah, like that...  Thanks!

Sinc,

Have a look at this url link (I guess was posted here too, but forgot where it is):

http://through-the-interface.typepad.com/through_the_interface/2007/11/devtv-introduct.html

(Introduction to AutoCAD .NET Programming - includes the SLN if I recall)
« Last Edit: November 01, 2008, 03:29:12 PM by Esquivel »