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.
Solved! Go to Solution.
Solved by quigs. Go to Solution.
We just tested this on some other machines and the GRID is defiantly stopping it working when activated.
Very weird.
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(); } } }
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.
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