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

HatchLoops and draw borders of hatches

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
283 Views, 0 Replies

HatchLoops and draw borders of hatches

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
0 REPLIES 0

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