Community
Hi there esteemed colleagues
Advice much appreciated.
using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; class PlaneOverrule : DrawableOverrule { public override bool WorldDraw(Drawable drawable, WorldDraw wd) { // we want to apply a transformation so that the entity // is displayed in the XZ plane in addition to the XY plane // (or rather it is displayed normal to the plane it is actually drawn on // in addition to the entity's customary world draw implementation ) Line line = drawable as Line; Matrix3d matrix = Matrix3d.Rotation(Math.PI / 2, Vector3d.YAxis, Point3d.Origin); Point3d start = line.StartPoint.TransformBy(matrix); Point3d end = line.EndPoint.TransformBy(matrix); wd.Geometry.WorldLine(start, end); // We want the entity to be displayed as it normally would be return base.WorldDraw(drawable, wd); } } public class Commands { private static PlaneOverrule overrule; [CommandMethod("OverrideToDifferentPlane")] public void OverrideToDifferentPlane() { if (overrule == null) { overrule = new PlaneOverrule(); Overrule.AddOverrule(RXObject.GetClass(typeof(Line)), overrule, false); } else { Overrule.RemoveOverrule(RXObject.GetClass(typeof(Line)), overrule); overrule.Dispose(); overrule = null; } Overrule.Overruling = !Overrule.Overruling; Application.DocumentManager.MdiActiveDocument.Editor.Regen(); } }
Solved! Go to Solution.
Solved by Virupaksha_aithal. Go to Solution.
Hi,
try adding overrule to all the entities like
Overrule.AddOverrule(RXObject.GetClass(typeof(Entity)), overrule, false);
and try using "GetTransformedCopy" API entity get the transferred copy so that your code works for all entities. refer below code (i have not tested for the entities though)
class PlaneOverrule : DrawableOverrule { public DBObjectCollection copyCollection = new DBObjectCollection(); public override bool WorldDraw(Drawable drawable, WorldDraw wd) { // we want to apply a transformation so that the entity // is displayed in the XZ plane in addition to the XY plane // (or rather it is displayed normal to the plane it is actually drawn on // in addition to the entity's customary world draw implementation ) Matrix3d matrix = Matrix3d.Rotation(Math.PI / 2, Vector3d.YAxis, Point3d.Origin); /* Line line = drawable as Line; Matrix3d matrix = Matrix3d.Rotation(Math.PI / 2, Vector3d.YAxis, Point3d.Origin); Point3d start = line.StartPoint.TransformBy(matrix); Point3d end = line.EndPoint.TransformBy(matrix); wd.Geometry.WorldLine(start, end);*/ Entity ent1 = drawable as Entity; if(ent1.ObjectId != ObjectId.Null) { Entity copyEnt = ent1.GetTransformedCopy(matrix); copyEnt.WorldDraw(wd); //to dispose the entities later.. copyCollection.Add(copyEnt); } // We want the entity to be displayed as it normally would be return base.WorldDraw(drawable, wd); } } public class Commands2 { private static PlaneOverrule overrule; [CommandMethod("OverrideToDifferentPlane")] public void OverrideToDifferentPlane() { if (overrule == null) { overrule = new PlaneOverrule(); Overrule.AddOverrule(RXObject.GetClass(typeof(Entity)), overrule, false); } else { //dispose the entities foreach(DBObject obj in overrule.copyCollection) { obj.Dispose(); } Overrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), overrule); overrule.Dispose(); overrule = null; } Overrule.Overruling = !Overrule.Overruling; Application.DocumentManager.MdiActiveDocument.Editor.Regen(); } }
Can't find what you're looking for? Ask the community or share your knowledge.