Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/23/2024 in all areas

  1. when i use princ brfore the second (cond..) -> (princ lst1) (princ lst2) NIL NIL. So there is nothing.
    1 point
  2. Just a quick look and I might be wrong! The output from the DCL lists will be a number 1, 2, 3, 4 and so on corresponding to the list item you chose - it looks like you are searching for the displayed text for example M4, M5 and so on - I think these will need to be 1, 2, 3 or whatever corresponding to your data at the top of the LISP. Have a check do a (princ lst1) or something to see what the output is
    1 point
  3. oke, so if I change \ to / it works. Thats great thanks!
    1 point
  4. A fence selection will ensure that your selection set is created in the order that the fence is created. That way, you have the right next's and previous'. However, if you want to click them one at a time as stated in the OP, then this will do for now. Though I don't believe it's the most efficient idea around: (defun c:foo ( / *error* acadobj activeundo adoc blk blk_curr blk_prev enx pck spc) ;; --- My Usual Intro --- ;; (defun *error* ( msg ) (vla-EndUndoMark adoc) (if pck (setvar "PICKADD" pck)) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*")) (princ (strcat "Error: " msg)) ) ) (setq acadobj (vlax-get-acad-object) adoc (vla-get-ActiveDocument acadobj) ) (if (= (getvar 'cvport) 1) (setq spc (vla-get-Block (vla-get-ActiveLayout adoc))) (setq spc (vla-get-ModelSpace adoc)) ) (setq pck (getvar "PICKADD")) (setvar "PICKADD" 2) (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T)) ;; --- My Usual Intro --- ;; (while (progn (setvar "errno" 0) (initget "Exit") (setq blk (entsel "\nSelect block in sequence [Exit] <exit>: ")) (cond ( (= (getvar "errno") 7) (princ "\nNothing selected.")) ( (member blk '("Exit" nil)) (setq blk nil)) ( (not (wcmatch (cdr (assoc 0 (setq blk (car blk) enx (entget blk)))) "INSERT")) (princ "\nObject is not a block") ) ( (not (= (cdr (assoc 66 enx)))) (princ "\nBlock does not contain any attributes") ) ( (not blk_prev) (setq blk_prev (vlax-ename->vla-object blk))) ( t (setq blk_curr (vlax-ename->vla-object blk)) (LM:vl-setattributevalue blk_prev "Next" (cond ((LM:vl-getattributevalue blk_curr "ID")) ("No ID Found"))) (LM:vl-setattributevalue blk_curr "Previous" (cond ((LM:vl-getattributevalue blk_prev "ID")) ("No ID Found"))) (setq blk_prev blk_curr) ) ) ) ) ;; --- My Usual Ending --- ;; (setvar "PICKADD" pck) (if (not activeundo) (vla-EndUndoMark adoc)) (princ) ;; --- My Usual Ending --- ;; ) ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ;; Set Attribute Value - Lee Mac ;; Sets the value of the first attribute with the given tag found within the block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; val - [str] Attribute Value ;; Returns: [str] Attribute value if successful, else nil. (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val) ) ) (vlax-invoke blk 'getattributes) ) ) (vl-load-com)
    1 point
×
×
  • Create New...