Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/12/2024 in all areas

  1. What I use in my day-to-day work is basically something like this. I'd normally type the right command name in and go about that approach. As Steven pointed out, once the direction is set, most users are happy with it. (Only works in 2D): (defun c:lx nil (CommandDirection (list "_.LINE" pause) ".Y")) (defun c:ly nil (CommandDirection (list "_.LINE" pause) ".X")) (defun c:cx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_.COPY" ss "" "_M" pause) ".Y"))) (defun c:cy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_.COPY" ss "" "_M" pause) ".X"))) (defun c:mx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".Y"))) (defun c:my (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".X"))) (defun c:sx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".Y"))) (defun c:sy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".X"))) ;; Command Direction - Jonathan Handojo ;; Creates a command that constraints point prompts to X, Y or Z axis. ;; cmd - a list of strings to pass into the AutoCAD command function. ;; => The next prompt following the string list supplied must be a point selection. ;; dir - a string of either ".X", ".Y" or ".Z" (defun CommandDirection (cmd dir) (apply 'command cmd) (while (not (zerop (getvar "cmdactive"))) (command dir "_non" "@0,0,0" pause) ) (princ) )
    2 points
  2. THANK YOU THIS IS PRECISELY WHAT I NEEDED
    1 point
  3. @leonucadomi Actually - I think this version will work better i it will prevent it from stripping other formatting for the reason Lee Mac noted here: ; Original by RonJonP, edited by P. Kenewell (defun c:ltx (/ o s) (setvar "cmdecho" 0) (command "._undo" "_be") (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (cond ((= "TEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "%%U%%O" (vl-string-subst "" "%%U" (vl-string-subst "" "%%O" (vla-get-textstring o)) ) ) ) ) ((= "MTEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "\\L\\O" (vl-string-subst "" "\\L" (vl-string-subst "" "\\O" (vla-get-textstring o)) ) ) ) ) ((= "DIMENSION" (cdr (assoc 0 (entget e)))) (if (= (vla-get-textoverride o) "") (vla-put-textoverride o "\\L\\O<>") (vla-put-textoverride o (strcat "\\L\\O" (vl-string-subst "" "\\L" (vl-string-subst "" "\\O" (vla-get-textoverride o)) ) ) ) ) ) ) ) ) (command "._undo" "_end") (setvar "cmdecho" 1) (princ) )
    1 point
  4. @leonucadomi Try This: ;; original code by RonJonP, edited by P. Kenewell (defun c:ltx (/ o s) (command "._undo" "_be") (if (setq s (ssget ":L" '((0 . "*TEXT,DIMENSION")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object e)) (cond ((= "TEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "%%U%%O" (vl-string-left-trim "%%U%%O" (vla-get-textstring o)))) ) ((= "MTEXT" (cdr (assoc 0 (entget e)))) (vla-put-textstring o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textstring o)))) ) ((= "DIMENSION" (cdr (assoc 0 (entget e)))) (if (= (vla-get-textoverride o) "") (vla-put-textoverride o "\\L\\O<>") (vla-put-textoverride o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textoverride o)))) ) ) ) ) ) (command "._undo" "_end") (princ) )
    1 point
  5. Please use Code Tags in the future. (<> in the editor toolbar)
    1 point
  6. Can you specify what the solution was for future people that encounter the issue?
    1 point
  7. Another is check does it exist. (if (tblsearch "block" bname) (vl-cmdf "-INSERTCONTENT" filePath "Block1" "Y" "0,0" 1 1 0) (vl-cmdf "-INSERTCONTENT" filePath "Block1" "0,0" 1 1 0) )
    1 point
  8. "The first part selects the polyline and extracts vertex coordinates to a list " ok a list would normally not have the "," seperating the X & Y. If you want to use X,Y then it needs to be a string. (setq plent (entsel "\nPick rectang")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) ((413540.0514 2885464.6320) (413537.4807 2885455.1222) (413535.0813 2885449.2106)) or ("413540.0514,2885464.6320" "413537.4807,2885455.1222" "413535.0813,2885449.2106") The other way is using something like this change pline to "_AeccDeleteSurfaceLine" need a couple more"" (defun AHpllst ( lst / x) (command "_pline") (while (= (getvar "cmdactive") 1 ) (repeat (setq x (length lst)) (command (nth (setq x (- x 1)) lst)) ) (command "") ) ) Sorry not tested.
    1 point
  9. Sorry no help to existing code if your using a FAS file. I use Bricscad mostly now and fas is not supported. This is close to what you want, I have not looked at color of hatch but that could be added. Change layer name, the rectang around the hatch is erased, the hatch is still there on Hatch layer, again could be erased. You were lucky did the d1 d2 bit yesterday for another post. ; https://www.cadtutor.net/forum/topic/90914-fill-in-several-outlines-with-separates-hatchings/ ; Convert a rectang to a pline with width. : By Alan H Sep 2024 (defun C:Rect2pl ( / sspl co-ord x mp1 mp2 d1 d2) (command "-layer" "M" "HATCH2" "") (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq sspl (ssget (list (cons 0 "LWPOLYLINE")(cons 410 (getvar 'ctab))))) (setvar 'clayer "HATCH2") (repeat (setq x (sslength sspl)) (setq plent (ssname sspl (setq x (1- x)))) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent)))) (setq d1 (distance (car co-ord)(cadr co-ord))) (setq d2 (distance (cadr co-ord)(caddr co-ord))) (if (< d1 d2) (progn (setq mp1 (mapcar '* (mapcar '+ (nth 0 co-ord) (nth 1 co-ord)) '(0.5 0.5))) (setq mp2 (mapcar '* (mapcar '+ (nth 2 co-ord) (nth 3 co-ord)) '(0.5 0.5))) (command "pline" mp1 "W" d1 d1 mp2 "") ) (progn (setq mp1 (mapcar '* (mapcar '+ (nth 1 co-ord) (nth 2 co-ord)) '(0.5 0.5))) (setq mp2 (mapcar '* (mapcar '+ (nth 3 co-ord) (nth 0 co-ord)) '(0.5 0.5))) (command "pline" mp1 "W" d2 d2 mp2 "") ) ) (command "erase" plent "") ) (princ) )
    1 point
  10. I commend all your hard work with this. It's ended up more complex than I ever thought. Thank you. It's lacking the ability to shift select to deselect objects. Looking at the code I wouldn't even know where to begin adding this in to it.
    1 point
  11. Windows 10 is not compatible for AutoCAD 2009 and AutoCAD 2009 was Windows XP and Vista, not even 7. AutoCAD 2016 with service pack, IIRC, was first for Windows 10. Have you set a compatibility mode? If so, which one? See this...How to Make Old Programs Work on Windows 10 (howtogeek.com) There is always...Longbow Software. You could try Hardware Acceleration OFF, it could fix it, worth a shot, or using reduced settings. It may help to see if there is a newer driver, or even a rollback to a previous may fix the issue.
    1 point
  12. To remove those pesky legacy color tags in forum code I use this regex in Notepad++ : \[.*?\] The "Find what" box should contain \[.*?\] The "Replace with" box should be kept empty. The "Wrap around" option should be selected The "Search Mode" should be set to "Regular Expression". Hitting the "Replace All" button will remove everything within Square Brackets including the brackets.
    1 point
  13. Version 1.0.0

    2,009 downloads

    Hi guys, This seems like it's already posted somewhere, but I'll just throw it out here anyway. This code allows you to calculate the total lengths of multilines segregated by their multiline size/scale. In order to use the attached LISP code, initiate the APPLOAD command from AutoCAD, and load this file. Once you've done so, you'll notice that you'll have a new command TML. To use the TML command: Select all the multilines that you'd like to calculate for its lengths. Click a point somewhere and an MTEXT will be created with the details for the lengths of the multilines for each size. Feel free to add any ideas, thoughts, criticisms, etc... and I'll try to modify them.
    1 point
  14. 1. DOUBLE-CLICK BLOCK REFERENCE TEXT TO OPEN ENHANCED ATTRIBUTE EDITOR 2. RIGHT-CLICK THE VALUE FIELD AND INSERT FIELD 3. UNDER FIELD CATAGORY NAME CLICK ON DATE, THEN SET THE FORMAT AS NEEDED PUT "%tc1" WITH NO QUOTES OR SPACES IN FRONT OF DATE FORMAT TO MAKE IT UPPERCASE (THIS MEANS TITLE CASE TYPE 1) 4. APPLY CHANGES EXAMPLE : %tc1MMM WILL SHOW MONTH AS THREE LETTERS IN ALL CAPS: I.E. JAN, FEB, MAR, ETC. HOPE THIS HELPS. ig: chevy_techno
    1 point
×
×
  • Create New...