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

Lofting two circles

2 REPLIES 2
Reply
Message 1 of 3
Roland_Feletic
372 Views, 2 Replies

Lofting two circles

I have problems to make a loft-object with two circles. Maybe anyone can help me to make a loftobject.
Have tried it with this code, but it does not work.


[CommandMethod("TestLoftObjekt", CommandFlags.Modal)]
public static void TestLoftObjekt()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
//Selection of a Curve
PromptEntityOptions prOpt = new PromptEntityOptions("\nPick circle");
//CurveOptions.AllowNone = false;
prOpt.SetRejectMessage("\nSelect a circle.");
prOpt.AddAllowedClass(typeof(Circle), false);
PromptEntityResult pr = ed.GetEntity(prOpt);
if (pr.Status == PromptStatus.OK)
{
ObjectId entid = pr.ObjectId;
using (Transaction myT = db.TransactionManager.StartTransaction())
{
Entity tmpEnt = (Entity)myT.GetObject(entid, OpenMode.ForWrite);
Circle Circle1 = tmpEnt as Circle;
if (Circle1 != null)
{
pr = ed.GetEntity(prOpt);
if (pr.Status == PromptStatus.OK)
{
entid = pr.ObjectId;
tmpEnt = (Entity)myT.GetObject(entid, OpenMode.ForWrite);
Circle Circle2 = tmpEnt as Circle;
if (Circle2 != null)
{
Vector3d MoveVec = new Vector3d(Circle2.Center.X - Circle1.Center.X, Circle2.Center.Y - Circle1.Center.Y, Circle2.Center.Z - Circle1.Center.Z);
MoveVec *= 3;
Matrix3d MoveC = Matrix3d.Displacement(MoveVec);
//Circle2.UpgradeOpen();
Circle2.TransformBy(MoveC);
//Circle2.DowngradeOpen();
Entity[] Circles = { Circle1, Circle2 };
LoftedSurface LS = new LoftedSurface();
LoftOptions LO = new LoftOptions();
LS.CreateLoftedSurface(Circles, null, null, LO);
BlockTableRecord btr = (BlockTableRecord)myT.GetObject(Circle1.OwnerId, OpenMode.ForWrite, false);
ObjectId obj = btr.AppendEntity(LS);
myT.AddNewlyCreatedDBObject(LS, true);
}
}
}
myT.Commit();
}
}
}
2 REPLIES 2
Message 2 of 3
cadMeUp
in reply to: Roland_Feletic

I think the problem is you need some guide curves in the second parameter to 'CreateLoftedSurface'. I re-worked your sample a little bit to include this. See the attached file. Also this will not work if the circles are on the same plane.

I drew two circles at elev 0 and moved the seond circle some distance along the Z direction. I tested the routine on these two circles and it worked with no problem.

I hope this will get you in the right direction.

I think the sample sdk application at:
ObjectARX2008\samples\dotNet\Managed_SurfaceHelix

will be very useful for you.
Message 3 of 3
Anonymous
in reply to: Roland_Feletic

Thank you, Larry.
Managed_SurfaceHelix was also very useful!
Roland

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