Author Topic: Is this a Bug in AutoCAD 2009?  (Read 1879 times)

0 Members and 1 Guest are viewing this topic.

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Is this a Bug in AutoCAD 2009?
« on: August 14, 2008, 01:17:41 pm »
Can someone run this code in  07 or 08 then in 09, and let me know if you see any differences?
Donít worry it wonít crash  :-o

Code: [Select]
#region #Using delarations
using System;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;

using AcAp = Autodesk.AutoCAD.ApplicationServices;
using AcDb = Autodesk.AutoCAD.DatabaseServices;

#endregion

[assembly: CommandClass(typeof(ExecMethod.Commands))]

namespace ExecMethod
{
  public class Commands
  {
    [CommandMethod("doit")]
    public static void doit()
    {
      Editor editor = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
      Database database = HostApplicationServices.WorkingDatabase;
      AcDb.TransactionManager manager = database.TransactionManager;

      Polyline pl = new Polyline(4);

      Point2d pt1 = new Point2d(0,0);
      Point2d pt2 = new Point2d(0,100);
      Point2d pt3 = new Point2d(100,100);
      Point2d pt4 = new Point2d(100,0);

      pl.AddVertexAt(0, pt1, 0, 0, 0);
      pl.AddVertexAt(1, pt2, 0, 0, 0);
      pl.AddVertexAt(2, pt3, 0, 0, 0);
      pl.AddVertexAt(3, pt4, 0, 0, 0);
      pl.Closed = true;

      Vector2d move = new Vector2d(1000, 1000);

      using(Transaction transaction = manager.StartTransaction())
      {
        ObjectId modelSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(database);
        BlockTableRecord record = transaction.GetObject(modelSpaceId, OpenMode.ForWrite) as BlockTableRecord;
        ObjectId mylineId = record.AppendEntity(pl);
        transaction.AddNewlyCreatedDBObject(pl, true);

        Polyline myLine = transaction.GetObject(mylineId, OpenMode.ForWrite) as Polyline;

        myLine.SetPointAt(0, pt1.Add(move));
        myLine.SetPointAt(1, pt2.Add(move));
        myLine.SetPointAt(2, pt3.Add(move));
        myLine.SetPointAt(3, pt4.Add(move));

        transaction.Commit();
      }
    }
  }
}

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #1 on: August 14, 2008, 01:20:32 pm »
here is the dll

Nick Schuckert

  • Newt
  • Posts: 31
Re: Is this a Bug in AutoCAD 2009?
« Reply #2 on: August 14, 2008, 01:33:51 pm »
I netloaded ExecMethod2.dll and executed DoIt from 08 and 09 and didn't see any differences. End result was a nice square box in both 08 and 09.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Is this a Bug in AutoCAD 2009?
« Reply #3 on: August 14, 2008, 03:19:38 pm »
Are you targetting any particular framework with that dll Dan? ie I have every framework known to man and every version of Acad from '06 upwards..........
Me

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #4 on: August 14, 2008, 07:49:45 pm »
I netloaded ExecMethod2.dll and executed DoIt from 08 and 09 and didn't see any differences. End result was a nice square box in both 08 and 09.

Thanks for testing this
 In 09 , I get a donít get a box, I get a line

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #5 on: August 14, 2008, 07:50:23 pm »
Are you targetting any particular framework with that dll Dan? ie I have every framework known to man and every version of Acad from '06 upwards..........

just installed .net 3.5 SP1, but I donít know if thatís the cause yet.
« Last Edit: August 14, 2008, 08:36:47 pm by Daniel »

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #6 on: August 15, 2008, 05:19:02 am »
Well, I have done everything I can think of (including reinstalling AutoCAD) but this code still fails on my computer. Hmm


nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #7 on: August 15, 2008, 05:45:58 am »
Ok, I think I have it narrowed down to  ďPoint2d.Add(Vector2d)Ē

08 returns  (25,25)(25,125)(125,125)(25,125)(25,25)(100024,100024)
09 returns  (25,0)(25,0)(125,0)(25,0)(25,0)(100024,0)

It seems that AutoCAD 09 is losing the Y value. Well! At least I can write my own work-around function, I thought the problem was in the polyline class

Code: [Select]
    // result from 08 (25,25)(25,125)(125,125)(25,125)(25,25)(100024,100024)
    // result from 09 (25,0)(25,0)(125,0)(25,0)(25,0)(100024,0)
    [CommandMethod("doit")]
    public static void doit()
    {
      Editor editor = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;

      Vector2d MoveBy = new Vector2d(25, 25);

      Point2dCollection ptc = new Point2dCollection();
      ptc.Add(new Point2d(0, 0));
      ptc.Add(new Point2d(0, 100));
      ptc.Add(new Point2d(100,100));
      ptc.Add(new Point2d(0, 100));
      ptc.Add(new Point2d(0, 0));
      ptc.Add(new Point2d(99999, 99999));

      //bug in Point2d.Add(vector2d)
      foreach (Point2d pt in ptc)
      {
        editor.WriteMessage("{0}", pt.Add(MoveBy));
      }
    }

nullptr

  • Bricscad
  • Needs a day job
  • Posts: 6582
  • AKA Daniel
Re: Is this a Bug in AutoCAD 2009?
« Reply #8 on: August 19, 2008, 01:03:10 am »