| Article | 70002758 |
| Type | HowTo |
| Product | Engine |
| Date Added | 9/18/2025 12:00:00 AM |
| Fixed | 11.4.21 (9/20/2025 12:00:00 AM) |
| Submitted by | Ikenna Aniobodo |
Summary
How to always show hatches of certain objects independ the vdDocument.GlobalRenderProperties.ShowHatches property value
Solution
Try a code like below:
//suppose you have add a vdFramedControl into a Form
private vdDocument doc { get { return vdFramedControl.BaseControl.ActiveDocument; } }
private void Form1_Load(object sender, EventArgs e)
{
doc.GlobalRenderProperties.ShowHatches = false;//initial set ShowHatches to false;
doc.FreezeEntityDrawEvents.Push(false);
doc.OnDrawFigure += Doc_OnDrawFigure;
doc.OnDrawAfterFigure += Doc_OnDrawAfterFigure;
doc.OnAfterNewDocument += new vdDocument.AfterNewDocument(doc_OnAfterNewDocument);
doc.OnAfterOpenDocument += new vdDocument.AfterOpenDocument(doc_OnAfterOpenDocument);
}
void doc_OnAfterOpenDocument(object sender)
{
vdDocument mdoc = sender as vdDocument;
mdoc.GlobalRenderProperties.ShowHatches = false;
}
void doc_OnAfterNewDocument(object sender)
{
vdDocument mdoc = sender as vdDocument;
mdoc.GlobalRenderProperties.ShowHatches = false;
}
//returns true is the passed figure need to ignore the ShowHatches and always be hatched
private bool IsForceHatchedFigure(vdFigure fig)
{
//quick filter out unnecessary objects to check
IvdHatchFigure hfig = fig as IvdHatchFigure;
if (hfig == null || hfig.HatchProperties == null || hfig.HatchProperties.FillMode == VdConstFill.VdFillModeNone) return false;
//filter what vdfigure you want to be hatched
//for example only vdCircle hatched will be shown.Other hatched figures will be shown depend the doc.GlobalRenderProperties.ShowHatches
if (fig is vdCircle)
{
return true;
}
return false;
}
private void Doc_OnDrawFigure(object sender, vdRender render, ref bool cancel)
{
bool ishatched = IsForceHatchedFigure(sender as vdFigure);
if (ishatched) doc.GlobalRenderProperties.ShowHatches = true;
}
private void Doc_OnDrawAfterFigure(object sender, vdRender render)
{
bool ishatched = IsForceHatchedFigure(sender as vdFigure);
if (ishatched) doc.GlobalRenderProperties.ShowHatches = false;
}
