Code Red > .NET

Hatch not showing up after creation

(1/6) > >>

Kralj_klokan:
Hi,

I ' m new to this forum and i have a problem while creating a hatch using traceboundaries().
After i creating my hatch and setting hatchstyle to outer i does not show up. The border polylines is displayed but the hatch only shows up if i click on any object and change its property.
I have no idea what the issue could be. I 've set all my system variables to the default. I tried it on various drawings and even on other autocad versions.
Once the hatch appears everything is working fine.

This issue is driving me nuts. Here is my Hatch creation code. Maybe someone sees something i don't.  :x :x :x

--- Code - C#: ---  Document doc = Application.DocumentManager.MdiActiveDocument;            Database db = doc.Database;            Editor ed = doc.Editor;            PromptPointResult ppr = ed.GetPoint("\nSelect internal point: ");            if (ppr.Status != PromptStatus.OK) return;             DBObjectCollection objs = ed.TraceBoundary(ppr.Value, true);            if (objs.Count == 0) return;             using (Transaction tr = doc.TransactionManager.StartTransaction())            {                BlockTable acBlkTbl;                acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;                 // Open the Block table record Model space for write                BlockTableRecord acBlkTblRec;                acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;                 using (Hatch hat = new Hatch())                {                    acBlkTblRec.AppendEntity(hat);                    tr.AddNewlyCreatedDBObject(hat, true);                    hat.HatchStyle = HatchStyle.Outer;                    hat.SetDatabaseDefaults();                    hat.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");                     hat.Associative = true;                    foreach (DBObject obj in objs)                    {                        Curve c = obj as Curve;                        if (c != null)                        {                            ObjectId curveId = acBlkTblRec.AppendEntity(c);                            tr.AddNewlyCreatedDBObject(c, true);                            hat.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { curveId });                        }                    }                    hat.EvaluateHatch(true);                    var ds = new DrawStream();                }                tr.Commit();            } Any help would be greatly appreciated since i 'm working on this for days.


edit kdub: code tag for code=csharp added.

gile:
Hi,

Your code works for me (tested on A2019).
You can try adding:
--- Code - C#: ---hat.DowngradeOpen(); just after:
--- Code - C#: ---hat.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");

Kralj_klokan:

--- Quote from: gile on July 17, 2019, 02:00:39 AM ---Hi,

Your code works for me (tested on A2019).
You can try adding:
--- Code - C#: ---hat.DowngradeOpen(); just after:
--- Code - C#: ---hat.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
--- End quote ---

I 've tried your suggestion but unfortunately still no result. It could be some graphics card setting or something like that.
This is really getting ridiculous. I 'm also using AutoCAD 2019.

Is the hatch created with hatchstyle.outer?

Ty for your help anyway.

Kralj_klokan:
I 've recorded my behaviour to show a picture how its working.
It's uploaded on vimeo on this link https://vimeo.com/user100893766/review/348539021/7a97fe464e
I also attached the video.

So i pick a point inside of the area i want to hatch. The hatch does not show up. But if i click on the polyline that surrounds the hatch  twice quickly it suddenly appears.

 :uglystupid2: :uglystupid2: :uglystupid2:

Atook:
Have you tried Editor.Regen() once you're done creating the hatch and committing the transaction?

Navigation

[0] Message Index

[#] Next page

Go to full version