Jump to content

Leaderboard

  1. GLAVCVS

    GLAVCVS

    Community Member


    • Points

      4

    • Posts

      669


  2. Steven P

    Steven P

    Trusted Member


    • Points

      3

    • Posts

      2,824


  3. Tomislav

    Tomislav

    Community Member


    • Points

      2

    • Posts

      208


  4. BIGAL

    BIGAL

    Trusted Member


    • Points

      1

    • Posts

      19,664


Popular Content

Showing content with the highest reputation on 05/27/2025 in Posts

  1. Although it may complicate the explanation a bit, as StevenP shows in his examples, it is also possible to apply the modifier code to multiple lists, but with two important considerations in mind: - all lists should have the same number of elements because the result of the operations will stop at the last element of the shortest list - the result of the operations will be performed, each time, on the same ordinal elements of each list, returning a result for each operation and adding them to a result list that will be returned at the end of all operations
    2 points
  2. Nikon, I'd consider adding a check that a suitable text was selected, quick and dirty like this: ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) Though of course if no mtext can be selected or the user changes their mind escape is the only way out so be wary of variables and error functions if needed. If the text strings are always short (under 250 characters) your code can be shortened to something like this I think. The second ssget you can use a wildcard "*TEXT" to get all text types. (defun c:test ( / ) ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) ;;get text string. Assuming the search text is less than 250 characters else use another method (setq MyText (cdr (assoc 1 (entget myent)))) ;;get a selection set. Again assuming text strings less then 250 characters. (princ "\nNow select texts to search: ") (setq MySS (ssget (list (cons 0 "MTEXT")(cons 1 (strcat "*" MyText "*"))))) ;; do what you want here with MySS (princ) ) a slight different take on yours for longer texts which should work for LT too (defun c:test ( / MyText MySS FinalSS acount) ;;Loop till a mtext is selected. (while (not (equal (assoc 0 (entget (setq MyEnt (car (entsel "Select Mtext"))))) '(0 . "MTEXT") )) (princ "\nNo, Please ") ) (setq MyText (cdr (assoc 1 (entget myent)))) ;; selected text string ;;Get the texts to search. (princ "\nNow select texts: ") (setq MySS (ssget (list (cons 0 "*TEXT")))) ;; Loop through texts adding to selection set where text is found (setq acount 0) (setq FinalSS (ssadd)) (while (< acount (sslength MySS)) (setq MyEnt (entget (ssname MySS acount))) (if (or (wcmatch (strcase (cdr (assoc 1 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; last 250 characters (if (cdr (assoc 3 MyEnt))(progn (wcmatch (strcase (cdr (assoc 3 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; first 250 characers (wcmatch (strcase (cdr (assoc 3 MyEnt))) (strcat "*" (strcase Mytext) "*" )) ;; Middle 250 characters )) ; end if, end progn assoc 3 ) ; endor (progn ;; found (setq FinalSS (ssadd (ssname MySS acount) FinalSS) ) ) (progn ;; not found ) ) ; end if (setq acount (+ acount 1)) ) ; end while ;; do what you want here with found texts FinalSS )
    1 point
  3. I think the problem exists elsewhere in the program - it looks like an extra "" is perhaps being issued to the command line and repeating the WBLOCK command.
    1 point
  4. Just stab in the dark... Perhaps try changing (while) loop to (repeat) loop... ; Block make (entmake (list (cons 0 "BLOCK") (cons 10 pt) (cons 2 bn) (cons 70 0))) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) elist (entget ent)) (entmake elist) ) (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))
    1 point
  5. just found out when I execute one lisp it creates dcl with correct name but with contents for dcl from another lisp, so something with same dcl file name definitions or something
    1 point
  6. @Steven P I'm not doing it for company , and I will try what they suggested ... @SLW210 that's very usefull thread for some new view on things, thanx...
    1 point
  7. (mapcar '(lambda (x y) (/ (float x)(float y))) (list 2 4 6 8) (list 1 3 7 9)) (mapcar (function (lambda (x y) (/ (float x)(float y)))) (list 2 4 6 8) (list 1 3 7 9)) (defun my-funk (x y)(/ (float x)(float y))) (mapcar 'my-funk (list 2 4 6 8) (list 1 3 7 9)) ;;; -> (2.0 1.33333 0.857143 0.888889)
    1 point
  8. I like mapcar - LISP is a list processing language and mapcar is great for lists. A couple of examples (setq Answer (mapcar 'Modifier' 'List to process 1' 'List to process 2' )) format (setq Answer (mapcar '* '(1 1 0) '(15 20 25) )) ;;modifier is multiply list 1 by list 2 - list 2 is a coordinate, here set z to 0... flatten in ---> Answer: (15 20 0) (setq Answer (mapcar '+ '(15 0 0) '(15 20 25) )) ;;modifier is multiply list 1 by list 2 - list 2 is a coordinate, offset X direction ---> Answer: (30 20 25) (setq Answer (mapcar 'strcase '("adam" "ben" "claire" "david"))) ;; Modifier is a function, strcase applied to all in the list ---> Answer: ("ADAM" "BEN" "CLAIRE" "DAVID") That last example was shamelessly taken from Lee Macs tutorial: https://lee-mac.com/mapcarlambda.html
    1 point
  9. Like @marko_ribar I use a convert to lisp by RLX. I use it to make custom dcl's, taking advantage of my Multi xxx lisps to write a dcl. Then convert it to lisp. Then just use notepad etc to add the dcl to your code. Speaking of that did you know you can have one dcl with multiple dcl's inside of it, You just load the master and call the sub dcl. Just a comment if you bomb a lisp with a dcl made using Mktemp it will leave the temporary dcl behind, just check your temp directory you may be horrified to see how many are there along with SV$, dwl, AC$ and more. Options File "Save File Path" "temporary Prefix" So having a (vl-file-delete fname) in code and in Error trap is a good idea. Yes have a cleanup lisp. (setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object)))) (setq pre (vla-get-TempFilePath *files*)) Convert dcl 2 lisp rlx.lsp
    1 point
  10. Note: Note that the iteration uses foreach, not vlax-for. This is to make the code compatible with older versions of AutoCAD.
    1 point
  11. Maybe this will help you (defun c:altObjs (/ cj a e l n at vlaObj) (if (setq a (getreal "\nNew height for (M)Texts/attributes: ")) (if (setq cj (ssget '((0 . "*TEXT,INSERT")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (if (wcmatch (cdr (assoc 0 (setq l (entget e)))) "*TEXT") (entmod (subst (cons 40 a) (assoc 40 l) l)) (if (= (vla-get-hasAttributes (setq vlaObj (vlax-ename->vla-object e))) :vlax-true) (foreach at (vlax-safearray->list (variant-value (vla-getattributes vlaObj))) (vla-put-Height at a) ) ) ) ) ) ) (princ) )
    1 point
×
×
  • Create New...