Distinguished Contributor
Posts: 172
Registered: ‎11-19-2003
Message 1 of 1 (110 Views)

HatchLoops and draw borders of hatches

110 Views, 0 Replies
07-05-2006 11:58 PM
Hallo all,
i have many hatches with deleted borders. Now i wanted to make a function
which recreates the borders.
It is not possible to get the ObjectIds of the Loops because they are
deleted. I can get the HatchLoop and a Curve2d.
But now i need a Curve-Entity because i need the borders in the drawing.
How can i do this? Is it possible to make it?
I don't need them associative to the new borders, just need the borders.
Here is the code i have till now, just have no idea how to make a Curve2d to
a Curve:

#region Using directives

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading;

using System.Globalization;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Geometry;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.Runtime;


[assembly: CommandClass(typeof(RSNNAcadApp.ExtendedCommands.Testerl))]

namespace RSNNAcadApp.ExtendedCommands


class Testerl



public void Test()


Database db = HostApplicationServices.WorkingDatabase;

//Transaction myT = db.TransactionManager.StartTransaction();

Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

Hatch HatchObj;

PromptEntityOptions HatchOptions = new PromptEntityOptions("Hatch wählen");

PromptEntityResult HatchResult = null;



HatchResult = ed.GetEntity(HatchOptions);

} while (HatchResult.Status == PromptStatus.Error);

if (HatchResult.Status == PromptStatus.Cancel)


else if (HatchResult.Status == PromptStatus.OK)


ObjectId entid = HatchResult.ObjectId;

Entity tmpEnt = null;

using (Transaction myT2 = db.TransactionManager.StartTransaction())


tmpEnt = (Entity)myT2.GetObject(entid, OpenMode.ForRead);


//Entity tmpEnt = (Entity)myT.GetObject(entid, OpenMode.ForRead);

HatchObj = tmpEnt as Hatch;

if (HatchObj != null)


ed.WriteMessage(String.Format("\nLoops: {0}",

for (int i = 0; i < HatchObj.NumberOfLoops; i++)


ed.WriteMessage(String.Format("\nObjekt {0} = {1}", i.ToString(),

HatchLoop HL = HatchObj.GetLoopAt(i) ;

// Does not work because the borders of the hatch are ereased


ObjectIdCollection IDColl = HatchObj.GetAssociatedObjectIdsAt(i);

Entity tmpEnt2 = null;

using (Transaction myT1 = db.TransactionManager.StartTransaction())


tmpEnt2 = (Entity)myT1.GetObject(IDColl[0], OpenMode.ForRead);


ed.WriteMessage(String.Format("\nObjekt {0} = {1}", i.ToString(),


Curve2dCollection CC = HL.Curves;

Curve2d Border = CC[0];








Roland Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.