Author Topic: Jig for a Polyline3d .. trial and error.  (Read 8607 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: Jig for a Polyline3d .. trial and error.
« Reply #15 on: January 28, 2008, 01:04:41 PM »
The Mercury and Oxygen styles do not add the Scroll bars , consequently showing all the code in the code pane ( which is what I prefer).
so .. I've changed my furum style to Mercury, and should be able to post into code panes. Anyone using one of the other styles will just have to vertically scroll their code pane to read the code.

Good call Kerry and thanks for that - the scroll bars annoy the crap out of me as well - now changed to Mercury and all is good.

Did you get this to work or is it still flickering? If it is, I will have a crack at it tomorrow, my time, and see what I can see, or not see, so to speak :)

Cheers,
Glenn.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Jig for a Polyline3d .. trial and error.
« Reply #16 on: January 28, 2008, 02:06:58 PM »
I haven't read the whole thread, but at AU this year, it was discussed that the 2D wireframe visual style causes flickering, so we should use the 3D Wireframe style.  Hope this helps
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Jig for a Polyline3d .. trial and error.
« Reply #17 on: January 28, 2008, 02:30:10 PM »
[........... Did you get this to work or is it still flickering? If it is, I will have a crack at it tomorrow, my time, and see what I can see, or not see, so to speak :)

Cheers,
Glenn.

I haven't been able to made time to look at it again yet Glenn ... would be good to see what you can see ..
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.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Jig for a Polyline3d .. trial and error.
« Reply #18 on: February 28, 2008, 12:00:45 AM »
I've had a go at this without using the jig and it works well for a while then throws an error "Internal error scandr 40" This is caused by a combo of  the regen and the pline not being kosher. If you add a break at pl.AppendVertex(v);    and hover over the pl you will see a list of exceptions. Where do they come from???

Code: [Select]
class pline3d
    {
        [CommandMethod("p3d")]
       public void pl3d()
        {
            Document doc=acadApp.DocumentManager.MdiActiveDocument;
            Editor ed=doc.Editor;
            Matrix3d ucs=ed.CurrentUserCoordinateSystem;
            Point3dCollection c = new Point3dCollection();
            Point3d baseP,p;
            bool bAddVertex=true;

            string msg = "\nSelect vertex point for self-Closing Polyline: ";
            if (!getpoint(msg, ref p)) return;
            baseP=p;
            c.Add(p.TransformBy(ucs));
            if(!getpoint(msg,baseP,ref p)) return;
            c.Add(p.TransformBy(ucs));
            ObjectId id= makePline3d(c);
            baseP = p;
            do
            {   
                if (!getpoint(msg, baseP, ref p)) return;
                baseP = p; p = p.TransformBy(ucs);
                bAddVertex = addVertex(id, p);
                ed.Regen();//Take this out and nothing shows///////////////
            }while (bAddVertex);

        }


        private bool addVertex(ObjectId id, Point3d p)
        {
            Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
            AcDb.Database db = ed.Document.Database;
            try
            {
                using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
                {
                    AcDb.Polyline3d pl = tr.GetObject(id, OpenMode.ForWrite) as Polyline3d;
                    AcDb.PolylineVertex3d v = new PolylineVertex3d(p);
                    pl.AppendVertex(v);    ///////////////////Put a break here///////////////////////////////
                    // pl.InsertVertexAt(v.Id, v);
                    //pl.Draw();
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                WinForms.MessageBox.Show(ex.Message,
                    "Exception",
                    WinForms.MessageBoxButtons.OK,
                    WinForms.MessageBoxIcon.Error);
                return false;
            }
            return true;
        }




        static bool getpoint(string msg, ref Point3d P)
        {
            Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
            PromptPointResult res = ed.GetPoint(msg);
            if (res.Status != PromptStatus.OK)return false;
            P = res.Value;
            return true;       
        }


        static bool getpoint(string msg,Point3d baseP,ref Point3d P)
        {
            Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
            PromptPointOptions ppo = new PromptPointOptions(msg);
            ppo.UseBasePoint = true;
            ppo.BasePoint = baseP;
            ppo.AllowArbitraryInput = true;
            PromptPointResult res = ed.GetPoint(ppo);
            if (res.Status != PromptStatus.OK)return false;
            P = res.Value;
            return true;       
        }

        static ObjectId makePline3d(Point3dCollection c)
        {
            Polyline3d pl = new Polyline3d(Poly3dType.SimplePoly,  c, false);
            Database db = HostApplicationServices.WorkingDatabase;
            using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr = tr.GetObject
                    (db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                btr.AppendEntity(pl);
                tr.AddNewlyCreatedDBObject(pl, true);
                tr.Commit();
            }
            return pl.ObjectId;
        }



    }

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Jig for a Polyline3d .. trial and error.
« Reply #19 on: March 02, 2008, 04:23:21 PM »
It appears a PolylineVertex3d is some kind of object and needs to be closed or disposed.

Code: [Select]
private bool addVertex(ObjectId id, Point3d p)
        {
            Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
            AcDb.Database db = ed.Document.Database;
            try
            {
                using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
                {
                    AcDb.Polyline3d pl = tr.GetObject(id, OpenMode.ForWrite) as Polyline3d;
                    AcDb.PolylineVertex3d v = new PolylineVertex3d(p);
                    pl.AppendVertex(v);
                    v.Dispose();   //The trouble maker fixed////////////////////////////////
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                WinForms.MessageBox.Show(ex.Message,
                    "Exception",
                    WinForms.MessageBoxButtons.OK,
                    WinForms.MessageBoxIcon.Error);
                return false;
            }
            return true;
        }


As far as complex object jigs go, I haven't seen them work exactly like cad. Kean Walmsley's works well but it is not the same as cad. When asking for a linesegment getpoint seems to be jig enough.