Results 1 to 6 of 6

Thread: how to get nentselp working correctly

  1. #1
    Member
    Join Date
    2018-07
    Posts
    5
    Login to Give a bone
    0

    Default how to get nentselp working correctly

    Code:
    (defun C:relfq (/)
      (setvar "cmdecho" 0)
      (prompt "Selecting all Mleaders on layer : \"text-fqnid\"")
      (setq ITEMS (ssget "X" (list '(0 . "MULTILEADER")'(8 . "TEXT_FQNID")))) 
      (setq i (sslength ITEMS)) 
      (while (> i 0)
        (defun massoc	(key EntData / x nlist)
          (foreach x EntData
            (if (eq key (CAR x))
             (setq nlist (cons (cdr x) nlist))
            ) ;_ end of if
          ) ;_ end of foreach
          (reverse nlist)
        ) ;_ end of DEFUN
        (setq i (1- i)) 
        (setq EN (ssname ITEMS i)) 
        (setq data (entget EN))
        (setq lyr (cdr (assoc 8 data)))
        (setq leader-10-list (massoc 10 data))
        (setq pt1 (nth 2 leader-10-list))
        (setq pt2 (nth 1 leader-10-list)) 
        (setq pt3 '(pt1))
        (setq source_obj (nentselp pt3)) ;;; this is the problem section
          (if (null source_obj)
            (prompt "\nNo source object selected.")
            (progn
              (setq tbl (ade_odgettables source_obj))
              (setq fqnid (ade_odgetfield source_obj tbl  "FQN_ID" 0)) 
              (setq clength (rtos (ade_odgetfield source_obj tbl "CALCULATED" 0) 2 2))
              (setq fibercnt (rtos (ade_odgetfield source_obj tbl "NUMBEROFFI" 0) 2 0))
              (setq wrkord (ade_odgetfield source_obj tbl "WORKORDERI" 0))
              (setq fqnidstr (strcat "\nFQNID#: " fqnid)) 
              (setq clengthstr (strcat "\nLENGTH: " clength " FT"))
              (setq fibercntstr (strcat "\nFIBER SIZE: " fibercnt))
              (setq wrkordstr (strcat "\nWORK ORDER: " wrkord))
              (setq str (strcat fqnidstr clengthstr fibercntstr wrkordstr))
              (command "erase" EN "")
              (command "mleader" pt1 pt2 str)
            );progn
          );if
      );while
      (setvar "cmdecho" 1)
      (princ)
    ) ;defun


    i have built this routine - what it should be doing is "re-labeling" all mleaders on the text_fqnid layer
    the labels are coming from data pulled with an nentselp to get object data from an xreffed line.
    this is intended to re-do labels if the object data changes by deleting the original mleader and remaking one in the same exact location. a required rule for using this that the first point of the mleader must o-snapped to the line being referenced.
    this should allow me to plug in the value for pt1 into the nentselp to use that point.

    this is where i am having trouble making the code work - i am getting errors like " error: bad argument type: 2D/3D point: (PT1)"
    what do i need to change to get this running smoothly??

  2. #2
    Member
    Join Date
    2018-07
    Posts
    5
    Login to Give a bone
    0

    Default Re: how to get nentselp working correctly

    also :
    just calling =
    (setq source_obj (nentselp pt1))
    returns error : "error: bad argument type: numberp: nil"

  3. #3
    Member
    Join Date
    2018-07
    Posts
    5
    Login to Give a bone
    0

    Default Re: how to get nentselp working correctly

    also:
    Code:
      (setq pts (vlax-invoke (vlax-ename->vla-object en) 'getleaderlinevertices 0))
        (setq pt1 (list (car pts) (cadr pts) (caddr pts)))
        (setq pt2 (list (car (setq pts (cdddr pts))) (cadr pts) (caddr pts)))
    		(setq ptlst '((car pt1)(cadr pt1)(caddr pt1)))
        (setq source_obj (nentselp (ptlst)))
    (spit-balling trying to get nentselp to read the three points of pt1)

    returns "error: too few arguments"

  4. #4
    Member
    Join Date
    2018-07
    Posts
    5
    Login to Give a bone
    0

    Default Re: how to get nentselp working correctly

    tried using dxf code to get the points differently - nentselp doesnt like that ether

    Code:
    (defun C:RELFQ (/)
      (setvar "cmdecho" 0)
      (prompt "Selecting all Mleaders on layer : \"TEXT_FQNID\"")
      (setq ITEMS (ssget "X" (list '(0 . "MULTILEADER")'(8 . "TEXT_FQNID"))))
      (setq i (sslength ITEMS))
      (while (> i 0)
        (defun massoc	(key EntData / x nlist)
          (foreach x EntData
            (if (eq key (CAR x))
             (setq nlist (cons (cdr x) nlist))
            )
          )
          (reverse nlist)
        )
        (setq i (1- i))
        (setq EN (ssname ITEMS i))
        (setq data (entget EN))
        (setq lyr (cdr (assoc 8 data)))
        (setq leader-10-list (massoc 10 data))
        (setq pt1 (nth 2 leader-10-list))
        (setq pt2 (nth 1 leader-10-list))
        (setq source_obj (nentselp (pt1)))
        (setq tbl (ade_odgettables source_obj))
        (setq fqnid (ade_odgetfield source_obj tbl  "FQN_ID" 0))
        (setq clength (rtos (ade_odgetfield source_obj tbl "CALCULATED" 0) 2 2))
        (setq fibercnt (rtos (ade_odgetfield source_obj tbl "NUMBEROFFI" 0) 2 0))
        (setq wrkord (ade_odgetfield source_obj tbl "WORKORDERI" 0))
        (setq fqnidstr (strcat "\nFQNID#: " fqnid))
        (setq clengthstr (strcat "\nLENGTH: " clength " FT"))
        (setq fibercntstr (strcat "\nFIBER SIZE: " fibercnt))
        (setq wrkordstr (strcat "\nWORK ORDER: " wrkord))
        (setq str (strcat fqnidstr clengthstr fibercntstr wrkordstr))
        (command "erase" EN "")
        (command "mleader" pt1 pt2 str)
      );while
      (setvar "cmdecho" 1)
      (alert "RELFQ : COMPLETE")
      (princ)
    ) ;defun

  5. #5
    Member
    Join Date
    2018-07
    Posts
    5
    Login to Give a bone
    0

    Default Re: how to get nentselp working correctly

    Code:
    (defun C:RELFQ7 (/)
      (setvar "cmdecho" 0)
      (prompt "Selecting all Mleaders on layer : \"TEXT_FQNID\"")
      (setq ITEMS (ssget "X" (list '(0 . "MULTILEADER")'(8 . "TEXT_FQNID"))))
      (setq i (sslength ITEMS))
      (while (> i 0)
        (defun massoc	(key EntData / x nlist)
          (foreach x EntData
            (if (eq key (CAR x))
             (setq nlist (cons (cdr x) nlist))
            )
          )
          (reverse nlist)
        )
        (setq i (1- i))
        (setq EN (ssname ITEMS i))
        (setq data (entget EN))
        (setq lyr (cdr (assoc 8 data)))
        (setq leader-10-list (massoc 10 data))
        (setq pt1 (nth 2 leader-10-list))
        (setq pt2 (nth 1 leader-10-list))
    		(setq source_obj (nentselp pt1))
    		(if (null source_obj)
    	    (prompt "\nNo source object selected.")
    	    (progn
    				(setq lst (ade_odgettables source_obj))
    	      (setq fqnid (ade_odgetfield source_obj lst "FQN_ID" 0))
    	      (command "mleader" pt1 pt2 fqnid)
    	    );progn
    	    );if
        (print pt1)
      );while
      (setvar "cmdecho" 1)
      (alert "RELFQ : COMPLETE")
      (princ)
    ) ;defun

    well i got this to test and work - but its not pulling the data for nentselp
    i think this is because the number being given back is scientific and is rounded,
    the returned value from the lisp being -
    (2.61436e+06 1.26179e+06 0.0)
    and the real start point of the leader being
    (2614364.09040, 1261791.96721, 0.0)

    what is the best way around this?

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: how to get nentselp working correctly

    Hi,

    A few notes if you don't mind:

    1- Move the function massoc out of while loop since this function would be loaded as per the quantity of selected Mleaders although it is needed to be loaded only once.
    2- Add IF function before the selection set to guarantee is that the selection set is not null otherwise you'd receive an error message with the second line of codes right after that.
    3- Localize your variables to avoid any mixed up with any variable that may match in other routines or so.
    4- Finally, the nentselp function will not be able to select any object based on a list of coordinates if that coordinate list is not visible in the screen limits so a zoom extents is required to obtain that position.

    Good luck and happy coding.

Similar Threads

  1. Roof cut(s) not working correctly
    By robert.manna in forum Revit Architecture - General
    Replies: 0
    Last Post: 2008-09-16, 02:17 AM
  2. Esc key not working correctly
    By dwain in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2008-04-11, 02:08 AM
  3. Help with using entsel or nentselp
    By MWKINCAID1 in forum AutoLISP
    Replies: 3
    Last Post: 2007-03-10, 12:10 AM
  4. Palettes not working correctly
    By briant in forum ACA General
    Replies: 2
    Last Post: 2005-06-30, 10:12 PM
  5. Lisp not working correctly
    By BCrouse in forum AutoLISP
    Replies: 4
    Last Post: 2005-04-22, 09:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •