Author Topic: Trying to convert simple polyline to AcGePolyline2d  (Read 6147 times)

0 Members and 1 Guest are viewing this topic.

Proctor

  • Guest
Trying to convert simple polyline to AcGePolyline2d
« on: August 18, 2011, 02:22:32 PM »
Hello: I need to know how to convert my lightweight polyline to AcGePolyline2d.
I'm working on an windows app that incorporates the autocad .net api.

Autocad version 09.

Thanks for your help,
Proctor

n.yuan

  • Bull Frog
  • Posts: 348
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #1 on: August 18, 2011, 03:45:48 PM »
Are you using Acad .NET API or ObjectARX API (C++)? AcGePolyline2d is an ObjectARX class, and the corresponding .NET API class is Autdesk.AutoCAD.Geometry.PolylineCurve2d, which has a few Contructors. You can get the needed parameter data from a Polyline and use it in one of the Constructor.

BTW, since you mentioned that you are doing an Windows app, is it an stand-alone EXE? if yes, you cannot use either ObjectARX class or .NET API class i n a stand-alone EXE, even the box has AutoCAD installed. They can only be used in code that run inside AutoCAD (*.arx from Object ARX code/.NET *.dll from .NET API code).

Proctor

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #2 on: August 18, 2011, 05:01:55 PM »
n.yuan: thank you for your reply. I'm using the .net api for autocad...so, from what you're saying, I won't have access to AcGePolyline2d. 
The reason I wanted to convert my polyline is because I wanted to use the "isOn" method in effort to try to see if a point is on my polyline.
I don't see this method available for Polyline or PolylineCurve2d.

Do you have any thoughts on how I can achieve this?

Also, my app runs inside autocad...

thanks again,
Proctor

kaefer

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #3 on: August 18, 2011, 05:24:41 PM »
I don't see this method available for Polyline or PolylineCurve2d.

The method IsOn is on Curve2d. You'd be amazed what classes derive from Curve2d, and on whom IsOn and it's various overloads are avaiable as well.


Curve2d
+- CircularArc2d
+- CompositeCurve2d
+- EllipticalArc2d
+- ExternalCurve2d
+- LinearEntity2d
|  +- Line2d
|  +- LineSegment2d
|  +- Ray2d
+- OffsetCurve2d
+- SplineEntity2d
   +- CubicSplineCurve2d
   +- NurbCurve2d
   +- PolylineCurve2d

Proctor

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #4 on: August 18, 2011, 06:56:46 PM »
Kaefer: thank you for your reply. This is great news! Can you please tell me where you were able to get the info on Curve2d?
I looked in the AutoCad developers guide, but didn't see it there:

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html


Can you also tell me how to convert a polyline to a PolylineCurve2d so that I can test out the IsOn to see
if it's available?

Thanks again,
Proctor

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #5 on: August 18, 2011, 07:41:34 PM »
< .. > 
Can you please tell me where you were able to get the info on Curve2d?
< .. >

Autodesk.AutoCAD.Geometry.Curve2d

Code: [Select]
[Wrapper("AcGeCurve2d")]
public abstract class Curve2d : Entity2d
{
    // Methods
    internal protected Curve2d(IntPtr unmanagedPointer, [MarshalAs(UnmanagedType.U1)] bool autoDelete);
    internal static unsafe Curve2d Create(AcGeCurve2d modopt(IsConst)* unmanagedPointer);
    public static Curve2d Create(IntPtr unmanagedPointer, [MarshalAs(UnmanagedType.U1)] bool autoDelete);
    public Point2d EvaluatePoint(double parameter);
    public Curve2d[] Explode(Interval interval);
    public double GetArea(double startParameter, double endParameter);
    public double GetArea(double startParameter, double endParameter, Tolerance tolerance);
    public BoundBlock2d GetBoundBlockOf(Interval range);
    public PointOnCurve2d[] GetClosestPointTo(Curve2d curve);
    public PointOnCurve2d GetClosestPointTo(Point2d point);
    public PointOnCurve2d[] GetClosestPointTo(Curve2d curve, Tolerance tolerance);
    public PointOnCurve2d GetClosestPointTo(Point2d point, Tolerance tolerance);
    public double GetDistanceTo(Curve2d curve);
    public double GetDistanceTo(Point2d point);
    public double GetDistanceTo(Curve2d curve, Tolerance tolerance);
    public double GetDistanceTo(Point2d point, Tolerance tolerance);
    internal unsafe AcGeCurve2d* GetImpObj();
    public Interval GetInterval();
    public double GetLength(double fromParameter, double toParameter);
    public double GetLength(double fromParameter, double toParameter, Tolerance tolerance);
    public PointOnCurve2d GetNormalPoint(Point2d point);
    public PointOnCurve2d GetNormalPoint(Point2d point, Tolerance tolerance);
    public BoundBlock2d GetOrthoBoundBlockOf(Interval range);
    public double GetParameterAtLength(double datumParameter, double length, [MarshalAs(UnmanagedType.U1)] bool parameterDirection);
    public double GetParameterAtLength(double datumParameter, double length, [MarshalAs(UnmanagedType.U1)] bool parameterDirection, Tolerance tolerance);
    public double GetParameterOf(Point2d point);
    public double GetParameterOf(Point2d point, Tolerance tolerance);
    public Curve2d GetReverseParameterCurve();
    public Point2d[] GetSamplePoints(int numSample);
    public PointOnCurve2d[] GetSamplePoints(double fromParameter, double toParameter, double approxEps);
    public Curve2d[] GetSplitCurves(double value);
    public Curve2d[] GetTrimmedOffset(double distance, OffsetCurveExtensionType extensionType);
    public Curve2d[] GetTrimmedOffset(double distance, OffsetCurveExtensionType extensionType, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsClosed();
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsClosed(Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsDegenerate(out Entity2d result);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsDegenerate(out Entity2d result, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsLinear(out Line2d line);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsLinear(out Line2d line, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Point2d point);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(double parameter);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Point2d point, out double value);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Point2d point, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(double parameter, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsOn(Point2d point, out double value, Tolerance tolerance);
    [return: MarshalAs(UnmanagedType.U1)]
    public bool IsPeriodic(out double period);
    public void SetInterval(Interval value);

    // Properties
    public BoundBlock2d BoundBlock { get; }
    public Point2d EndPoint { get; }
    public bool HasEndPoint { [return: MarshalAs(UnmanagedType.U1)] get; }
    public bool HasStartPoint { [return: MarshalAs(UnmanagedType.U1)] get; }
    public BoundBlock2d OrthoBoundBlock { get; }
    public Point2d StartPoint { get; }
}

 
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Proctor

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #6 on: August 18, 2011, 08:21:49 PM »
Thanks again for your help.

Proctor

kaefer

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #7 on: August 19, 2011, 12:47:29 AM »
Here is an example of conversion between Polyline and CompositeCurve2d.

Are you sure you want to go down the Geometry route instead of merely checking if your Point2d is near enough to the ClosestPointTo on your Polyline?

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #8 on: August 19, 2011, 09:48:21 AM »
++

Proctor

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #9 on: August 19, 2011, 10:31:23 AM »
I was just thinking that same thought last night...on my way home from work ...on the freeway.
I think I'll give that a try instead.

Thanks,
Proctor

Proctor

  • Guest
Re: Trying to convert simple polyline to AcGePolyline2d
« Reply #10 on: August 19, 2011, 11:53:28 AM »
GetClosestPointTo works great...and so much easier!!!

thanks for all your help.

Proctor