Leader Vertices - How to modify

Leader Vertices - How to modify

Anonymous
Not applicable
1,706 Views
6 Replies
Message 1 of 7

Leader Vertices - How to modify

Anonymous
Not applicable

How do I interate through the vertices of a leader and update them.

 

I have tried

 

myObjRef.UpgradeOpen()

For i = 0 TomyObjRef.NumVertices - 1

 

Dim MyVertex AsNewGeometry.Point3d(myObjRef.VertexAt(i).X, _

myObjRef.VertexAt(i).Y, _

0.0)

myObjRef.SetVertexAt(i, MyVertex)

Next

 

I had expected properties like StartPoint LastVertex to be updated.

 

Thanks

0 Likes
1,707 Views
6 Replies
Replies (6)
Message 2 of 7

hgasty1001
Advisor
Advisor

Hi,

 

The Leader is like a polyline, so you can List vertex :

 

For i=MyLeader.StartParameter to MyLeaderEndParameter

 Dim p as point3d=Myleader.GetPointAtParameter(i)

 Do your staff

Next

 

Or Append a vertex:

 

Myleader.AppendVertex(New Point3D(x,y,0)

 

And so on, almost the same as a polyline.

 

 

Gaston Nunez

 

 

0 Likes
Message 3 of 7

Anonymous
Not applicable

I am using AutoCAD 2010 and i do not see StartParameter or EndParameter on my leader object.

 

I am retrieving the vertices with my code but find that MyLeader.SetVertex is not setting the vertex as I expected.

 

I have reposted my code below showing how I get MyLeader object

 

ForEach myObjID InmyObjIDs

      Dim myLeader AsDatabaseServices.Leader

       myLeader = myObjID.GetObject(DatabaseServices.OpenMode.ForRead)

       If myLeader.BlockName = "*Paper_Space"Then

              Dim isMyLayerLocked AsBoolean= LayerCheckUnlockForID(myObjID)

              myLeader.UpgradeOpen()

              For i = 0 TomyLeader.NumVertices - 1 

                    Dim MyVertex AsNewGeometry.Point3d(myLeader.VertexAt(i).X, _

                                                                                   myLeader.VertexAt(i).Y, _

                                                                                   0.0)

                     myLeader.SetVertexAt(i, MyVertex)

               Next

               myLeader.Draw()

         EndIf

Next

 

 

 

Regards

Martin

0 Likes
Message 4 of 7

hgasty1001
Advisor
Advisor

Hi,

 

Sorry, the actual names are: StartParam and EndParam. As for your code, i think you are trying to add a duplicate vertex at each node (i), and the leader implementation forbid to add 0 length segments. AppendVertex add a vertex to the end of the vertex list, by other side  SetVertexAt modify the point in the vertex at the given index.

 

Gaston Nunez

0 Likes
Message 5 of 7

Anonymous
Not applicable

Firstly I would like to thank you for your assistance but I am confused by your description.

 

I do not intend to add a vertex.

 

My intention is to reset the z value to 0.0 as this causing us an issue when we get small errors i.e.. Z = 1.07797e-015

 

I thought that is the purpose of

myLeader.SetVertexAt(i, MyVertex)

 

Your description of the function appears to confirm my  thoughts though your interpretation of my code is that I am adding a vertex.

 

I have checked the return value from

myLeader.SetVertexAt(i, MyVertex)

and it returns True so I would have thought the update has been accepted.

 

I rely actrans.commit() to save my edits.

 

Any assistance you can give to explain this would be appreciated.

Message 6 of 7

Anonymous
Not applicable

Use SetVertexAt to replace any point in the list.  Therefore, if you wanted to take point 21 (1,2,3) and change it to (1,2,0) then you use SetVertexAt and specify point 21 and the new value.  But aren't leaders 2D anyway?  they would use 2D points not 3D Points.

 

jvj

0 Likes
Message 7 of 7

Anonymous
Not applicable

I wish it was a 2D point as then my function would not be required.

0 Likes