Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/06/2022 in all areas

  1. One definition of block A in the block library, But you can have multiples of block A in the drawing. This should be what your looking for. Added two other lisp that will dump properties of selected items into command prompt. dumpit = dxf codes Vdumpit = visual lisp propeties ;;----------------------------------------------------------------------;; ;; Select Block by Name (defun C:SBN (/ blkname SS) (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block")))))) ;Gets block name to use in ssget filter (if (setq SS (ssget (list '(0 . "INSERT") (cons 2 blkname)))) ;will only select blocks of the same name (sssetfirst nil SS) ) (princ) ) ;;----------------------------------------------------------------------------;; ;; Dump all methods and properties for selected objects (defun C:VDumpIt (/ ent) (while (setq ent (car (entsel "\nSelect Entity to Dump"))) (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t) ) (textscr) (princ) ) ;;----------------------------------------------------------------------------;; ;; Dump all DXF Group Data (defun C:DumpIt (/ ent) (while (setq ent (car (entsel "\nSelect Entity to Dump"))) (mapcar 'print (entget ent '( "*"))) ) (textscr) (princ) )
    2 points
  2. OK - I'll look into it. Since I am no expert with field expressions, I am not sure if it can be done that way. mhupp's solution might work better for you with a 1+ added. if the number rounds down.
    1 point
  3. Yes. But there might be other types of text, such as ARCTEXT (or was it RTEXT? Can't remember LOL).
    1 point
  4. without checking , does wcmatch accept wildcards, * ? .... "*TEXT")
    1 point
  5. I figured he wanted the fields in the first place so it would change when the dimension changed. You just have to run the UPDATEFIELD command on the drawing. Your way works the same since you just run the command again on all the dimensions. I was just trying to stick to the OPs intent. If the OP had several different divisions in the same drawing he would have to run the command again multiple times.
    1 point
  6. You could also go with: (if (wcmatch (cdr (assoc 0 (setq e (entget sn)))) "TEXT,MTEXT")
    1 point
  7. This should be what you want. getting rid off all the field id's unless you change them alot. you will have to rerun the lisp to update if you change any of the dimensions. (defun c:@Dims (/ dist SS eo len div) (vl-load-com) (if (and (setq dist (getdist "\nSpecify Increment Distance: ")) (setq SS (ssget '((0 . "DIMENSION")))) ) (foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq eo (vlax-ename->vla-object dim)) (setq len (vlax-get eo 'Measurement)) (setq div (fix (/ len dist))) ;round to whole number 15.9 = 15 (vla-put-TextOverride eo (strcat (rtos len 2 0) "/" (rtos dist 2 0) " = " (rtos div 2 0) " Spaces")) ) ) (vla-Regen (vla-get-ActiveDocument (vlax-get-Acad-Object)) acActiveViewport) ;regen active viewport (princ) )
    1 point
  8. OK - I am not understanding your picture. it says "Correct n" is "16" yet you said divide the distance by the overall correctly at "15 spaces". The code I have updated below gives this - is it correct? Why the extra 1 division? The 2nd updated code below adds the 1 to it. 1st Code: (defun c:@Dims (/ dist ss n eo) (vl-load-com) (if (and (setq dist (getdist "\nSpecify increment distance: ")) (setq ss (ssget '((0 . "DIMENSION")))) ) (progn (setq n (sslength ss)) (while (> (setq n (1- n)) -1) (setq eo (vlax-ename->vla-object (ssname ss n))) (vla-put-AltUnitsScale eo dist) (vla-put-TextOverride eo (strcat "<>\\X[%<\\AcExpr (%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).Measurement \\f \"%lu2%pr0\">%/" (rtos dist 2 2) ") \\f \"%lu2%pr0\">%]@%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).AltUnitsScale \\f \"%lu2%pr0\">%" ) ) (vla-Update eo) ) ) ) (command "._UpdateField" ss "") (princ) ) 2nd Code: (defun c:@Dims2 (/ dist ss n eo) (vl-load-com) (if (and (setq dist (getdist "\nSpecify increment distance: ")) (setq ss (ssget '((0 . "DIMENSION")))) ) (progn (setq n (sslength ss)) (while (> (setq n (1- n)) -1) (setq eo (vlax-ename->vla-object (ssname ss n))) (vla-put-AltUnitsScale eo dist) (vla-put-TextOverride eo (strcat "<>\\X[%<\\AcExpr (1+(%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).Measurement \\f \"%lu2%pr0\">%/" (rtos dist 2 2) ")) \\f \"%lu2%pr0\">%]@%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).AltUnitsScale \\f \"%lu2%pr0\">%" ) ) (vla-Update eo) ) ) ) (command "._UpdateField" ss "") (princ) ) Please let me know.
    1 point
  9. Ok - try one of these 2 routines: (vl-load-com) (defun c:@Dims (/ dist div ss n eo) (if (and (setq dist (getdist "\nSpecify increment distance: ")) (setq ss (ssget '((0 . "DIMENSION")))) ) (progn (setq n (sslength ss)) (while (> (setq n (1- n)) -1) (setq eo (vlax-ename->vla-object (ssname ss n))) (vla-put-AltUnitsScale eo dist) (setq div (/ 1.0 dist)) (vla-put-TextOverride eo (strcat "<>\\X[%<\\AcExpr (" (rtos div 2 2) "*%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).Measurement \\f \"%lu2%pr0\">%) \\f \"%lu2%pr0\">%]@%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).AltUnitsScale \\f \"%lu2%pr0\">%" ) ) (vla-Update eo) ) ) ) (command "._UpdateField" ss "") (princ) ) (defun c:@Dims2 (/ dist ss n eo) (if (and (setq dist (getdist "\nSpecify increment distance: ")) (setq ss (ssget '((0 . "DIMENSION")))) ) (progn (setq n (sslength ss)) (while (> (setq n (1- n)) -1) (setq eo (vlax-ename->vla-object (ssname ss n))) (vla-put-AltUnitsScale eo dist) (vla-put-TextOverride eo (strcat"<>\\X(%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID eo)) ">%).AltUnitsScale \\f \"%lu2%pr0\">%)" ) ) (vla-Update eo) ) ) ) (command "._UpdateField" ss "") (princ) ) EDIT - don't forget a (vl-load-com) statement. Added to top of code block.
    1 point
  10. Command RSTNL for Replace Symbol To New Line ;; http://www.lee-mac.com/stringsubst.html ;;--------------------=={ String Subst }==--------------------;; ;; ;; ;; Substitutes a string for all occurrences of another ;; ;; string within a string. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; new - string to be substituted for 'old' ;; ;; old - string to be replaced ;; ;; str - the string to be searched ;; ;;------------------------------------------------------------;; ;; Returns: String with 'old' replaced with 'new' ;; ;;------------------------------------------------------------;; (defun LM:StringSubst ( new old str / inc len ) (setq len (strlen new) inc 0 ) (while (setq inc (vl-string-search old str inc)) (setq str (vl-string-subst new old str inc) inc (+ inc len) ) ) str ) ;; RSTNL for Replace Symbol To New Line (defun c:RSTNL ( / mtext symbl oldtext newtext) ;; symbol to be used as new line delimiter. ;; you could also let the user pick it like this: ;; (setq symbl (getstring "\nEnter Symbol: " T)) ;; The T allows the user to add space characters (setq symbl " + ") (princ "\nNow pick the MText elements: ") (while (setq mtext (car (entsel "\nSelect Mtext: "))) (setq oldtext (cdr (assoc 1 (entget mtext)))) ;; substitute the symbol to "\\P". "\\P" means new line for MTexts (setq newtext (LM:StringSubst "\\P" symbl oldtext)) ;; entmod (modify entity) by substitute of the assoc/cont 1 group (entmod (subst (cons 1 newtext) (assoc 1 (entget mtext)) (entget mtext) )) ;; substitute text contents ) )
    1 point
  11. The variable DYNPROMPT must be set to '1' (one). Otherwise the prompt near the cursor will not be displayed, and apparently it will not take input unless it is displayed even if DYNMODE is set to 3.
    1 point
  12. However, I answer... Many solutions: 1 Without modifying the code, do the command line immediately after use: (setq my_set (command "_.PSELECT" "_Previous" "")) Will assign to the my_set variable the selection set made. 2 By modifying line 88 in the code (without declaring my_set as a local variable in the code): (sssetfirst nil (ssget "_WP" ob_lst_pt '((0 . "*TEXT")))) by (sssetfirst nil (setq my_set (ssget "_WP" ob_lst_pt '((0 . "*TEXT"))))) 3 By modifying the code like this: Delete line 88 and replace the line at the end: (prin1) by (ssget "_WP" ob_lst_pt '((0 . "*TEXT"))) This last solution will allow for example to include it in another lisp (after loading) by the following syntax: (setq my_set (C:seltextbyviewport))
    1 point
  13. Hello Try this (roughly tested) (vl-load-com) (defun l-coor2l-pt (lst flag / ) (if lst (cons (list (car lst) (cadr lst) (if flag (caddr lst) 0.0)) (l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag) ) ) ) (defun c:SelTextByViewPort ( / AcDoc Space js pt_v id_vp l h lst_pt js_obj UCS save_ucs WSC nw_pl ob_lst_pt) (setvar "CMDECHO" 0) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (vla-get-PaperSpace AcDoc) ) (vla-StartUndoMark AcDoc) (if (eq (getvar "CTAB") "Model") (setvar "TILEMODE" 0)) (command "_.PSPACE") (princ "\nSelect a viewport: ") (while (null (setq js (ssget "_+.:E:S:L" (list '(0 . "VIEWPORT") '(67 . 1) (cons 410 (getvar "CTAB")) '(-4 . "!=") '(69 . 1) ) ) ) ) ) (setq pt_v (cdr (assoc 10 (setq dxf_ent (entget (setq ent (ssname js 0)))))) id_vp (cdr (assoc 69 dxf_ent)) l (cdr (assoc 40 dxf_ent)) h (cdr (assoc 41 dxf_ent)) lst_pt (list (list (- (car pt_v) (* 0.5 l)) (- (cadr pt_v) (* 0.5 h)) 0.0) (list (+ (car pt_v) (* 0.5 l)) (- (cadr pt_v) (* 0.5 h)) 0.0) (list (+ (car pt_v) (* 0.5 l)) (+ (cadr pt_v) (* 0.5 h)) 0.0) (list (- (car pt_v) (* 0.5 l)) (+ (cadr pt_v) (* 0.5 h)) 0.0) ) js_obj (ssadd) ) (entmakex (vl-list* (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 67 1) (cons 100 "AcDbPolyline") (cons 90 (length lst_pt)) (cons 70 1) (mapcar '(lambda (p) (cons 10 p)) lst_pt) ) ) (ssadd (setq nw_pl (entlast)) js_obj) (command "_.MSPACE") (setvar "CVPORT" id_vp) (command "_.PSPACE") (command "_.CHSPACE" js_obj "" (if (> id_vp 2) "")) (command "_.MSPACE") (setq Space (if (eq (getvar "CVPORT") 1) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) UCS (vla-get-UserCoordinateSystems AcDoc) save_ucs (vla-add UCS (vlax-3d-point '(0.0 0.0 0.0)) (vlax-3d-point (getvar "UCSXDIR")) (vlax-3d-point (getvar "UCSYDIR")) "CURRENT_UCS" ) ) (vla-put-Origin save_ucs (vlax-3d-point (getvar "UCSORG"))) (setq WCS (vla-add UCS (vlax-3d-Point '(0.0 0.0 0.0)) (vlax-3d-Point '(1.0 0.0 0.0)) (vlax-3d-Point '(0.0 1.0 0.0)) "TEMP_WCS")) (vla-put-activeUCS AcDoc WCS) (setq nw_pl (vlax-ename->vla-object nw_pl) ob_lst_pt (l-coor2l-pt (vlax-get nw_pl 'coordinates) nil) ) (vla-put-layer nw_pl "0") (vla-delete nw_pl) (sssetfirst nil (ssget "_WP" ob_lst_pt '((0 . "*TEXT")))) (and save_ucs (vla-put-activeUCS AcDoc save_ucs)) (and WCS (vla-delete WCS) (setq WCS nil)) (vla-EndUndoMark AcDoc) (setvar "CMDECHO" 1) (prin1) ) 0
    1 point
  14. Are you referring to the Dynamic Input feature by any chance?
    1 point
×
×
  • Create New...