Author Topic: Mleader - direction of the dogleg  (Read 1681 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 141
Mleader - direction of the dogleg
« on: March 19, 2013, 11:44:00 AM »
Hi everyone,
I am creating a mleader and I am having difficulties with the dogleg, it always goes to the right.  (See picture)
And as soon as I change the location of the text, the dogleg will go in the good direction. 
The text of the mleader is a mtext that the user have select before creating the mleader.  I thought the problem could come from that but I remove the text and just create a basic mleader and dogleg still go to the right.
Thank for your help :) 

Jeff H

  • Needs a day job
  • Posts: 6030
Re: Mleader - direction of the dogleg
« Reply #1 on: March 19, 2013, 12:23:36 PM »
In this crap is a one way to set dogleg
http://www.theswamp.org/index.php?topic=31861.msg452633#msg452633

Code - C#: [Select]
  1. ...................................................................................
  2.  
  3.                double direction = 1.0;
  4.  
  5.               if ((endPoint - startPoint).DotProduct(Vector3d.XAxis) < 0.0)
  6.               {
  7.                   direction = -1.0;
  8.                }
  9. .....................................................................
  10.  
  11.                if (direction > 0)
  12.                {
  13.                    ml.TextAlignmentType = TextAlignmentType.LeftAlignment;
  14.                }
  15.                else
  16.                {
  17.                    ml.TextAlignmentType = TextAlignmentType.RightAlignment;
  18.                }
  19. ............................................................................................
« Last Edit: March 19, 2013, 12:27:40 PM by Jeff H »

latour_g

  • Newt
  • Posts: 141
Re: Mleader - direction of the dogleg
« Reply #2 on: March 19, 2013, 01:26:37 PM »
Thanks Jeff for your answer.  I have already try to change the textalignmenttype.  The result is that text will be justify either to the left or to the right but the dogleg will still always go to the right. What's wrong with those dogleg !

Lee Mac

  • Seagull
  • Posts: 12219
  • London, England
Re: Mleader - direction of the dogleg
« Reply #3 on: March 19, 2013, 02:00:32 PM »
Here is an old example in LISP, maybe you can convert it to C#:

Code - Auto/Visual Lisp: [Select]
  1. ;; MLeader Coordinates  -  Lee Mac
  2. ;; Creates an MLeader object with two vertices displaying the coordinates
  3. ;; of the first selected point expressed relative to the current UCS
  4.  
  5. (defun c:mlp ( / mld pt1 pt2 spc )
  6.    (setq spc
  7.            (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)
  8.        )
  9.    )
  10.    (while
  11.        (and
  12.            (setq pt1 (getpoint "\nPick Point: "))
  13.            (setq pt2 (getpoint "\nPick Endpoint of Leader: " pt1))
  14.        )
  15.        (setq mld (vlax-invoke spc 'addmleader (append (trans pt1 1 0) (trans pt2 1 0)) 0.0))
  16.        (vla-put-textstring mld (strcat "X=" (rtos (car pt1)) "\\PY=" (rtos (cadr pt1))))
  17.        (vla-put-textrotation mld 0.0)
  18.        (if (<= (car pt2) (car pt1))
  19.            (progn
  20.                (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(-1.0 0.0) 1 0 t)))
  21.                (vla-put-textrightattachmenttype mld acattachmentmiddle)
  22.                (vlax-invoke mld 'setleaderlinevertices 0 (append (trans pt1 1 0) (trans pt2 1 0)))
  23.            )
  24.            (progn
  25.                (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(1.0 0.0) 1 0 t)))
  26.                (vla-put-textleftattachmenttype mld acattachmentmiddle)
  27.            )
  28.        )
  29.    )
  30.    (princ)
  31. )

MexicanCustard

  • Swamp Rat
  • Posts: 704
Re: Mleader - direction of the dogleg
« Reply #4 on: March 19, 2013, 04:30:06 PM »
Look at MLeader.SetDogLeg(leaderindex, vector)
Revit 2019, AMEP 2019 64bit Win 10

latour_g

  • Newt
  • Posts: 141
Re: Mleader - direction of the dogleg
« Reply #5 on: March 20, 2013, 04:17:19 PM »
Thanks MexicanCustard, this is what I needed to set. 
I wasn't sure about what I needed to write for the vector and I got my answer here :
http://adndevblog.typepad.com/autocad/2012/06/setting-the-direction-of-the-mleader-text.html

Now those dogleg is going in the good direction.  Thanks everyone, I really appreciate !

 ^-^