.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I have a cirlce which is rotated 45 degree around the X-axis. If you look at it from the top (normal=0,0,1) it will look like an ellipse.
I want to draw a new entity (ELLIPSE) that will have the same shape/look as the circle viewed from the top, but the whole entity must have z=0.
Basically, exactly what the command FLATTEN does.
Is there a way to do this easily? Or is the only way to figure out the math behind it? Does anyone know a site where this math is explained?
Thank you.
Solved! Go to Solution.
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this code:
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.DatabaseServices;
[assembly: CommandClass(typeof(Rivilis.CurveProject))]
namespace Rivilis
{
public class CurveProject
{
[CommandMethod("CrvPrjUCS")]
static public void CrvPrjUCS()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = Application.DocumentManager.MdiActiveDocument.Database;
PromptEntityOptions opt = new PromptEntityOptions("\nSelect a Curve: ");
opt.SetRejectMessage("Not a Curve");
opt.AddAllowedClass(typeof(Curve), false);
PromptEntityResult rs = ed.GetEntity(opt);
Matrix3d mat = ed.CurrentUserCoordinateSystem;
Plane pln = new Plane(Point3d.Origin, Vector3d.ZAxis);
pln.TransformBy(mat);
if (rs.Status == PromptStatus.OK) {
using (Transaction tr = db.TransactionManager.StartTransaction()) {
Curve crv = tr.GetObject(rs.ObjectId, OpenMode.ForRead) as Curve;
if (crv != null) {
Curve newCrv = crv.GetOrthoProjectedCurve(pln);
if (newCrv != null) {
BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
if (btr != null) {
btr.AppendEntity(newCrv);
tr.AddNewlyCreatedDBObject(newCrv, true);
} else {
newCrv.Dispose();
}
}
}
tr.Commit();
}
}
}
}
}
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Alexander,
I noticed the GetOrthoProjectedCurve() and GetProjectedCurve() methods gave unexpected results with polylines (all types).
You can have a look at the GetOrthoProjectedPolyline() and GetProjectedPolyline() extension methods for Polyline, Polyline2d and Polyline3d classes in the GeometryExtension library here:
http://www.theswamp.org/index.php?topic=31865.msg3
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
C6309D9E0751D165D0934D0621DFF27919
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi, Gilles!
You probably right, but I've tested this code with different types of polylines in AutoCAD 2013 and found no problems. Maybe you can clarify the conditions in which these problems arise?
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Ok, with A3013 GetOrthoProjectedCurve() seems to work as expected with Polyline entities, but I still have unexpected results with Polyline2d entities (wrong elevation).
With prior AutoCAD versions GetOrthoProjectedCurve() raised a eNotApplicable exception with Polyline entities and gave unpredictable reulst with Polyline2d entities.
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: Projecting a circle on default UCS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
It's a bit late reply, but....great ty!




