Friday, October 12, 2012

MLeader Direction

Adding multileaders to a drawing is fairly easy, one tricky item that isn’t quite evident is how to set the direction of the mLeader, where the mleader goes from left to right or right to left. In order to do this we can check the start point and the end point of the leader. In the small code snippet below I’m creating a vector that goes from left to right, if the start point to end point shows I need to go in the opposite direction then I make a vector to reflect this.

                        MLeader mld = new MLeader();
int ldNum = mld.AddLeader();
int lnNum = mld.AddLeaderLine(ldNum);
mld.AddFirstVertex(lnNum, poly.GetPoint3dAt((int)selectedPolyVertexParam));
mld.AddLastVertex(lnNum, endPt);

Vector3d vecDir = new Vector3d(1, 0, 0);
if ((endPt.X - poly.GetPoint3dAt((int)selectedPolyVertexParam).X) < 0)
vecDir = new Vector3d(-1, 0, 0);
mld.SetDogleg(0, vecDir);

Then the code sets the dog leg based on that direction. In my example I only have one leader, but if you have more you will need to make sure you apply the dog leg to the correct leader, rather then the first one in the code above.

No comments:


Blog Widget by LinkWithin