.NET

Reply
Active Contributor
pva75
Posts: 48
Registered: ‎07-22-2012
Message 1 of 4 (354 Views)
Accepted Solution

How to set Polyline.StartPoint ?

354 Views, 3 Replies
08-12-2012 01:48 PM

I tried to set Polyline.StartPoint to new position (Point3d):

 

Polyline.StartPoint = myNewPoint3d;

 

I have "not implemented" exception.

 

Also, I tried to do it as:

 

var seg0 = acEnt.GetLineSegmentAt(0);

seg0.Set(newPoint3d(0, 0, 0), seg0.EndPoint);

 

It doesn't work also.

 

I can do it as:

 

acEnt.SetPointAt(0, my2dPoint);

 

But it's 2D point, not 3d

 

Of course I can remove polyline and create it again, but...

 

How to set start point correctly for 3d point?

 

Pavel

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (352 Views)

Re: How to set Polyline.StartPoint ?

08-12-2012 02:16 PM in reply to: pva75

Here is a quick and dirty snip you will be use as framework,

change to your suit

 

   [CommandMethod("SPT")]  
        public void chageStartPoint()
        {
                PromptEntityOptions peo = new PromptEntityOptions("\nSelect a segment where to add a vertex: ");
            peo.SetRejectMessage("\nIncorrect entity"); 
            peo.AllowNone = false; 
            peo.AllowObjectOnLockedLayer = false;
            peo.AddAllowedClass(typeof(Polyline), true);
            PromptEntityResult per = ed.GetEntity(peo); 
            if (per.Status == PromptStatus.OK) 
            {
 
                ObjectId id = per.ObjectId; 
                try 
                { 
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    { 
                        Polyline pline = tr.GetObject(id, OpenMode.ForRead, false) as Polyline; 
                        if (pline != null)
                        {
                            pline.UpgradeOpen();
                            Point3d pt = ed.GetPoint("\nPick new start point location: ").Value;
                            Point2d sp = pt.Convert2d(new Plane(Point3d.Origin, pline.Normal));
                            pline.AddVertexAt(0, sp, 0, pline.ConstantWidth, pline.ConstantWidth);
                            pline.RemoveVertexAt(1);

                        }
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                
                    ed.WriteMessage( ex.Message);
                }
            }
        } 

 

~'J'~

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Contributor
pva75
Posts: 48
Registered: ‎07-22-2012
Message 3 of 4 (330 Views)

Re: How to set Polyline.StartPoint ?

08-12-2012 09:42 PM in reply to: Hallex

Thanks a lot! I think it will work for me.

 

Pavel.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 4 (321 Views)

Re: How to set Polyline.StartPoint ?

08-13-2012 12:55 AM in reply to: pva75

You need to extend this code

Add in there the part to work with different

coordinate system etc

You're welcome

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community