.NET

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

HatchLoops and draw borders of hatches

107 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;

#endregion

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

namespace RSNNAcadApp.ExtendedCommands

{

class Testerl

{

[CommandMethod("HatchLoops")]

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;

do

{

HatchResult = ed.GetEntity(HatchOptions);

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

if (HatchResult.Status == PromptStatus.Cancel)

return;

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}",
HatchObj.NumberOfLoops.ToString()));

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

{

ed.WriteMessage(String.Format("\nObjekt {0} = {1}", i.ToString(),
HatchObj.LoopTypeAt(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(),
tmpEnt2.GetType().ToString()));

*/


Curve2dCollection CC = HL.Curves;

Curve2d Border = CC[0];

}

}

}

}

}

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--
Roland Feletic
Ingenieurbuero A. Pauser Ges.m.b.H.
http://www.pauser.at

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
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 to get help installing your software.

Ask the Community