Jump to content

Points of leader


wimal

Recommended Posts

(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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 ).

Link to comment
Share on other sites

  • 3 weeks later...
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)))
   )
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...