.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Grid stops overrule from working

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
quigs
594 Views, 5 Replies

Grid stops overrule from working

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 :D.

My name is Martin.. 😄
5 REPLIES 5
Message 2 of 6
quigs
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.. 😄
Message 3 of 6
quigs
in reply to: quigs

BUMP!

No takers,

not even the mods?

My name is Martin.. 😄
Message 4 of 6
Balaji_Ram
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

Message 5 of 6
quigs
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.. 😄
Message 6 of 6
quigs
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.

 

😄 😄 :D:D:D:D:D

 

Thanks

My name is Martin.. 😄

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost