Author Topic: Determining coordinates of a point arrow mulileader  (Read 4973 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Determining coordinates of a point arrow mulileader
« on: February 27, 2015, 07:30:51 AM »
I tried google but I only found examples to create a multileader.
I would, however, find the coordinates of the point of the arrow.

In the list of properties obtained with (vlax-dump-object) I do not see this property.
In the list (entget) I see coordinates below a list 10 but there are many lists 10, how I can only differentiate the correct one?

Any suggestions?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Determining coordinates of a point arrow mulileader
« Reply #1 on: February 27, 2015, 09:40:06 AM »
Look into vla-GetLeaderLineVertices
Code - Auto/Visual Lisp: [Select]
  1. (setq o (vlax-ename->vla-object (car (entsel "\nPick an mleader: "))))
  2. (vla-getleaderlinevertices o 0)
  3. ;; Returns #<variant XXXX ...>
  4. (vlax-invoke o 'getleaderlinevertices 0)
  5. ;; Vlax-invoke bypasses the need to convert a variant value
  6. ;; Returns (2.70946e+006 1.31026e+006 0.0 2.70951e+006 1.31027e+006 0.0)
« Last Edit: February 27, 2015, 09:44:17 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Determining coordinates of a point arrow mulileader
« Reply #2 on: February 27, 2015, 12:29:36 PM »
If you did want to go the 'Vanilla' route:
Code - Auto/Visual Lisp: [Select]
  1. (defun mleaderarrowpoint ( ent )
  2.     (cdr (assoc 10 (cdr (member '(304 . "LEADER_LINE{") (entget ent)))))
  3. )

Lupo76

  • Bull Frog
  • Posts: 343
Re: Determining coordinates of a point arrow mulileader
« Reply #3 on: February 27, 2015, 01:00:38 PM »
Look into vla-GetLeaderLineVertices
Code - Auto/Visual Lisp: [Select]
  1. (setq o (vlax-ename->vla-object (car (entsel "\nPick an mleader: "))))
  2. (vla-getleaderlinevertices o 0)
  3. ;; Returns #<variant XXXX ...>
  4. (vlax-invoke o 'getleaderlinevertices 0)
  5. ;; Vlax-invoke bypasses the need to convert a variant value
  6. ;; Returns (2.70946e+006 1.31026e+006 0.0 2.70951e+006 1.31027e+006 0.0)

Thank You!
I solved!

Trivia: There is a document or a guide with a list of functions (eg. Vla-getleaderlinevertices) broken down by type of entity to which they are applicable?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Determining coordinates of a point arrow mulileader
« Reply #4 on: February 27, 2015, 01:10:11 PM »
Use this to get properties:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:vlaxprop (/ o)
  2.   (if (setq o (car (entsel "\nSelect object to show data: ")))
  3.     (vlax-dump-object (vlax-ename->vla-object o) t)
  4.   )
  5.   (textscr)
  6. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lupo76

  • Bull Frog
  • Posts: 343
Re: Determining coordinates of a point arrow mulileader
« Reply #5 on: February 27, 2015, 01:16:21 PM »
Use this to get properties:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:vlaxprop (/ o)
  2.   (if (setq o (car (entsel "\nSelect object to show data: ")))
  3.     (vlax-dump-object (vlax-ename->vla-object o) t)
  4.   )
  5.   (textscr)
  6. )

You're right!
I already know this code.

I asked this because I had not seen 'Vla-getleaderlinevertices' list. Sorry

Lupo76

  • Bull Frog
  • Posts: 343
Re: Determining coordinates of a point arrow mulileader
« Reply #6 on: March 09, 2015, 01:40:39 PM »
If you did want to go the 'Vanilla' route:
Code - Auto/Visual Lisp: [Select]
  1. (defun mleaderarrowpoint ( ent )
  2.     (cdr (assoc 10 (cdr (member '(304 . "LEADER_LINE{") (entget ent)))))
  3. )

Hello Lee,
I found the following code:
Code: [Select]
(setq listcoord (vl-remove-if-not '(lambda (x)(equal (car x) 10))(entget ent1)))
to determine the list of the coordinates.
Now I would like to use (entmod) to replace them with other coordinates.
How can I do? Whereas all the coordinates belong to the group with the same name 10.  :cry:?
« Last Edit: March 09, 2015, 02:06:59 PM by Lupo76 »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Determining coordinates of a point arrow mulileader
« Reply #7 on: March 09, 2015, 03:43:39 PM »
Are you just trying to modify the endpoint of the mleader?
Code - Auto/Visual Lisp: [Select]
  1. (setq o (vlax-ename->vla-object (car (entsel "\nPick an mleader: "))))
  2. (setq l (vlax-invoke o 'getleaderlinevertices 0))
  3. ;; Vlax-invoke bypasses the need to convert a variant value
  4. ;; Returns (2.70946e+006 1.31026e+006 0.0 2.70951e+006 1.31027e+006 0.0)
  5. (setq p (getpoint "\nPick a point: "))
  6. ;; Change leader endpoint to picked point
  7. (vlax-invoke o 'setleaderlinevertices 0 (append p (cdddr l)))
« Last Edit: March 09, 2015, 03:59:29 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lupo76

  • Bull Frog
  • Posts: 343
Re: Determining coordinates of a point arrow mulileader
« Reply #8 on: March 10, 2015, 03:22:49 AM »
Are you just trying to modify the endpoint of the mleader?
Code - Auto/Visual Lisp: [Select]
  1. (setq o (vlax-ename->vla-object (car (entsel "\nPick an mleader: "))))
  2. (setq l (vlax-invoke o 'getleaderlinevertices 0))
  3. ;; Vlax-invoke bypasses the need to convert a variant value
  4. ;; Returns (2.70946e+006 1.31026e+006 0.0 2.70951e+006 1.31027e+006 0.0)
  5. (setq p (getpoint "\nPick a point: "))
  6. ;; Change leader endpoint to picked point
  7. (vlax-invoke o 'setleaderlinevertices 0 (append p (cdddr l)))

Sorry I forgot to write.
I can not use setleaderlinevertices, because there is a bug in BricsCAD.
This bug will be fixed in the next version, but I would like my application to be backwards compatible.
So I must use (entmod).

Any suggestions?
There is a function to change the first or the second or the third pair pointed with code 10?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Determining coordinates of a point arrow mulileader
« Reply #9 on: March 10, 2015, 05:01:29 AM »
If you did want to go the 'Vanilla' route:
Code - Auto/Visual Lisp: [Select]
  1. (defun mleaderarrowpoint ( ent )
  2.     (cdr (assoc 10 (cdr (member '(304 . "LEADER_LINE{") (entget ent)))))
  3. )

Hello Lee,
I found the following code:
Code: [Select]
(setq listcoord (vl-remove-if-not '(lambda (x)(equal (car x) 10))(entget ent1)))
to determine the list of the coordinates.
Now I would like to use (entmod) to replace them with other coordinates.
How can I do? Whereas all the coordinates belong to the group with the same name 10.  :cry:?
@ Lupo: Your code will return more group 10 subs than there are arrows.

Following Lee's example you will need something like this:
Code: [Select]
(defun MleaderCoordsGet (ename / elist return)
  (setq elist (entget ename))
  (while (setq elist (cdr (member '(304 . "LEADER_LINE{") elist)))
    (setq return (cons (cdr (assoc 10 elist)) return))
  )
  (reverse return)
)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Determining coordinates of a point arrow mulileader
« Reply #10 on: March 10, 2015, 05:13:13 AM »
Any suggestions?
There is a function to change the first or the second or the third pair pointed with code 10?
Perhaps this?:
Code: [Select]
; (MleaderCoordsSetSingle (car (entsel)) 0 '(20.0 10.0 0.0))
(defun MleaderCoordsSetSingle (ename idx pt / cnt doneP)
  (setq cnt -1)
  (entmod
    (mapcar
      '(lambda (sub)
        (cond
          (doneP
            sub
          )
          ((equal sub '(304 . "LEADER_LINE{"))
            (setq cnt (1+ cnt))
            sub
          )
          ((and (= idx cnt) (= 10 (car sub)))
            (setq doneP T)
            (cons 10 pt)
          )
          (T
            sub
          )
        )
      )
      (entget ename)
    )
  )
)

Edit: Added doneP variable to avoid changing gc 10 items after the final arrow coordinates.
« Last Edit: March 10, 2015, 05:27:59 AM by roy_043 »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Determining coordinates of a point arrow mulileader
« Reply #11 on: March 10, 2015, 11:50:19 AM »
Here's one to entmod all leader points:
Code - Auto/Visual Lisp: [Select]
  1. (defun _mleaderset (ename point / i el)
  2.   (setq i -1)
  3.   (if (and (= (type ename) 'ename) (= (type point) 'list))
  4.     (entmod (mapcar '(lambda (x)
  5.                        (setq i (1+ i))
  6.                        (if (and (= (car x) 10) (equal (nth (1- i) el) '(304 . "LEADER_LINE{")))
  7.                          (cons 10 point)
  8.                          x
  9.                        )
  10.                      )
  11.                     (setq el (entget ename))
  12.             )
  13.     )
  14.   )
  15. )
  16. (_mleaderset (car (entsel)) (getpoint))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC