Leaderboard
Popular Content
Showing content with the highest reputation on 07/22/2022 in all areas
-
@JimmyDev Do you know that you can shorten repetative syntaxes coded by using (defun myfunc ( arg ) ... ) function and managing repetitions by iteration through (mapcar (function (lambda ( arg ) (myfunc arg))) (list arg1 arg2 ...))3 points
-
A command example (vlax-invoke-method mySheet "Activate") so for current sheet make it active. vlax-invoke-method. So maybe these no idea if they will work not tested. (vlax-invoke-method mySheet "PasteSpecial") (vlax-invoke-method mySheet "Format" "Picture (PNG)") (vlax-invoke-method mySheet "Link" :vlax-false) (vlax-invoke-method mySheet "DisplayAsIcon" :vlax-false) Missing the cell address ? Or one way around is to do a (alert "pick cell in excel") Acad will sit there waiting while you pick a cell in excel, then go back to acad and click OK to continue, I know this works for select range. Not sure if paste will work ok hopefully yes.2 points
-
You can also work out what to change in your code, If you start the plot command in the command line (_plot), it will give you all the options that your LISP has preselected one after another. Make a note of them as it runs through the plot command and you can change these above to suit your needs.1 point
-
1 point
-
Use @marko_ribar suggestion or you can just combine them easily enough. (setq SS (ssget "_X" '((0 . "INSERT") (2 . "CATA00000,CART_LV##,CATIDENTELEA0,CATREVBELA0")))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq pt (cdr (assoc 10 (entget blk)))) (command "_.Move" blk "" pt '(1178 10 0)) ) You can use Wild cards "#" for numbers ;; CART_LV## = BLOCK names CART_LV00 - CART_LV99 "@" for letters ;; CART_LV@ = Block names CART_LVa - CART_LVZ "*" for anything ;; CART_LV* = any block that starts with "CART_LV" *CAT* = any block that containts "CAT" *CART = any block that ends with "CART" if you only want 01-03 just put CATA00000,CART_LV01,CART_LV02,CART_LV03,.... For the last two blocks that didn't move check to see if they are on a locked layer, Then if the name has the correctly spelling.1 point
-
I'm not even sure why this did it for me, but I've been struggling to understand mapcar and lambda expressions and this little example made it (mostly) click! Ty M.R.!1 point
-
Lee Mac's Field Objects lisp http://lee-mac.com/fieldobjects.html This program enables the user to easily view the object or set of objects referenced by a selected Field. Upon issuing the command syntax fieldobjects at the AutoCAD command-line, the program will prompt the user to select an annotation object (Text, MText or Attribute) containing one or more field expressions referencing one or more objects in the active drawing. Such fields may be created using my Areas to Field program, or my Area Field to Attribute program. Following a valid selection, the program will enclose the selected annotation object containing the field(s) with a green rectangular text box, with links to every referenced object, each of which is surrounded by a red rectangular bounding box. The size of the rectangular frames relative to the enclosed objects is dependent on the current zoom level, and will automatically update as the user zooms & pans around the drawing area. I added this macro years ago to my Text, Mtext, Field drop-down ^C^C^P(or C:FieldObjects (load "FieldObjectsV1-0.lsp"));FieldObjects Great when you need it, thanks Lee!1 point
-
The move command needs two points to work properly. If you only provide it with one it assumes the 2nd point is 0,0,0 hence why its only moving to the right by 0.5. (setq SS (ssget "_X" '((0 . "INSERT") (2 . "CART_LV02")))) ;this will select all blocks named CART_LV02 in the drawing. (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;lists all entity names of selection set (setq pt (cdr (assoc 10 (entget blk)))) ;get insertion point of block (command "_.Move" blk "" pt '(0.5 0 0)) )1 point
-
See the reply in the LT forum post you started at Autodesk https://forums.autodesk.com/t5/autocad-lt-forum/puzzling-with-at-script-for-autocad/m-p/11311508#M1959531 point
-
1 point
-
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/shrinking-windows-in-visual-lisp-editor/m-p/8769890/highlight/true#M3847291 point
-
Use the rectangle command as suggested which is quicker than drawing lines and then joining them, the fillet command also has various options available for using in an LT script. Try running the command and watch the command line which prompts you for input. So in your case you want to start the fillet command and the use the 'radius op[tion (which only needs the letter 'r' in a script followed by the radius you want, you are then prompted again for input and you see an option to select a polyline using the command modifier 'L' will select the last object created and then enter to accept the selection (enter is carried out by using a space or empty line in your script). When you then start the mtext command you can again use command modifiers to select the geometric center of the last object created. The mtext command in a script allows for various options if you watch the command line for the prompts1 point
-
1 point
-
Hi, AFAIK, the FieldCode method don't work with attribute references (only with texts and mtexts). Another way to find the field code of a (m)text or an atribute is to search in the object extension dictionary for a "ACAD_FIELD" entry which is another dictionary in which you have to look for a "TEXT" entry which is the "FIELD" object. But I was not able to go further using the COM/Activex automation (used both by VBA and Visual LISP). So, all I can give you now is a LISP routine which deals with DXF datas, maybe you can inspire to write some VBA code... The routine uses a recursive process because in fields using formulas, an object linked field can be nested into another object nlinked field, and so on... ;; gc:FieldCode (gile) ;; Returns an attribute text or mtext string with the field code ;; ;; Argument : object entity name (ENAME) (defun gc:FieldCode (ent / foo elst xdict dict field str) ;;--------------------------------------------------------;; (defun foo (field str / pos fldID objID) (setq pos 0) (if (setq pos (vl-string-search "\\_FldIdx " str pos)) (while (setq pos (vl-string-search "\\_FldIdx " str pos)) (setq fldId (entget (cdr (assoc 360 field))) field (vl-remove (assoc 360 field) field) str (strcat (substr str 1 pos) (if (setq objID (cdr (assoc 331 fldId))) (vl-string-subst (strcat "ObjId " (itoa (gc:EnameToObjectId objID))) "ObjIdx" (cdr (assoc 2 fldId)) ) (foo fldId (cdr (assoc 2 fldId))) ) (substr str (1+ (vl-string-search ">%" str pos))) ) ) ) str ) ) ;;--------------------------------------------------------;; (setq elst (entget ent)) (if (and (member (cdr (assoc 0 elst)) '("ATTRIB" "MTEXT" "TEXT")) (setq xdict (cdr (assoc 360 elst))) (setq dict (dictsearch xdict "ACAD_FIELD")) (setq field (dictsearch (cdr (assoc -1 dict)) "TEXT")) ) (setq str (foo field (cdr (assoc 2 field)))) ) ) ;;============================================================;; ;; gc:EnameToObjectId (gile) ;; Converts an ename to an object ID ;; ;; Argument : an ename (defun gc:EnameToObjectId (ename) ((lambda (str) (hex2dec (substr (vl-string-right-trim ">" str) (+ 3 (vl-string-search ":" str))) ) ) (vl-princ-to-string ename) ) ) ;;============================================================;; ;; hex2dec (gile) ;; convert an hexadécimal (string) into a décimal (integer) ;; ;; Argument : un hexadédimal (chaîne) (defun hex2dec (s / r l n) (setq r 0 l (vl-string->list (strcase s))) (while (setq n (car l)) (setq l (cdr l) r (+ (* r 16) (- n (if (<= n 57) 48 55))) ) ) ) ;;============================================================;; ;; lst2str (gile) ;; Concatenates a list and a separator into a string ;; ;; Arguments ;; lst : list ;; sep : separator (defun lst2str (lst sep) (if (cdr lst) (strcat (vl-princ-to-string (car lst)) sep (lst2str (cdr lst) sep) ) (vl-princ-to-string (car lst)) ) )1 point