Author Topic: Ac2009 and Jigs  (Read 3107 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8698
  • AKA Daniel
Ac2009 and Jigs
« on: August 14, 2008, 03:46:53 AM »
Anyone having any problems with jigs in 2009? I have one that works in 08 but not 09

this pic from 08.. nothing to show in 09


vegbruiser

  • Guest
Re: Ac2009 and Jigs
« Reply #1 on: August 14, 2008, 04:03:47 AM »
The jig code that Kean posted here seems to work for me. Although I couldn't figure out how to add a rotation to it, so I used a different approach for my layout creation tool.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8698
  • AKA Daniel
Re: Ac2009 and Jigs
« Reply #2 on: August 14, 2008, 04:09:58 AM »
Thanks I give this a try.  I wonder why mine works fine in 07 & 08 but I can't see it in 09 (except for breif flashes)


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8698
  • AKA Daniel
Re: Ac2009 and Jigs
« Reply #3 on: August 14, 2008, 04:14:01 AM »
here is my code

//ParamDictionary dict is just a list of points I give to a rectangle class

Code: [Select]
public class CabJig : DrawJig, IDisposable
  {
    // Fields
    private Point3d currentCursorPosition;
    private bool disposed;
    private Editor editor;
    private Rectangle entityToDrag;
    private Point3d previousCursorPosition;

    // Constructors
    private CabJig()
    {
    }

    public CabJig(ref ParamDictionary dict)
    {
      this.previousCursorPosition = new Point3d(0.0, 0.0, 0.0);
      this.entityToDrag = new Rectangle(ref dict);
      this.entityToDrag.Color = Color.FromColorIndex(ColorMethod.ByAci, 10);
      this.editor = Application.DocumentManager.MdiActiveDocument.Editor;
    }

    // Methods
    private bool CursorHasMoved()
    {
      return !(this.currentCursorPosition == this.previousCursorPosition);
    }

    public void Dispose()
    {
      this.Dispose(true);
      GC.SuppressFinalize(this);
    }

    private void Dispose(bool disposing)
    {
      if (!this.disposed)
      {
        if (disposing)
        {
          this.entityToDrag.Dispose();
        }
        this.disposed = true;
      }
    }

    protected override SamplerStatus Sampler(JigPrompts prompts)
    {
      PromptPointResult userFeedback = prompts.AcquirePoint("\nSpecify insertion point:");
      this.currentCursorPosition = userFeedback.Value;
      if (this.CursorHasMoved())
      {
        this.entityToDrag.DrawFrom(this.currentCursorPosition);
        this.previousCursorPosition = this.currentCursorPosition;
        return SamplerStatus.OK;
      }
      return SamplerStatus.NoChange;
    }

    public Point3d StartJig()
    {
      if (this.editor.Drag(this).Status != PromptStatus.OK)
      {
        throw new System.Exception();
      }
      return this.currentCursorPosition;
    }

    protected override bool WorldDraw(WorldDraw draw)
    {
      draw.Geometry.Draw(this.entityToDrag);
      return true;
    }
  }

vegbruiser

  • Guest
Re: Ac2009 and Jigs
« Reply #4 on: August 14, 2008, 04:20:25 AM »
Also, you might want to use the updated code that's about halfway down the page (if you want to use Annotation scales and Attributes in the inserted block that is) :)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8698
  • AKA Daniel
Re: Ac2009 and Jigs
« Reply #5 on: August 19, 2008, 02:04:25 AM »
My problem was caused by this bug in .NET 3.5 SP1
http://discussion.autodesk.com/thread.jspa?threadID=685493