Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/09/2022 in all areas

  1. That's correct. I'm sorry to about that. I misunderstood that the coordinates obtained by (assoc 10) in the text, are "points". As you said, when I (princ), there was a 10 value in the front. ((10 xxxx yyyy zzzz)(10 xxxx yyyy zzzz)(10 xxxx yyyy zzzz)) So, I modified the code as follows, and it succeeded. thank you very much (defun c:DFT( / *error* seltxt selcount selnum old_osmode ob count a5 bas name xxlist enti1 enti2 dxy x xx y yy xy finded num pcolor seldxy selx selxx sely selyy selxy ) (setvar "cmdecho" 0) (command "ucs" "w") (command "_undo" "_be") (defun *error*(e) (command "_undo" "_e") (princ) ) (setq old_osmode (getvar "osmode")) (setvar "osmode" 0) (setq scolor 1) ;set line's default color (setq seltxt (ssget '((0 . "text,mtext")))) (setq selcount (sslength seltxt)) (setq selnum 0) (setq finded 0) (setq ob (ssget "x" '((0 . "text,mtext")))) (setq count (sslength ob)) (repeat selcount (setq a5 (cdr (assoc 1 (entget (ssname seltxt selnum))))) (setq seldxy (assoc 10 (entget (ssname seltxt selnum)))) (setq selx (nth 1 seldxy)) (setq sely (nth 2 seldxy)) (setq seldxypoint (list selx sely)) (setq num 0) (repeat count (setq name (ssname ob num)) (setq xxlist (entget name)) (progn (setq enti1 (cdr (assoc -1 xxlist))) (setq text2 (cdr (assoc 1 xxlist))) (setq dxy (assoc 10 xxlist)) (setq x (nth 1 dxy)) (setq y (nth 2 dxy)) (setq dxypoint (list x y)) (if (wcmatch (strcase (LM:UnFormat text2 nil))(strcat "*" (strcase (LM:UnFormat a5 nil)) "*")) (if (/= seldxy dxy) (progn (setq pointlist (list dxypoint seldxypoint)) (LWPoly pointlist 0) (vlax-put-property (vlax-ename->vla-object (entlast)) "Color" scolor) (setq finded (+ finded 1)) );progn );if );if );progn (setq num (+ num 1)) );repeat (setq selnum (+ selnum 1)) (setq scolor (+ scolor 1)) );repeat (prompt (strcat "\n The number of duplicate texts = " (rtos finded) " ea")) (if ( = finded 0 ) (alert "There's no duplicated texts.")) (command "_undo" "_e") (setvar "osmode" old_osmode) (princ) (command "ucs" "p") (princ) );end_defun ;;-------------------=={ 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 ) ) ) ) (vl-load-com) (defun LWPoly (lst cls) ; LM's entmake functions (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) )
    1 point
  2. So when you were trying to work out what was going wrong, what did you find - it will save us all a little time if you don't end with "this doesn't work" but if you can add details such as "this doesn't work and think this is the problem" For example, does it call the LWPoly routine OK?.. working out where it all goes wrong. If it does then just put a temporary line in there "(princ lst)" to check what values are being passed to it, suspect that will give you the answer.....
    1 point
  3. Having opened the drawing, I think that you have been scaling in Paper space. In model space, the scale bars measure as quoted, i.e. your model space units are metres. When you go into paper space, you have to remember that AutoCAD defaults to inches and millimetre units. So to scale for paper space you must divide the drawing units in millimetres by the scale required. So one metre is 1000 millimetres, then divide that by 400 which equals 2.5. If you use Properties, and in Paper space click on the viewport, the scale of the viewport is revealed as 2.402468, so you have been altering things. Again in Properties, just correct the Custom Scale to 2.5 and that is it. Now the A3 sheet will plot out at 1 to 400, but be warned, your drawing frame has a 6mm margin all round, so you must have borderless printing on or you will not get a plot with a surrounding frame line.
    1 point
×
×
  • Create New...