Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/18/2023 in all areas

  1. Sounds like your modification is running (command "") without calling a command. This acts like hitting enter or right click and telling AutoCAD to repeat last command. If you repeat last command and their isn't a previous one to repeat (you just opened the drawing) it will execute the help command. Check to make sure your not calling something when it loads, And all Code is within defun brackets.
    2 points
  2. You can have a go - not something I would do to be honest, far too specific for a single solution. OK, you might have hundreds of these drawings to do, but to write, check, verify, try to break a code before you finally use it usually is more time consuming than just doing it for a few drawings (of course, other times I do that just because I can) This will select all the text that is a height of 2 (according to your drawing) (refer to Lee Macs website for ssget references - his is probably the easiest for me to understand) (setq MySS (ssget "X" '((0 . "TEXT")(40 . 2)))) This will loop through the selection set and update your text. (setq acount 0) (while (< acount (sslength MySS)) (setq MyEnt (ent get (ssname MySS acount)) ) ;;Do Your text changes here, save as variable NewText ;;https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-C7D27797-247E-49B9-937C-0D8C58F4C832 (setq MyEnt (subst (cons 1 NewText) (assoc 1 MyEnt) MyEnt )) ;; (entmod MyEnt) (setq acount (+ acount 1)) ) ;; end while and how you want to do the texts and any verification that each is a number is up to you - loads of options out there. The simplest would be a mix of the ascii and chr functions with a +1 which would increase by 1 the last digit and no error checking that the text is a number. There is a method out there to add all the ascii characters together so that +1 will do 10s,, 100's and so on if necessary (this method will work for letters if you ever get that case. versatility), or else you want to do a check that the text string is a number (this is all online somewhere), convert to a number then +1 (use ATOI for integers, ATOF if you might have decimal places) Remember that NewText has to be a string, if you calculation gives you a number it wants to be (rtos Newtext) in the substitution line You might want to add in start and end undo markers in case it all goes wrong sometime (this is online), How long you spend making it nice depends how often you will use this, but the basics are above, and in the original thread you copied the code from (always good to give a link to there, there are other ideas in that thread if what you posted doesn't work for others following you)
    1 point
  3. Really the only way would be to create 2, then do a viewport freeze to one or the other.
    1 point
  4. Here is my sample... Untested though... (defun c:zoo ( / e ss s vsz ) ;;; zoom to object of object (vl-load-com) (if (setq e (entsel "\nPick object segment you want to zoom to...")) (progn (setq ss (vlax-invoke (vlax-ename->vla-object (car e)) 'explode)) (setq s (vlax-vla-object->ename (car (vl-sort ss '(lambda ( a b ) (< (distance (vlax-curve-getclosestpointto a (trans (cadr e) 1 0)) (trans (cadr e) 1 0)) (distance (vlax-curve-getclosestpointto b (trans (cadr e) 1 0)) (trans (cadr e) 1 0)))))))) (setq vsz (getvar 'viewsize)) (vl-cmdf "_.UCS" "_OB" s) (vl-cmdf "_.PLAN" "") (vl-cmdf "_.ZOOM" "_OB" s "") (vl-cmdf "_.ZOOM" "_C" "_non" (getvar 'viewctr) vsz) (mapcar 'vla-delete ss) ) ) (princ) )
    1 point
  5. Was about to say the same, when you open a file and hit 'enter' the default is to open the help pages. So if your LISPs have the equivalent of an enter before doing anything else and on opening this is what will happen
    1 point
  6. You gave simple example, thus it was not hard to construct WIPEOUT through (entmake)... So for complex ones, I strongly suggest that you use first code which will convert lwpolyline into wipeout with the same characteristics... (defun c:makewipeout ( / vertexList lw ) (setq vertexList (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq lw (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") (cons 8 "0") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 (1+ (* 128 (getvar 'plinegen)))) (cons 38 0.0) ) (mapcar '(lambda ( pt ) (cons 10 pt)) vertexList) (list (list 210 0.0 0.0 1.0)) ) ) ) (vl-cmdf "_.WIPEOUT" "_P" lw "_Yes") (princ) ) Or alternatively using (entget (car (entsel))) from previously generated WIPEOUT : ((-1 . <Entity name: 4ac03910>) (0 . "WIPEOUT") (5 . "AA") (330 . <Entity name: 4a5381c0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbWipeout") (90 . 0) (10 -1.0 -1.0 0.0) (11 2.0 0.0 0.0) (12 0.0 2.0 0.0) (13 1.0 1.0 0.0) (70 . 7) (280 . 1) (281 . 50) (282 . 50) (283 . 0) (71 . 2) (91 . 5) (14 -0.5 0.5 0.0) (14 0.5 0.5 0.0) (14 0.5 -0.5 0.0) (14 -0.5 -0.5 0.0) (14 -0.5 0.5 0.0) (290 . 0)) (defun c:makewipeout ( / vertexListmain vertexList ) (setq vertexListmain (list (list -1 -1 0.) (list 1 -1 0.) (list 1 1 0.) (list -1 1 0.) ) ) (setq vertexList (mapcar '(lambda (x) (mapcar '(lambda (y) (/ y 2.0)) x)) vertexListmain)) (entmake (append (list (cons 0 "WIPEOUT") (cons 100 "AcDbEntity") (cons 100 "AcDbWipeout") (cons 90 0) (cons 10 (car vertexListmain)) (cons 11 (mapcar '- (cadr vertexListmain) (car vertexListmain))) (cons 12 (mapcar '- (caddr vertexListmain) (cadr vertexListmain))) (cons 13 (caddr vertexListmain)) (cons 70 7) (cons 280 1) (cons 281 50) (cons 282 50) (cons 283 0) (cons 71 2) (cons 91 5) ) (mapcar '(lambda (p) (cons 14 p)) (append vertexList (list (car vertexList)))) (list (cons 290 0)) ) ) (princ) ) HTH., M.R.
    1 point
  7. I think I would go for the option to select and increment each number one at a time here, would be less prone to errors and for example there are the numbers above the 'Shot' that you want but also the larger numbers making selecting everything and distinguishing which to increment trickier (possible, just trickier).
    1 point
  8. Here are some alternatives: Subst Nth
    1 point
  9. https://adndevblog.typepad.com/autocad/2012/05/lisp-entmakeing-a-wipeout-object-in-autocad-gives-different-coordinates-than-expected.html
    1 point
  10. This is what I used to show Viewport in Model space. --Edit "Use to" I Work with Solidworks now. ;;----------------------------------------------------------------------------;; ;; Creates Viewport outline and moves it to Model space (defun C:VP2M (/ SS vp elist MiscOn cen c40 c41 LL UR) (vl-load-com) (if (setq SS (ssget "_X" (list '(0 . "viewport") (cons 410 (getvar 'ctab))))) (foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq elist (entget vp)) (if (> (cdr (assoc '69 elist)) 1) ; skip display viewport (progn (if (= (cdr (assoc '68 elist)) 0) ; is viewport active? (progn (setq MiscOn 'NO) (vl-cmdf "._Mview" "_on" "_si" vp) ; activate viewport ) (setq MiscOn 'YES) ) (setq cen (cdr (assoc '10 elist)) c40 (cdr (assoc '40 elist)) ;length c41 (cdr (assoc '41 elist)) ;width LL (list (- (car cen) (/ c40 2)) (- (cadr cen) (/ c41 2))) UR (list (+ (car cen) (/ c40 2)) (+ (cadr cen) (/ c41 2))) ) (vl-cmdf "_.Pspace") (vl-cmdf "_.Rectangle" LL UR) (vl-cmdf "_.Chspace" "_Last" "") (vl-cmdf "_.Pspace") (if (eq MiscOn 'NO) (vl-cmdf "_.Mview" "_off" "_si" vp) ; deactivate viewport ) ) ) ) ) ;(setvar 'Tilemode 1) ;switch to model space (princ) )
    1 point
  11. Entmaking a Wipeout
    1 point
×
×
  • Create New...