Author Topic: Drag jitters  (Read 16040 times)

0 Members and 1 Guest are viewing this topic.

TonyT

  • Guest
Re: Drag jitters
« Reply #15 on: August 01, 2006, 03:50:00 AM »
For the first item - duplicate items - I have added this at the end of the ForEach SelectedObject loop:

transformedEntity.SwapIdWith(selectedEntity.ObjectId, true, true);
selectedEntity.Erase();

In my example code you see that I insert the block using VBA then drag it. I insert at 0,0,0 just to get it onto the drawing. When I run the code I get a block at 0,0,0 and one on the end of my cursor.
With regular AutoCAD INSERT command I insert a block and I only have the one on the cursor. A small issue and one that could be solved with a hack.

Hi Mark. 

It looks like you're using the Drag() overload that wraps acedDragGen().

The problem there is that acedDragGen() wasn't really designed to
drag new objects (e.g., the way the INSERT command works), but
rather, existing objects in the database (e.g., the way the MOVE
command works).

If your app works kind-a like the INSERT command, then you should
not be using the acedDragGen() wrapper. Rather you should use the
wrapper for AcEdJig (which is designed for dragging new objects). 

If you were using the AcEdJig wrapper, there would be no need to
create an insertion of the block in the drawing first, and hence, no
need for the swapIdWith() or any other kludge.

The sample code at the URL below works for me, and shows how
to do dragging of new, non-database resident objects properly.

     http://www.caddzone.com/InsertJig.cs


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Drag jitters
« Reply #16 on: August 01, 2006, 04:54:53 AM »
Welcome to TheSwamp Tony.

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.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: Drag jitters
« Reply #17 on: August 01, 2006, 05:38:21 AM »
Hi, Tony!
I am glad to see you here!  :-)

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters
« Reply #18 on: August 01, 2006, 01:11:43 PM »
Tony,
Thank you SO much for that. I had a feeling that I was trying to use a wrench for a hammer.
I tried the code and it worked great. I did have to make one small correction. In the SamplerStatus override there is a line that the compiler didn't like:
JigPromptOptions jigOpts = new JigPromptOptions();
It couldn't create an instance of an abstract class.

I changed it to:
JigPromptPointOptions jigOpts = new JigPromptPointOptions();
That seemed to work.

That should make a nice part of the "Programming AutoCAD .NET" section of your caddzone.com website.

Well, I'm not finished with this but other issues will get their own threads.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

TonyT

  • Guest
Re: Drag jitters
« Reply #19 on: August 01, 2006, 02:01:59 PM »
Kerry and Alex Thanks!

Welcome to TheSwamp Tony.



mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Drag jitters
« Reply #20 on: August 04, 2006, 02:50:45 PM »
If it were my design, I wouldn't have the dragger do anything with either the original or the new entities.  In fact, I wouldn't even have it create any new db resident entities.  I would create an interface that would accept a basepoint and the original db resident ObjectId's.  It would start the drag operation and return the last matrix generated by the user. 

Code: [Select]
  public interface IComDragger
  {
     bool StartDrag(double[] basePoint, params int[] oldStyleObjectIds);

     double[] TransformationMatrix
     {
       get;
     }
  }

You would then create concrete classes that would implement the interface.  One class for following the cursor, another for rotation, and another for scaling.  You would need a factory to generate the appropriate class and return it as an instance of the interface.

Code: [Select]
  public class ComDraggers
  {
    public IComDragger FollowCursorDragger
    {
      get
      {
        return new FollowCursorDragger();
      }
    }

    public IComDragger ScaleDragger
    {
      get
      {
        return new ScaleDragger();
      }
    }

    public IComDragger RotateDragger
    {
      get
      {
        return new RotateDragger();
      }
    }
  }

The dragger classes would only be responsible for producing a ghosted image.  It would be up to the calling code to determine what, if anything, to do with the original entities using the matrix provided by the draggers.  The calling code would also be responsible for creating new entities if they were needed.

But that's just what I would do :-)

Bobby, on further investigation it is becoming clearer that what you suggest is really what I want.
Tony's code inserts a new block quite nicely. In my application I want to do things like insert a block that isn't in the current drawing (from file), fill out attribute values or put things on certain layers or edit them in some other way BEFORE I actually drag them.
Doing these things in VBA will make things much easier for me. I only really need the drag/jig functionality from .NET. I want to handle everything else from the ActiveX side of things.

The "Interface" concept is still beyond me but I'm willing and eager to learn. Would you mind adding some comments to your framework that might help me?

Thanks
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions