Jump to content

Recommended Posts

Posted

Does anyone have an example of the creation of an EllipticalArc3d in C#. I have been searching for days and cannot find anything. I have attempted to figure it out but I have had no luck.

Any help is greatly appreciated.

 

This is what I have started but I am still missing a whole lot I'm afraid.

[font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]EllipticalArc3d[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] vEllip = [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]new[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]EllipticalArc3d[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]();[/size][/font][/size][/font]

[font=Consolas][size=2][font=Consolas][size=2]vEllip.Center = vIns;[/size][/font][/size][/font]
[font=Consolas][size=2][size=2][font=Consolas]vEllip.MajorRadius = 2.0;[/font][/size][/size][/font]
[font=Consolas][size=2][size=2][font=Consolas]vEllip.MinorRadius = 1.0;[/font][/size]

[size=2][font=Consolas]vBtr.AppendEntity(vEllip);[/font][/size]
[/size][/font][font=Consolas][size=2][/size][/font][font=Consolas][size=2][font=Consolas][size=2]vTr.AddNewlyCreatedDBObject(vEllip, [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]true[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]);[/size][/font][/size][/font]

 

 

 

Posted

Would you be using this elliptical arc to create an elliptical dome in 3D by any chance?

Posted (edited)

You can create an ellipse directly instead,

just play with different angle and other values:



[CommandMethod("eel")]
       public void 
testCreateEllipseArc()

{
           Document 
doc = 
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;


           Editor ed 
= doc.Editor;


           Database 
db = 
doc.Database;

try

{

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

{

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



Vector3d major= new Vector3d(0,1,0);



double ratio = 0.5;



double startang = Math.PI ; // 0.0  for 



double endang = 1.5 * Math.PI;//2 * Math.PI



Ellipse elp = new Ellipse(new Point3d(0, 0, 0), Vector3d.ZAxis, major, ratio, 
startang, endang);



elp.ColorIndex = 
1;



btr.AppendEntity(elp);



tr.AddNewlyCreatedDBObject(elp, 
true);



tr.Commit();

}

}
           catch 
(Autodesk.AutoCAD.Runtime.Exception 
ex)

{
               Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message + "\n" + ex.StackTrace);

}

finally

{

ed.WriteMessage("\nPokey");

}
       }

Or am I missing something?

 

Another way:


EllipticalArc3d vEllip = new EllipticalArc3d();


                   vEllip.Set(new Point3d(0, 0, 0), new Vector3d(0, 2, 0), 
new Vector3d(1, 0, 0), 2.0, 1.0, 0.0, 2 * Math.PI);


                   Ellipse elp = new Ellipse(vEllip.Center, Vector3d.ZAxis, 
vEllip.MajorAxis, vEllip.MinorRadius / vEllip.MajorRadius, vEllip.StartAngle, 
vEllip.EndAngle);

Edited by fixo
Posted

This way I've created ellipsoid with no problems,

tested in A2010:


public void 
testCreateEllipsoid()

{
           Document 
doc = 
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;


           Editor ed 
= doc.Editor;


           Database 
db = doc.Database;


           Line 
ln=new Line();


           Solid3d 
sol = new Solid3d();



doc.TransactionManager.EnableGraphicsFlush(true);

try

{

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

{

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



EllipticalArc3d vEllip = new EllipticalArc3d();



vEllip.Set(new Point3d(0, 0, 0), new Vector3d(0, 2, 0), new Vector3d(1, 0, 0), 
2.0, 1.0, 1.5 * Math.PI, Math.PI / 2);



Ellipse elp = new Ellipse(vEllip.Center, Vector3d.ZAxis, vEllip.MajorAxis, 
vEllip.MinorRadius / vEllip.MajorRadius, vEllip.StartAngle, 
vEllip.EndAngle);



ln = new Line(elp.StartPoint, 
elp.EndPoint);



btr.AppendEntity(elp);



tr.AddNewlyCreatedDBObject(elp, true);



btr.AppendEntity(ln);



tr.TransactionManager.QueueForGraphicsFlush();



tr.AddNewlyCreatedDBObject(ln, true);



tr.TransactionManager.QueueForGraphicsFlush();



sol.RecordHistory = true;



RevolveOptions opts = new RevolveOptions();



RevolveOptionsBuilder rob = new RevolveOptionsBuilder(opts);



rob.CloseToAxis = false;



rob.DraftAngle = 0;



rob.TwistAngle = 0;



sol.CreateRevolvedSolid(elp as Entity, ln.StartPoint, ln.EndPoint.GetAsVector() 
- ln.StartPoint.GetAsVector(), 2 * Math.PI, 0, 
rob.ToRevolveOptions());



btr.AppendEntity(sol);



tr.AddNewlyCreatedDBObject(sol, true);



tr.TransactionManager.QueueForGraphicsFlush();



doc.TransactionManager.FlushGraphics();



ed.Regen();



tr.Commit();





}

}
           catch 
(Autodesk.AutoCAD.Runtime.Exception 
ex)

{

Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message + 
"\n" + 
ex.StackTrace);

}

finally

{



if (sol != 
null)

{

ed.WriteMessage("\nThe ellipsoid is created 
successfully");

}

}
           }

Posted

Thank you Fixo. I'm really not sure why I didn't see it before but I completely missed my target on this one. After reading your reply it became clear what I was missing. Thank you for your help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...