namespace Test
{
public class HatchDrawRule : DrawableOverrule
{
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
if (drawable.Bounds == null) return false;
Extents3d b = (Extents3d)drawable.Bounds;
if (b.MinPoint.Z != 0) return false;
var style
= new TextStyle
(); style.TextSize = (b.MaxPoint.Y - b.MinPoint.Y) / 4;
var center
= new Point3d
((double)(b
.MinPoint.X + b
.MaxPoint.X) / 2,
(double)(b
.MinPoint.Y + b
.MaxPoint.Y) / 2,
0); wd.Geometry.Text(center, Vector3d.ZAxis, Vector3d.XAxis, "Hatch", true, style);
return base.WorldDraw(drawable, wd);
}
}
public class CustomHatchClass
{
private static HatchDrawRule _hatchDrawRule;
[CommandMethod("AllowCustomHatch")]
public void AllowCustomHatch()
{
if (_hatchDrawRule == null)
{
_hatchDrawRule
= new HatchDrawRule
(); Overrule
.AddOverrule(RXObject
.GetClass(typeof(Hatch
)), _hatchDrawRule,
false); }
Overrule.Overruling = true;
Acap.DocumentManager.MdiActiveDocument.Editor.Regen();
}
[CommandMethod("GetData")]
public void GetData()
{
var doc = Acap.DocumentManager.MdiActiveDocument;
var pr = doc.Editor.GetSelection();
if (pr.Status == ZwSoft.ZwCAD.EditorInput.PromptStatus.OK)
{
foreach (ObjectId id in pr.Value.GetObjectIds())
{
using (var tran = doc.Database.TransactionManager.StartTransaction())
{
var ent = tran.GetObject(id, OpenMode.ForRead) as Entity;
{
//Can I read the text within Hatch directly?
}
}
}
}
}
}
}