Jump to content
wimal

Points of leader

Recommended Posts

wimal

(setq pt(nentsel (strcat "\n Select a leader  < exit > : ")));get entity
(setq e (entget (car pt)));;association list of entity
(setq p1 (assoc 10 e))

 

How can I get 3 points of leader.

leader.PNG

Share this post


Link to post
Share on other sites
tombu
Posted (edited)

Use the lisp function MEMBER It searches a list for an occurrence of an expression and returns the remainder of the list, starting with the first occurrence of the expression so:

(defun C:test (/ e pt p2 p3)
(setq pt(nentsel (strcat "\n Select a leader  < exit > : "))
      e (entget (car pt));;association list of entity
      e (member (assoc 10 e) e)
      p1 (cdr (assoc 10 e));; cdr removes the 10 leaving the coordinates.
      e (cdr e)
      p2 (cdr (assoc 10 e))
      e (cdr e)
      p3 (cdr (assoc 10 e))
)
       (princ "\np1=")(princ p1)(princ ", p2=")(princ p2)(princ ", p3=")(princ p3)(princ)
)

should return what you're looking for.

You may want to search for qlset.lsp by Frank Whaley who worked for Autodesk. This code allows you to examine the current QLEADER settings, or to initialize the setting before using the QLEADER command. It can tell you how many points the leader has for example. Not everyone uses the default settings.

Edited by tombu
Added output

Share this post


Link to post
Share on other sites
Grrr

First define a function that will check for that group code key, and return its value:

(defun IsItDxf10 ( x )
 (if (= (car x) 10) (cdr x))
)

 

Second learn how to use vl-remove-if-not function to retrieve the items from the list that match the function's criteria.

Assuming that you know the dxf elist is obtained via (entget ).

Share this post


Link to post
Share on other sites
Lee Mac

Use a method similar to that which I describe here.

Share this post


Link to post
Share on other sites
wimal

Thanks all fore helping me.:D

Share this post


Link to post
Share on other sites
wimal

Now I need to feed new value to third point of the leader. How can do that. Pl.help

Share this post


Link to post
Share on other sites
Lee Mac
Now I need to feed new value to third point of the leader. How can do that. Pl.help

 

 

You could use a function similar to the following:

(defun substnthkey ( idx key val lst / cnt )
   (setq cnt -1)
   (mapcar
       (function
           (lambda ( itm )
               (cond
                   (   (/= key (car itm)) itm)
                   (   (/= idx (setq cnt (1+ cnt))) itm)
                   (   (cons key val))
               )
           )
       )
       lst
   )
)

Example:

_$ (substnthkey 1 10 '(0 0 0) '((1 . "A") (2 . "B") (10 1 2 3) (3 . "C") (10 2 3 4) (4 . "D") (10 3 4 5)))
((1 . "A") (2 . "B") (10 1 2 3) (3 . "C") (10 0 0 0) (4 . "D") (10 3 4 5))

This could also be written recursively:

(defun substnthkey-rec ( idx key val lst )
   (cond
       (   (null lst) nil)
       (   (or (/= key (caar lst)) (< -1 (setq idx (1- idx))))
           (cons (car lst) (substnthkey-rec idx key val (cdr lst)))
       )
       (   (cons (cons key val) (cdr lst)))
   )
)

Share this post


Link to post
Share on other sites
Grrr

Thumbs up, Lee! :thumbsup:

Share this post


Link to post
Share on other sites
Lee Mac

Thanks Grrr :)

Share this post


Link to post
Share on other sites
wimal

Thanks Mr Lee Mac

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×