.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Curve2dCollection.Curves return null

2 REPLIES 2
Reply
Message 1 of 3
giuseppe.ceccherini
760 Views, 2 Replies

Curve2dCollection.Curves return null

Hi all,

using Autocad 2010 x64 on win7, I create a CommandMethod that scan document to search Hatches. When i get a Hatch object and then HatchLoop object trough GetLoopAt method, then the property Curves of the Curve2dCollection object return always null.

It should seem a bug. This happens also with Autocad 2009.

Does anyone knows something about this issue?

thanks in advance

 

Giuseppe
2 REPLIES 2
Message 2 of 3

Sorry.. Curves property is of HatchLoop object, not of Curve2dCollection.

 

mi code (c#) is:

 

                foreach (ObjectId acObjId in acBlkTblRec)
                {
                    if (acObjId.ObjectClass.Name.ToUpper() == "ACDBHATCH")
                    {
                        nCnt = nCnt + 1;
                        DBObject dbO = acObjId.GetObject(OpenMode.ForRead);
                        Hatch h = (Hatch)dbO;
                        for (int i = 0; i <= h.NumberOfLoops - 1; i++)
                        {
                            HatchLoop hl = h.GetLoopAt(i);
                            Curve2dCollection curves = hl.Curves;

---------------------------------------------------------------------

hl.Curves is null (but the curves exist!!!), that's my problem

Giuseppe
Message 3 of 3

        [CommandMethod("ht")]
        public static void HatchLoop()
        {
            PromptSelectionResult res = SysVarManager.Editor.GetSelection(
                new PromptSelectionOptions(),
                new SelectionFilter(new TypedValue[] { new TypedValue(0, "Hatch") }));
            if (res.Status != PromptStatus.OK)
                return;

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {

                BlockTableRecord btr =
                    (BlockTableRecord)tr.GetObject(
                        db.CurrentSpaceId,
                        OpenMode.ForWrite,
                        false);

                foreach (ObjectId id in res.Value.GetObjectIds())
                {
                    Hatch h = (Hatch)tr.GetObject(id, OpenMode.ForRead);
                    Matrix3d mat = Matrix3d.PlaneToWorld(h.GetPlane());

                    for (int i = 0; i < h.NumberOfLoops; i++)
                    {
                        HatchLoop loop = h.GetLoopAt(i);
                        if (loop.IsPolyline)
                        {
                            BulgeVertexCollection bvs = loop.Polyline;
                            Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();
                            for (int j = 0; j < bvs.Count; j++)
                            {
                                BulgeVertex bv = bvs[j];
                                pl.AddVertexAt(j, bv.Vertex, bv.Bulge, 0, 0);
                            }
                            pl.TransformBy(mat);
                            btr.AppendEntity(pl);
                            tr.AddNewlyCreatedDBObject(pl, true);

                        }
                        else
                        {
                            foreach (Curve2d c2d in loop.Curves)
                            {
                                Curve c = c2d.ToCurve(mat);
                                btr.AppendEntity(c);
                                tr.AddNewlyCreatedDBObject(c, true);
                            }
                        }
                    }
                }
                tr.Commit();
            }
        }

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost