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

How to set Polyline.StartPoint ?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
pva75
1740 Views, 3 Replies

How to set Polyline.StartPoint ?

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

3 REPLIES 3
Message 2 of 4
Hallex
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
Message 3 of 4
pva75
in reply to: Hallex

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

 

Pavel.

Message 4 of 4
Hallex
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

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