Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/23/2021 in all areas

  1. I assumed that you are after replacing all text strings in the selected attributed block HDV1_CONVER to selected string from Mtext so here is a draft to see if this meet your aim of the program. (defun c:Test (/ int sel str ent get) ;; Tharwat - 23.Dec.2021 ;; (and (setq sel (car (entsel "\nPick Mtext : "))) (or (= (cdr (assoc 0 (entget sel))) "MTEXT") (alert "invalid object selected. Try again") ) (setq str (cdr (assoc 1 (entget sel)))) (princ (strcat "\nSelect Blocks to replace < HDV1_CONVERT > to replace < " str " > with all attributes with :" ) ) (setq int -1 sel (ssget "_:L" '((0 . "INSERT") (66 . 1) (2 . "HDV1_CONVERT")) ) ) (while (setq int (1+ int) ent (ssname sel int) ) (while (and (setq ent (entnext ent)) (not (eq (cdr (assoc 0 (setq get (entget ent)))) "SEQEND")) ) (and (= (cdr (assoc 0 get)) "ATTRIB") (entmod (subst (cons 1 str) (assoc 1 get) get)) ) ) ) ) (princ) )
    2 points
  2. 1 point
  3. It irks me when an apparently simple drawing exercise should prove not straight forward. After much pondering, I think the dimension of 12 is the red herring and does not add to the information necessary to draw the figure.
    1 point
  4. Doesn't even matter what folder the lisp is in or moved to as long as it's in both the Support File Search Path and Trusted folders the ^C^C(LOAD "polywidthzero.lsp");polywidthzero will work! Relative paths are useful to relate xrefs to the location of the current drawing so they are preserved when moving a project folder with references to subfolders. Why would you use relative paths in loading a lisp macro with no way of knowing what the location of the current drawing is in advance?
    1 point
  5. Relative path... has to be relative to something else. So if I have a drawing saved in "c:\Users\stevenp\mydrawings\adrawing.dwg" then the relative path to that drawing is "c:\Users\stevenp\mydrawings". It might be you save a specific LISP file with the drawing folder and there are ways to set a relative path to the drawing you have open (for example, if I have LISPs specific to Client A, it might make sense to keep them in the folder for Client A with the drawings, all together in one place for 1 client). Or you could define a specific file path for all your LISP files, such as "c:\users\stevenp\AllMyLISPS\" and in the AutoCAD Appload startup suite tell it to open that file in that location, needing to change it every time you move your LISPs or update your CAD version Or you could do as suggested above and save your LISP files in a trusted location, no need to tell AutoCAD where it it saved, it looked in these Trusted locations automatically.
    1 point
  6. Copying and pasting from what I have, this will get you the dimension - might be a long way round but it gave e "L=3000" from your example drawing. You have to select each dimension that you want. Now all you need is how to get the value from this single selected dimension and put it into a table, do you want to modify an existing table or create a new table from a list of selected dimensions? I've also copied in Lee Macs Unformat LISP - from his website and I would always recommend going there to get the latest version rather than what is below (defun c:dynamicdimtext ( / ) (defun getfroment (ent entcodes / acount acounter mytext newtext stringtext) ;;get dotted pairs list (setq entlist (entget ent)) (setq acount 0) (while (< acount (length entlist)) (setq acounter 0) (while (< acounter (length entcodes)) (setq entcode (nth acounter entcodes)) (if (= (car (nth acount entlist)) entcode ) (progn (setq newtext (cdr (nth acount entlist))) (if (numberp newtext)(setq newtext (rtos newtext))) ;fix for real numbers (setq mytext (append mytext (list (cons (car (nth acount entlist)) newtext) )) ) );end progn );end if (setq acounter (+ acounter 1)) );end while (setq acount (+ acount 1)) );end while ;;get string from dotted pair lists (if (> (length mytext) 0) (progn (setq acount 0) (setq temptext "") (while (< acount (length mytext)) (setq temptext (cdr (nth acount mytext)) ) (if (= stringtext nil) (setq stringtext temptext) (setq stringtext (strcat stringtext temptext )) );end if (setq acount (+ acount 1)) );end while );end progn );end if (if (= stringtext nil)(setq stringtext "")) (setq mytext stringtext) mytext ) ;;get text as a string (defun gettextasstring ( enta entcodes / texta ) (if (= (getfroment enta entcodes) "") () (setq texta (getfroment enta entcodes)) ) texta ) ;;get text 1 (setq ent1 (getent "\nSelect Dimension : ")) (setq entlist1 (entget ent1)) (setq entcodes1 (list 4 1 172 304)) (setq text01 (gettextasstring ent1 entcodes1) ) ;Text as string (setq text01 (LM:UnFormat text01 "" )) (princ text01) ) ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; str - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( str mtx / _replace rx ) (defun _replace ( new old str ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace str new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq str (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq str (_replace (car pair) (cdr pair) str)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str)) (_replace "\\" "\032" str) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p str)) str ) ) ) )
    1 point
  7. To many unanswered questions, do you want how many are 3000 long, choose by Layer or sort by layer, what does table look like to mention a few.
    1 point
  8. no need a special editor to do that you need only Hebrew fonts, like .shx or .ttf files, then set a font STYLE to with them. mhupp's solution is better to get .ttf fonts. windows provide them by language setting. or try this attachment Hebrew Basic.ttf Hebrew.shx
    1 point
  9. Try this ; break strings into sets of 3 characters seperated by comma ;By AlanH DEC 2021 ; thanks to Lee-mac for this defun ; www.lee-mac.com ; 44 is comma 32 is space (defun _csv->lst ( str / pos ) (if (setq pos (vl-string-position 44 str)) (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2)))) (list str) ) ) (defun c:commastr ( / ss x obj txt lst val str str2 len) (setq ss (ssget (list (cons 0 "TEXT,MTEXT")))) (if (= ss nil) (progn (alert "NO text found\n\n\n Will now exit")(EXIT)) (repeat (setq x (sslength ss)) (setq lst '()) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq txt (vla-get-textstring obj)) (setq lst (cons (_csv->lst txt) lst)) (setq str "") (foreach val lst (setq val2 (car val)) (setq len (strlen val2)) (setq str (substr val2 (- len 2) 3)) (setq len (- len 3)) (while (> len 3) (setq str2 (substr val2 (- len 2) 3)) (setq str (strcat str2 "," str)) (setq len (- len 3)) ) ) (if (> len 0) (progn (setq str2 (substr val2 1 len)) (setq str (strcat str2 "," str)) ) ) (vla-put-textstring obj str) ) ) (princ) ) (C:commastr)
    1 point
  10. As Tharwat has suggested, an example, single pick, where the dynamic property name is "Length" (setq blk (vlax-ename->vla-object (car (entsel "Pick block")))) (setq len (LM:getdynpropvalue blk "Length")) Your task is to use a selection set instead plenty of examples here.
    1 point
  11. You need to make a selection set then change the entity to vla-object then from the previously posted function you can get the length property once you feed the correct arguments as described in the function.
    1 point
  12. i think this exercise was conceived to problem solve. There was a deliberate anomaly in the given dimensions, and full marks to whoever produced an "acceptable" solution. But zero marks if the solution was sought on Forums!!
    1 point
  13. I have just realised that when one uses the TTR option for drawing a circle, you do not have to activate the Tangent snap, the command does it for you.
    1 point
  14. hello i managed to make it work, thank you all from my heart! (LOAD "C:/Users/Utente/Dropbox/Lavoro/backup/AUTOCAD/Lisp/PURGE/RSHX.lsp");RSHX; many thanks
    1 point
  15. Use the filter command then select all and change the dimensions in the properties palette.
    1 point
  16. Try thiS LISP Export-Table-to-excel _ LispBox .LSP
    1 point
×
×
  • Create New...