.NET

Reply
Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 1 of 6 (305 Views)
Accepted Solution

Grid stops overrule from working

305 Views, 5 Replies
11-10-2012 02:55 AM

Hi there,

I have created a polyline overrule with custom gips and worlddraw

and we have an odd occurrence.  On 3 of our test machines it works fine.

But on my machine (the best and newest one), if I have the grid turned

on the overrule wont display.  Its invisible.  If you do a select all you can

see it but you can’t select it.

 

I thought maybe it was a custom grip issue but then why when the grid is

Off does it work fine?  What worries me a little is that to figure this out

was purely luck.  I can put in a call to turn the grid off but this isn’t finding the

problem.

 

Any clues?

 

Thanks in advance :smileyvery-happy:.

My name is Martin.. :smileyvery-happy:

Thank you for that,

we found that we didn't put in a tr.Commit(); in the worlddraw.  Now it's back in it works perfectly.

 

:smileyvery-happy: :smileyvery-happy: :smileyvery-happy::smileyvery-happy::smileyvery-happy::smileyvery-happy::smileyvery-happy:

 

Thanks

Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 2 of 6 (257 Views)

Re: Grid stops overrule from working

11-12-2012 01:14 AM in reply to: quigs

We just tested this on some other machines and the GRID is defiantly stopping it working when activated.

 

Very weird.

My name is Martin.. :smileyvery-happy:
Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 3 of 6 (232 Views)

Re: Grid stops overrule from working

11-13-2012 09:55 AM in reply to: quigs

BUMP!

No takers,

not even the mods?

My name is Martin.. :smileyvery-happy:
ADN Support Specialist
Balaji_Ram
Posts: 735
Registered: ‎03-21-2011
Message 4 of 6 (184 Views)

Re: Grid stops overrule from working

11-20-2012 03:14 AM in reply to: quigs

Hello Martin,

 

I tried a sample code that overrules polyline and then turned GRID on/off but the overrule did work correctly in both cases. Here is a very simple drawable overrule code that I am using to draw circles at each vertex of the overruled pline. I have tried it with AutoCAD 2011 and 2013 and it worked ok. Which version are you using ?

Is it system specific ? If so, have you tried resetting the AutoCAD settings by using the "Reset Settings to Default" ?

 

Here is the sample code. You can draw a pline and then run the Test command to select the pline.

 

    public class MyDrawOverrule : DrawableOverrule
    {
        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            Autodesk.AutoCAD.DatabaseServices.Polyline pline = drawable as Autodesk.AutoCAD.DatabaseServices.Polyline;
            if (pline != null)
            {
                short clr = 1;
                int segCount = pline.NumberOfVertices;
                for (int cnt = 0; cnt < segCount; cnt++)
                {
                    Point3d vertexPt = pline.GetPoint3dAt(cnt);
                    SegmentType type = pline.GetSegmentType(cnt);

                    switch (type)
                    {
                        case SegmentType.Arc:

                            CircularArc2d arc2d = pline.GetArcSegment2dAt(cnt);

                            clr = wd.SubEntityTraits.Color;
                            wd.SubEntityTraits.Color = 2;
                            wd.Geometry.Circle(vertexPt, arc2d.GetLength(arc2d.GetParameterOf(arc2d.StartPoint), arc2d.GetParameterOf(arc2d.EndPoint)) * 0.2, pline.Normal);
                            wd.SubEntityTraits.Color = clr;

                            break;

                        case SegmentType.Line:

                            LineSegment2d line2d = pline.GetLineSegment2dAt(cnt);

                            clr = wd.SubEntityTraits.Color;
                            wd.SubEntityTraits.Color = 2;
                            wd.Geometry.Circle(vertexPt, line2d.GetLength(line2d.GetParameterOf(line2d.StartPoint), line2d.GetParameterOf(line2d.EndPoint)) * 0.2, pline.Normal);
                            wd.SubEntityTraits.Color = clr;

                            break;

                        case SegmentType.Coincident:
                            break;
                        case SegmentType.Empty:
                            break;
                        case SegmentType.Point:
                            break;
                    }
                }
            }
            return base.WorldDraw(drawable, wd);
        }
    }

    public class Commands
    {
        static MyDrawOverrule pldo = null;
        static List<ObjectId> plineIds = new List<ObjectId>();

        [CommandMethod("Test")]
        public void TestMethod()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            PromptEntityResult per = ed.GetEntity("\nSelect a polyline");
            if (per.Status != PromptStatus.OK)
                return;

            plineIds.Add(per.ObjectId);

            if (pldo == null)
            {
                pldo = new MyDrawOverrule();

                Overrule.AddOverrule(RXObject.GetClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline)), pldo, true);

                pldo.SetIdFilter(plineIds.ToArray());

                Overrule.Overruling = true;
            }
            else
            {
                pldo.SetIdFilter(plineIds.ToArray());
            }

            using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
            {
                Entity reg = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite);
                reg.RecordGraphicsModified(true);
                tr.TransactionManager.QueueForGraphicsFlush();
                tr.Commit();
            }
        }
    }

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 5 of 6 (174 Views)

Re: Grid stops overrule from working

11-20-2012 07:52 AM in reply to: Balaji_Ram

Thanks for the reply,

It isn't machine specific because we have just tested, and the bug seems to appear on both of our machines.  We are re-writing now and adding back in some custom grips.  We believe it may be a problem there.  I will post here when I know more. 

 

Thanks,

 

Maritn.

My name is Martin.. :smileyvery-happy:
Distinguished Contributor
quigs
Posts: 143
Registered: ‎09-30-2008
Message 6 of 6 (158 Views)

Re: Grid stops overrule from working

11-21-2012 03:16 AM in reply to: quigs

Thank you for that,

we found that we didn't put in a tr.Commit(); in the worlddraw.  Now it's back in it works perfectly.

 

:smileyvery-happy: :smileyvery-happy: :smileyvery-happy::smileyvery-happy::smileyvery-happy::smileyvery-happy::smileyvery-happy:

 

Thanks

My name is Martin.. :smileyvery-happy:
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!