Leaderboard
Popular Content
Showing content with the highest reputation since 10/19/2026 in all areas
-
A couple of points to make: The need to create thousands of variables on-the-fly typically points to poor program design; in almost every case, a list is more suitable. Setting all such variables to nil at the end of the program does clear them from the document namespace, but consider that you are essentially creating & clearing global variables that are not local to the scope of your program, and as such, the variable names could potentially clash with identically named variables in the document namespace - this is generally considered bad practice.6 points
-
A contrived exercise to demonstrate the performance considerations: (defun foo1 ( lst ) (vl-sort lst (function (lambda ( s1 s2 ) (compare (splitstr s1) (splitstr s2)) ) ) ) ) (defun foo2 ( lst ) (mapcar '(lambda ( n ) (nth n lst)) (vl-sort-i (mapcar 'splitstr lst) 'compare) ) ) (defun compare ( l1 l2 / x y ) (while (and l1 l2 (= (setq x (car l1)) (setq y (car l2)))) (setq l1 (cdr l1) l2 (cdr l2) ) ) (cond ( (null l1)) ( (null l2) nil) ( (and (numberp x) (numberp y)) (< x y) ) ( (numberp x)) ( (numberp y) nil) ( (< (strcase x) (strcase y))) ) ) (defun splitstr ( str ) (read (strcat "(" (vl-list->string (apply 'append (mapcar (function (lambda ( a ) (if (< 47 a 58) (list a) (list 34 a 34) ) ) ) (vl-string->list str) ) ) ) ")" ) ) ) _$ (setq mylist (makelist 100)) ("byo547swd" "niq983ocu" "aca823vdk" "wtq568rur" "phi902niq" "bjh526uzd" "rji359jxn" "qqv937rwf" "tug083pja" "gad189ena" "lte537pir" "laa124lqe" "pjd997nvz" "opt105nif" "lbg559zsq" "tpj226ohq" "jdo941odr" "pyl665lro" "hoi547oxb" "tke599mge" "tqm797yrt" "dlm480ido" "jlt529gio" "dtl751rtz" "lpi310zks" "rit617cpr" "qdf999kec" "lkz260ohj" "xlg106fuk" "dqj592rbs" "rza409lss" "phx280fll" "rft924rac" "xrt327nir" "mil320zdh" "sec951fzz" "hng963son" "bhm360nws" "whv768vre" "sub738cgn" "udp152qpy" "bfv499vpg" "bef375dxu" "sne299abt" "jwg218naf" "kul046lji" "opm274fep" "xqb135wrk" "vug239ccx" "yvk063bnl" "cca701lfg" "upy690bri" "nsj806ovt" "igt413wky" "ftw622pra" "jsm813cre" "fnd378khc" "utk011unn" "hkm488zlv" "naw752kdp" "gze062nrv" "ytt910gzi" "eeq942uez" "rbm719yzv" "adu204kgv" "voo553bzq" "qah335lvg" "oky453mna" "bye070dci" "uwt849qig" "nkg662cbj" "koy546cve" "fgp548fhm" "hxm087okh" "atb056yvr" "jxz680bdn" "ofc383clx" "ran801jgt" "dai951aut" "muc372eji" "dmv843wdj" "mwl251acq" "skn266edb" "stz033eih" "qbm300sjp" "tax196nfk" "uix079eqf" "evl716cui" "tjl236dov" "mod149kqp" "cai814mxb" "yyf245cfk" "occ503uit" "csd182gul" "jgs728fmy" "hga698aqi" "hfk752ize" "vra872olq" "bjm266zaq" "zva674kji") _$ (foo1 mylist) ("aca823vdk" "adu204kgv" "atb056yvr" "bef375dxu" "bfv499vpg" "bhm360nws" "bjh526uzd" "bjm266zaq" "bye070dci" "byo547swd" "cai814mxb" "cca701lfg" "csd182gul" "dai951aut" "dlm480ido" "dmv843wdj" "dqj592rbs" "dtl751rtz" "eeq942uez" "evl716cui" "fgp548fhm" "fnd378khc" "ftw622pra" "gad189ena" "gze062nrv" "hfk752ize" "hga698aqi" "hkm488zlv" "hng963son" "hoi547oxb" "hxm087okh" "igt413wky" "jdo941odr" "jgs728fmy" "jlt529gio" "jsm813cre" "jwg218naf" "jxz680bdn" "koy546cve" "kul046lji" "laa124lqe" "lbg559zsq" "lkz260ohj" "lpi310zks" "lte537pir" "mil320zdh" "mod149kqp" "muc372eji" "mwl251acq" "naw752kdp" "niq983ocu" "nkg662cbj" "nsj806ovt" "occ503uit" "ofc383clx" "oky453mna" "opm274fep" "opt105nif" "phi902niq" "phx280fll" "pjd997nvz" "pyl665lro" "qah335lvg" "qbm300sjp" "qdf999kec" "qqv937rwf" "ran801jgt" "rbm719yzv" "rft924rac" "rit617cpr" "rji359jxn" "rza409lss" "sec951fzz" "skn266edb" "sne299abt" "stz033eih" "sub738cgn" "tax196nfk" "tjl236dov" "tke599mge" "tpj226ohq" "tqm797yrt" "tug083pja" "udp152qpy" "uix079eqf" "upy690bri" "utk011unn" "uwt849qig" "voo553bzq" "vra872olq" "vug239ccx" "whv768vre" "wtq568rur" "xlg106fuk" "xqb135wrk" "xrt327nir" "ytt910gzi" "yvk063bnl" "yyf245cfk" "zva674kji") _$ (foo2 mylist) ("aca823vdk" "adu204kgv" "atb056yvr" "bef375dxu" "bfv499vpg" "bhm360nws" "bjh526uzd" "bjm266zaq" "bye070dci" "byo547swd" "cai814mxb" "cca701lfg" "csd182gul" "dai951aut" "dlm480ido" "dmv843wdj" "dqj592rbs" "dtl751rtz" "eeq942uez" "evl716cui" "fgp548fhm" "fnd378khc" "ftw622pra" "gad189ena" "gze062nrv" "hfk752ize" "hga698aqi" "hkm488zlv" "hng963son" "hoi547oxb" "hxm087okh" "igt413wky" "jdo941odr" "jgs728fmy" "jlt529gio" "jsm813cre" "jwg218naf" "jxz680bdn" "koy546cve" "kul046lji" "laa124lqe" "lbg559zsq" "lkz260ohj" "lpi310zks" "lte537pir" "mil320zdh" "mod149kqp" "muc372eji" "mwl251acq" "naw752kdp" "niq983ocu" "nkg662cbj" "nsj806ovt" "occ503uit" "ofc383clx" "oky453mna" "opm274fep" "opt105nif" "phi902niq" "phx280fll" "pjd997nvz" "pyl665lro" "qah335lvg" "qbm300sjp" "qdf999kec" "qqv937rwf" "ran801jgt" "rbm719yzv" "rft924rac" "rit617cpr" "rji359jxn" "rza409lss" "sec951fzz" "skn266edb" "sne299abt" "stz033eih" "sub738cgn" "tax196nfk" "tjl236dov" "tke599mge" "tpj226ohq" "tqm797yrt" "tug083pja" "udp152qpy" "uix079eqf" "upy690bri" "utk011unn" "uwt849qig" "voo553bzq" "vra872olq" "vug239ccx" "whv768vre" "wtq568rur" "xlg106fuk" "xqb135wrk" "xrt327nir" "ytt910gzi" "yvk063bnl" "yyf245cfk" "zva674kji") _$ (equal (foo1 mylist) (foo2 mylist)) T _$ (benchmark '((foo1 mylist) (foo2 mylist))) Benchmarking ..........Elapsed milliseconds / relative speed for 128 iteration(s): (FOO2 MYLIST).....1953 / 4.84 <fastest> (FOO1 MYLIST).....9453 / 1.00 <slowest>5 points
-
So in keeping with posting some of my LISPs, I used this just the other day, and just was reminded with the recent resurrection of the Fillet 0 issue thread where the OP was doing 40,000, not sure what LISP they used. Per the latest resurrection, setting FILLETPOLYARC setting may or may not help depending on what you are trying to fillet. The few times I have seen Fillet 0 fail with the P option was when the fillet radii completed something like a half circle when adjacent corners are filleted (something like the ends of a slot). This can be handy dandy. There are others like this around. For my use this was better than a few of the ones I tried. You may need to change the FILLETPOLYARC=0 if you have issue using this with Radius=0. In those situations when I had an issue, the LISP just doesn't do anything to those fillets, so I just go back with a small radius and change them, then you should be able to Fillet=0 those. (defun c:MF () (c:MultiPolyFillet) ) (defun c:MultiPolyFillet (/ radius ss i ent) (setq radius (getdist "\nFillet radius: ")) (if radius (progn (setvar "FILLETRAD" radius) (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE")))) (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) (command "_.FILLET" "_P" ent) (setq i (1+ i)) ) ) ) ) ) (princ "MultiPolyFillet complete.") (princ) ) (princ "\nMultiPolyFillet loaded. Type MultiPolyFillet or MF to run." ) (princ)4 points
-
Stating the obvious: just consider that creating xrecords & dictionaries is modifying the drawing database and the data is stored in the drawing, whereas LISP data is obviously transient.3 points
-
If you're worried about the removal of duplicated elements when using (vl-sort), just use (vl-sort-i) to obtain the sorted indices and use them to order the original list - this has been solved/demonstrated many times over and is also typically far more performant when sorting lists for which the sort function would otherwise perform some manipulation of the list elements. _$ (setq mylist '(5 3 6 4 5 3 7 5)) (5 3 6 4 5 3 7 5) _$ (vl-sort mylist '<) (3 4 5 6 7) _$ (mapcar '(lambda ( n ) (nth n mylist)) (vl-sort-i mylist '<)) (3 3 4 5 5 5 6 7)3 points
-
Here's another without command calls: (defun c:zal (/ a d c tabs) ;; RJP » 2020-07-08 (setq c (getvar 'ctab)) (vlax-for x (vla-get-layouts (setq d (vla-get-activedocument (setq a (vlax-get-acad-object))))) (setq tabs (cons (list (vla-get-name x) (vla-get-taborder x)) tabs)) ) ;; The sort makes sure that the tabs step left to right (foreach x (cdr (vl-sort tabs '(lambda (r j) (< (cadr r) (cadr j))))) (setvar 'ctab (car x)) (vlax-put d 'mspace 0) (vla-zoomextents a) ) (setvar 'ctab c) (princ) )3 points
-
3 points
-
Thanks. Yes, this entire site runs on PHP. Fortunately, my web host was very quick to add the necessary patches to ensure safety and security. We're all good3 points
-
Inspired by SWL210 tonight... An update to this one.... it is a bit more complex then just grabbing an entity or entering a text value... Went down the grread route which gave the results I want. Command is (entortext "Message" '(List 1) '(List 2) ) Message: Text message such as "Enter a value, or select some text" '(List 1) - Control characters to end the selection process in ASCII codes: 13 = Enter, 32 = Space ('List 2) - Text Control for selections: "A" - Alphabetical characters only (a, A - z, Z) as text entry or any text entity selection "N" - Numerical Characters only (1-9 .) as text entry, or pure numerical text entity selection "P" - Punctuation characters (< > , . / ?.....) as "A" but text is only punctuation "M" - Mathematical modifiers (+ - / *.....) as "A" but text is only numerical modifiers (I should change this t be the same as "N") "E" - any entity is selectable. Without E is selection is text only List 2 can be joined eg '("A" "M" "N" "P") to select any text (also '("N" "P") works and enter any text Special option: If 'N' is used only numerical text is selectable, 'A' will allow any text entity to be selectable. Combined also works for selecting any text (but only entering A-Z, 1-9 here no punctuation) For example "Select an entity or 'O' for Options") '(79 111) '("E") Note: Distinguishes between cases.... Note here 'O' for options, for example, excludes that as part of a text string to be returned - selection is ended on 'O' There are examples, entorent, entorstring, entorvalue to look at in there. Returns: If text is entered: '("text", ASCII of enter method (13, 32..), nil) If Entity is selected: '(<entity name>, point selected, insert point of selection If Escape pressed: ("Lucky escape" 27 nil) - escape is captured and returned to the calling function - handy if selecting in a while loop If that makes sense, have a play. Oh, and an easter egg for you which might or might not work... (defun EntorText ( msg EndString TextTypes / MyTextType EndLoop grsel sela sel MyEnt MyValue MyCharacters MyCommand enta entb pt lw MyList MyTextString EscapeCode NestedSelection Tlist EList IsBlock) (defun EntorCommand (/ *error* RunLispCommand RunNativeCommand MyCommand LispCheck Result ErrorMessage CommandStatus ) (defun *error* (Msg) (if (> (getvar "CMDACTIVE") 0) (command) ) ; ;; Cancel any native command still running. (cond ((null Msg) (princ "\nCommand ended with error.")) ((wcmatch (strcase Msg) "*BREAK*,*CANCEL*,*EXIT*" ) (princ "\nCommand cancelled.") ) (t (princ (strcat "\nCommand error: " Msg ))) ) ; End Cond (princ) ) ; End Defun *error* (defun RunLispCommand (LispFunction /) (apply LispFunction nil) ) ; End Defun RunLispCommand (defun RunNativeCommand (CommandName /) (command CommandName) (while (> (getvar "CMDACTIVE") 0) (command pause) ) ; End While ) ; End Defun RunNativeCommand (setq MyCommand (strcase (getstring "\nPausing Text Selection.\n(Command Line to) Enter Command: " ))) (setq LispCheck (vl-catch-all-apply 'eval (list (read (strcat "C:" MyCommand) )))) (if (and LispCheck (not (vl-catch-all-error-p LispCheck)) ) ; end and (progn ; LISP (setq Result (vl-catch-all-apply 'RunLispCommand (list (read (strcat "C:" MyCommand))))) (if (vl-catch-all-error-p Result) (progn ; LISP Error (setq ErrorMessage (vl-catch-all-error-message Result)) (if (wcmatch (strcase ErrorMessage) "*BREAK*,*CANCEL*,*EXIT*,*ABORT*" ) (princ (strcat "\nLISP command " MyCommand " cancelled: " ErrorMessage )) (princ (strcat "\nLISP Command " MyCommand " ended with an error: " ErrorMessage )) ) ; End If ) ; End Progn (progn ; LISP Completed (setq CommandStatus "completed") ) ; End Progn ) ; End If ) ; End Progn (progn ; Native AutoCAD Command (setq Result (vl-catch-all-apply 'RunNativeCommand (list MyCommand) )) (if (vl-catch-all-error-p Result) (progn ; Native Command Error (setq ErrorMessage (vl-catch-all-error-message Result)) (if (> (getvar "CMDACTIVE") 0) (command) ) ; Ends command if running (if (wcmatch (strcase ErrorMessage) "*BREAK*,*CANCEL*,*EXIT*,*ABORT*") (princ (strcat "\nCommand " MyCommand " cancelled: " ErrorMessage )) (princ (strcat "\nCommand " MyCommand " ended with an error: " ErrorMessage )) ) ; End If ) ; End Progn (progn ; Native Command Completed (setq CommandStatus "completed") ) ; End Progn ) ; End If ) ; End Progn ) ; End If (princ "\nEnded Command") (princ) ) ; End Defun Run EntOrCommand ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq EscapeCode nil) (if (= (type EndString) 'LIST) (progn) (setq EndString (list 13 32)) ;; 13: Enter, 32: Space ('T' in getstring) ) ; End String (if (= (type msg) 'Str) (princ msg) (princ (setq msg "Select or enter text: ")) ) (if (= (type TextTypes) 'LIST) (progn) (setq TextTypes (list "A" "N" "P" "M")) ;; A: Alphabet, N: Numerical, P: Punctuation, M: Mathemtatical ) ; End String ;;Starting values (setq MyValue "") (setq MyEnt (list)) (setq EndLoop "No") (setq MyCommand 0) (setq MyTextType nil) (if (or (member "N" TextTypes)(member "n" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) "1234567890.,"))) ; Numerical (if (or (member "NE" TextTypes)(member "ne" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) ""))) ; Numerical (if (or (member "A" TextTypes)(member "a" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) ; Alphabet (if (or (member "NA" TextTypes)(member "na" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) ""))) ; Aphabetical (if (or (member "P" TextTypes)(member "p" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) "`#`~`@\\|<`,>`.`?/¬``!\"£$%^&`*()`-_="))) ; Punctuation (if (or (member "NP" TextTypes)(member "np" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) ""))) ; Aphabetical (if (or (member "M" TextTypes)(member "m" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) "=/+-`*`.`,"))) ; Maths Functions (if (or (member "NM" TextTypes)(member "nm" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) ""))) ; Aphabetical (if (or (member "E" TextTypes)(member "e" TextTypes)) (setq MyTextType (strcat (if (= MyTextType nil) "" MyTextType) ""))) ; Entity (implied in code if not listed) (if (= MyTextType nil)(setq MyTextType "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ")) ;;Add in EA, EN, EP, EM - for text selection only ;;Loop for grread function (while (= EndLoop "No") (setq grsel (vl-catch-all-apply 'grread '(nil 13 2))) ; catch errors (escape key) (if (vl-catch-all-error-p grsel) ;; escape pressed, end loop (progn (setq EndLoop "Yes") (princ (strcat "\n" (setq MyValue "Lucky escape"))) (setq escapecode 27) (setq MyEnt nil) (if lw (redraw lw 4) ) ) ;end progn escape pressed (progn (setq sela (car grsel)) (if (= sela 5) ; Highlight on hover (progn (if lw (redraw lw 4) ) ;Remove any highlight (if (and (setq pt (cadr grsel) ) (setq lw (ssget pt)) (setq lw (ssname lw 0)) ) ; end and (redraw lw 3) ) ; end if ) ; end progn ) ; end if (if (or (= sela 2)(= sela 3) ) ; text entry or mouse click (progn (setq sel (nth 1 grsel)) (if (= (type sel) 'LIST) (progn (setq MyList (setq TList'("TEXT" "MTEXT" "RTEXT" "ATTRIB" "ATTDEF" "DIMENSION" "INSERT"))) ; Permitted entity types (if (or (member "E" TextTypes)(member "e" TextTypes)) (setq MyList (append MyList (setq EList (list "LINE" "POLYLINE" "3DPOLYLINE" "LWPOLYLINE" "MLINE" "SPLINE" "POLYGON" "MPOLYGON" "VIEWPORT" "WIPEOUT" "ELLIPSE" "CIRCLE" "ARC" "POINT" "HATCH" "SURFACE" "SOLID3D" "SHAPE" "FACE" "3DFACE" "SOLID" "3DSOLID" "TRACE" "RAY" "XLINE" "RASTER" "XREF" )))); TList: Text List, EList: Entity List ) ;;SP TO complete this list with: ;;ACAD_PROXY_ENTITY, BODY, HELIX, IMAGE, LEADER LIGHT, MULTILEADER, MLEADERSTYLE, ;;OLEFRAME, OLE2FRAME, REGION, SECTION, SEQEND, SHAPE, SUN, TABLE, TOLERANCE,UNDERLAY, VERTEX, (setq MyEnt (nentselp sel)) (if MyEnt (setq IsBlock (last (cadddr MyEnt)))) (cond ((and ;; Block but not text IsBlock (= (member (cdr (assoc 0 (entget(car MyEnt)))) TList) nil) (or (member "E" TextTypes)(member "e" TextTypes)) ;; (member (cdr (assoc 0 (entget(car MyEnt)))) EList) ;; Don't use in case type not in list ) ; end and (progn (setq MyEnt (list IsBlock sel (cdr (assoc 10 (entget IsBlock)))) ) ;; CAR ISBlock?? (setq EndLoop "Yes") ) ) ((and ;; Block and text IsBlock (member (cdr (assoc 0 (entget (car MyEnt)))) TList) ;; text in block ) ; end and (progn (if (equal TextTypes '("E"))(princ ": Ahh, you selected a text")(princ ": text selecting? Nice.")) ;;Check if numerical only selection (if (or (equal TextTypes '("N")) (equal TextTypes '("n")) (equal TextTypes '("NE")) (equal TextTypes '("ne")) ) ; endor (progn (setq entb (last (last (nentselp (last grsel))))); grsel point value (if (and (/= entb nil) (/= (type entb) 'real)) (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq MyEnt (list entb (last grsel)))) (progn) ) (setq MyTextString (cdr (assoc 1 (entget (car MyEnt)))) ) (setq mytextString (LM:Unformat MytextString nil)) ; Unformat string (if (or (wcmatch (strcat MyTextString) "*[~1234567890`.`,]*") (and (vl-string-search "." MyTextString) (vl-string-search "." MyTextString (+ (vl-string-search "." MyTextString) 1)) ) ; end and ) ; endor (progn (princ (strcat " However, selection is not numerical,\n" Msg ", or [esc]: ")) (setq MyEnt nil) ) ; end progn (progn (setq EndLoop "Yes") ) ) ; end if number check ) ; end progn numerical (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end progn ) ; end if ((= nil MyEnt) (progn (Princ "\nMissed! Try again.\n")(princ msg) (setq MyEnt nil) ) ) ((= (member (cdr (assoc 0 (entget(car MyEnt)))) MyList) nil) (progn (Princ "\nWrong Type! Try again.\n")(princ msg) (setq MyEnt nil) ) ) ( T ;; Text selected (if (equal TextTypes '("E"))(princ ": Ahh, you selected a thing")(princ ": Fantastic selecting ability.")) ;;Check if numerical only selection (if (or (equal TextTypes '("N")) (equal TextTypes '("n")) (equal TextTypes '("NE")) (equal TextTypes '("ne")) ) ; endor (progn (setq entb (last (last (nentselp (last grsel))))); grsel point value (if (and (/= entb nil) (/= (type entb) 'real)) (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq MyEnt (list entb (last grsel)))) (progn) ) (setq MyTextString (cdr (assoc 1 (entget (car MyEnt)))) ) (setq mytextString (LM:Unformat MytextString nil)) ; Unformat string ; (if (wcmatch (strcat (cdr (assoc 1 (entget (car MyEnt))))) "*[~1234567890`.`,]*") (if (or (wcmatch (strcat MyTextString) "*[~1234567890`.`,]*") (and (vl-string-search "." MyTextString) (vl-string-search "." MyTextString (+ (vl-string-search "." MyTextString) 1)) ) ; end and ) ; endor (progn (princ (strcat " However, selection is not numerical,\n" Msg ", or [esc]: ")) (setq MyEnt nil) ) ; end progn (progn (setq EndLoop "Yes") ) ) ; end if number check ) ; end progn numerical (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end cond T ) ; end conds (if lw (redraw lw 4)) ; remember to (redraw xyz 3) in originating code to keep highlight (setq sel nil) ) ; end progn ; selection is list (progn (setq MyCharacters (list 137)) ; list of single characters to accept (if (member 32 Endstring)(progn)(setq MyCharacters (cons 32 MyCharacters))) ; add [space] if 't' (if (or ;;limit characters able to able to be used ;; remove escape keys later (wcmatch MyTextType (strcat "*" (strcase (chr sel)) "*"));; Strcase to include caps (= sel 92) ; '\' character for commands (member sel MyCharacters) ) ; endor (progn (if (= sel 92) ;; If double '\\' enter commands - check if '\' entered (progn (setq MyCommand (+ MyCommand 1)) (if (= MyCommand 2) (progn (princ (chr 8)) ; remove last '\' from command line (setq MyValue (vl-string-right-trim (chr 92) MyValue)) ; remove '\' from result (EntorCommand) (setq MyCommand 0) (setq sel nil) (princ "\nResume Text Selection.\n")(princ MSG)(if MyValue (princ MyValue)) ) ; end progn command = 2 (progn (if (member sel EndString) ;; remove escape keys from MyValue (progn) (progn (princ (chr sel)) (setq MyValue (strcat MyValue (chr sel) )) ) ; end progn ) ; end if ) ; end progn ) ; end if ) ; end progn (progn (setq MyCommand 0) (if (member sel EndString) ;; remove escape keys from MyValue (progn) (progn (princ (chr sel)) (setq MyValue (strcat MyValue (chr sel) )) ) ; end progn ) ; end if ) ; end progn ) ; end if ) ) (if (member sel EndString) ; enter (progn (setq EndLoop "Yes") (setq EscapeCode sel) ) ; end progn (progn ) ) ; end if (if (= sel 8) ; backspace (progn (if (> (strlen MyValue) 0) (progn (setq MyValue (substr MyValue 1 (- (strlen MyValue) 1))) (princ (chr sel)) ) ; end progn ) ; end if ) ; end progn (progn ) ) ; end if ) ; end progn ) ; end if list ) ; end progn ) ; end if text / mouse entry ) ; end progn ) ; end if catch-all-error ) ; end while (if (or ( = (length MyEnt) 0)(= MyEnt nil) ;; if no entity selected.. text entry ) ; end OR (progn ;; If text is entered ) ; end progn (progn (setq enta (car MyEnt)) (setq pt (cdr (assoc 10 (entget enta))) ) (setq entb (last (last (nentselp pt)))) ;; use sel? ;; nested entities (if (and (/= entb nil) (/= (type entb) 'real) (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER") ) ; end and (setq MyValue entb) ; If entity is DIM, Table, Leader (setq MyValue enta) ; ELse entity ) ; end if ) ; end progn ) ; end if ;;Result - '(MyValue Pt) ;;'Ended ##' : An escape character code if entered ;;'Lucky Escape' : Escape key pressed ;;<Entity name: ##> : The selected entity ;;Other character : Entered Characters ;;(cadr grsel) - mouse point ;;pt - entity insert point (assoc 10) (if EscapeCode (setq MyValue (list MyValue EscapeCode nil)) (setq MyValue (list MyValue (cadr grsel) pt)) ) MyValue ) Al Still thinks this is a native command "EntOrText" by the way...3 points
-
I thought I would have some more fun with this problem. As I posted earlier, I think AutoCAD's parametric features offer a good solution. Here's an easier construct. Open the attached file and go to the Parametric tab and click Show All or enter the command DCDISPLAY and select the box to see the dimensional constraints. Change the value of dimension d3 to see the box in a different position agaist the wall. The following VLISP program creates a box of user specified dimensions and animates it position and orientation as it slides along the floow and wall. 0,0 is assumed to be the lower corner of the wall. box_animation.mp4 ;Creates an animation of a rectangle slding along a floor ; as it rotates leaning agains a wall. ; 11/13/2026 (defun c:boxanimate (/ ang boxL boxW dAngle dAngleR p i d vlaObj nSteps dx) (vl-load-com) (setq boxL (getreal "\nEnter box length (9): ")) (if (not boxL) (setq boxL 9) ) (setq boxw (getreal "\nEnter box width (2) ")) (if (not boxW) (setq boxW 2) ) (setq dAngle 1 ; rotation angle increment ang dAngle ; total rotation dAngleR (/ (* pi dAngle) 180.) p (list (- boxL) 0) ; poit of rotation i 0 d 100 ; delay value ) (command "_rectangle" "_non" p "_non" (list 0 boxW)) (setq vlaObj (vlax-ename->vla-object (entlast))) (setq nSteps (/ 90 dAngle)) (setvar "CMDECHO" 0) (while (< i nsteps) (setq angR (/ (* pi ang) 180.)) (setq dx (abs (+ (car p) (* boxL (cos angR))))) (vla-Rotate vlaObj (vlax-3d-point p) dAngleR) (vla-Move vlaObj (vlax-3d-point '(0.0 0.0 0.0)) (vlax-3d-point (list dx 0.0 0.0)) ) (setq ang (+ ang dAngle) p (mapcar '+ p (list dx 0)) ) (vla-update (vlax-get-acad-object)) (command-s "_.REGEN") (command "_.DELAY" 100) (setq i (1+ i)) ) (setvar "CMDECHO" 1) (princ) ) ; end defun box fit.02.dwg2 points
-
Dictionary is an object in the drawing file. (setq mainDict (namedobjdict)) (dictadd mainDict "PART001" ;this is they unique key (entmakex '((0 . "XRECORD") ;needed (100 . "AcDbXrecord") ;needed (1 . "Steel") (2 . "Description") (3 . "12.5") (4 . "24") (5 . "100") (6 . "Black") ) ) ) (setq color (cdr (assoc 6 (dictsearch Maindict "PART001")))) So the main "list" or Dictionary is mainDict you then need a key to store the sub list under "PART001" and then as many dotted pairs as you want. dictsearch would be alot faster than assoc with 20,000 list.2 points
-
To select multiple objects, use **`ssget`** instead of `entsel`, and then apply `setpropertyvalue` to each selected object in a loop. Select several objects using a frame, or one at a time. For all selected objects, the **Annotative** property will change to **No**. The filter allows you to select: `TEXT`, `MTEXT', `DIMENSION`, `MULTILEADER` **Objects are not deleted or recreated.** Only the `Annotative` property is changed. ; "Annotative" 0 /No/ (defun c:NoAnno (/ ss i) ; AI ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" 0) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i))) ) ) (princ) ) ; "Annotative" 1 /Yes/ (defun c:YesAnno (/ ss i) ; AI ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" 1) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i))) ) ) (princ) ) ;;; Remove/Add Annotative property to objects [No/Yes] (default No) ;;; Supported objects: TEXT, MTEXT, DIMENSION, MULTILEADER (defun c:SetAnno (/ ss i ans val) ;; Prompt the user, default is No (initget "No Yes") (setq ans (getkword "\nRemove/Add Annotative property to objects [No/Yes] <No>: ")) (if (not ans) (setq ans "No")) ; if Enter pressed — use No (setq val (if (= ans "Yes") 1 0)) ; Yes = 1, No = 0 ;; (if (setq ss (ssget '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT,DIMENSION,MULTILEADER")))) ; remark of Paul Li (progn (setq i 0) (repeat (sslength ss) (setpropertyvalue (ssname ss i) "Annotative" val) (setq i (1+ i)) ) (princ (strcat "\nProcessed objects: " (itoa i) " | Annotative = " ans)) ) (princ "\nNo objects selected.") ) (princ) )2 points
-
You can use AutoLISP's setpropertyvalue to change the Annotative property to No without deleting the objects. LISP code=>(setpropertyvalue (car (entsel "\nSelect object: ")) "Annotative" 0) For processing nested objects, you would also need to iterate through the block definitions and apply the same change to their entities. Xrefs cannot be modified this way without editing their source drawings. This is a useful alternative to manually changing each object's Properties palette.2 points
-
I wonder if exporting the Attribute Values to Excel, then back into the new titleblock would be better? @Lee Mac has Update Titleblock Attributes | Lee Mac Programming and @ziele_o2k has... Export Title Blocks to CSV for Lee's Update Title Block - AutoLISP, Visual LISP & DCL - AutoCAD Forums2 points
-
Did something similar for vehicle driveway checking, just a maybe make the box like 2mm smaller than true size and position and rotate, use intersectwith to see if the box and walls touch you will get nil if they dont.touch. Say stop when get points.2 points
-
This was created by Copilot, limited testing. and only sorts on single item. (defun BubblePass (lst / a b) (cond ((or (null lst) (null (cdr lst))) lst) ((> (car lst) (cadr lst)) (cons (cadr lst) (BubblePass (cons (car lst) (cddr lst))))) (t (cons (car lst) (BubblePass (cdr lst)))) ) ) (defun BubbleSort (lst / i) (repeat (length lst) (setq lst (BubblePass lst)) ) lst ) Asked about sort on 1st 2 items in list (defun QSORT2 (lst / pivot) (defun _less (a b) (or (< (car a) (car b)) (and (= (car a) (car b)) (< (cadr a) (cadr b))))) (if (cdr lst) (progn (setq pivot (car lst)) (append (QSORT2 (vl-remove-if-not '(lambda (x) (_less x pivot)) (cdr lst))) (list pivot) (QSORT2 (vl-remove-if-not '(lambda (x) (not (_less x pivot))) (cdr lst))) ) ) lst ) ) Limited testing.2 points
-
Yeah lisp is a little on the background right now , wife has some serious health issues so my attention lies elsewhere at this moment. The 'good' news is I'm running out of work this month so next month I have a lot of spare time. Will do some reading and maybe / probably some lisping too.2 points
-
@Discus84 Your question reminded me of the time my son asked me if I could determine if the couch he was planning to buy would fit in the frieght elevator of his aprtment building. There are several way to solove this problem. 1. Make multiple copies of the red box at different angles and then position them with object snap against the walls and floor. 2. Use the paramteric feature of AutoCAD to create and constrain the wall and the box. The following image shows only the angle contraint of the box. Tangency to the wall and floor is made via a dimensional contraint. Here's the result of changing the box angle. The following shows the dimensional and geometric constraints. Note, d3 constrains the box to be flush with the back wall and d9 with the floor. You can edit the dimensions in the attached file to meet yout requirements. box fit.dwg2 points
-
@PGia there are other ways to sort lists other than inbuilt Vl-sort. You can use a Lisp version of Bubble sort and other sort algorithms. I sort up to 5 items deep in a list and as far as I can tell none are lost. Yes have seen that with some lists using VL-sort. So you can sort on say X & Y. ; sorts on 1st two items (vl-sort lst '(lambda (a b) (cond ((< (car a) (car b))) ((= (car a) (car b)) (< (cadr a) (cadr b))) ) ) )2 points
-
sure : (alert "Press ok to start your 30hr day") anything else I can do for you?2 points
-
2 points
-
I get that @PGia but it almost be harder to recall the correct random variable. associated list might not be what you need with the large data set your working with. as assoc looks at all 20000 records every time. look into Dictionary before going the other route. alot faster searching because you can only have unique keys tho that might be a deal breaker for you.2 points
-
There may be ways to speed up using a list of 20,000 points, the first is if your points are numbered then make the list that way you have to but pt number 0 as 1st item then a (nth x lst) is a simple task and does not need the (- x 1). Re find a point depending how the list is made there is a way of quickly finding the point based on a sorted list a 10,000 list takes 13 tries to find the correct answer, it uses a 1/2 algorithm, look at 5000 item is it before or after look at say 2500 is it before or after so very fast. Can you explain what it is your doing and maybe some people here can provide faster code. I know something I did took 34 minutes 1st go, it now takes 2 minutes including user input.2 points
-
@PGia While it's very possible to create variables on the fly. I agree with Lee that it should not be a method to use, especially in the way you are wanting to use it. That being said, I wrote the following many years ago, but hardly have ever used it for anything. It accepts an assoc. list of strings representing variables and the corresponding values, then creates a variable for each with the value. The core of it is very simple (set (read "StrVar") value) ;|============================================================================== Function Name: (pjk-dynsetvar) Arguments: assoclst = List of cons; an assoc list on the format: (list (cons "<var name1>" <value1>) ... (cons "<Var namN>" <valueN>)) Usage: (pjk-dynsetvar <Assoc. List>) Ex: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) Returns: The results of the read list. You can verify the variables with the ! prefix: Command line Example: Command: (pjk-dynsetvar (list (cons "Cenpt" (list 1.0 1.0 0.0)) (cons "Radius" 0.25))) ((1.0 1.0 0.0) 0.25) Command: !Cenpt (1.0 1.0 0.0) Command: !Radius 0.25 Description: This function dynamically sets AutoLISP variables based on an association list of strings and values. The string keys represent the names of the variables that the values will be assigned to. ================================================================================|; (defun pjk-DynSetVar (assoclst) (mapcar (function (lambda (x)(set (read (car x)) (cdr x)))) assoclst) ) ;; End Function (pjk-dynsetvar)2 points
-
It seems it's not placing CENTERMARKS in Mechanical, I haven't tested other verticals from the toolset, it does use my fallback CrossHairs, though. I may not bother getting CENTERMARK to work in verticals unless someone else is interested, I would use the LISP in AutoCAD anyway, but I will do some testing on Mechanical/Architectural drawings in AutoCAD when I have time. Speaking of time, does anyone have a LISP or something that can give me a 30+ hour day, maybe @rlx I'll try to check this latest version in AutoCAD 2000i this weekend.2 points
-
@Steven P A couple of suggestions (defun MakeDriveList ( / replace with (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already (setq drivelist (ah:butts 1 "V" '("Please choose" "C:" "D:" "E:" "F:"))) "(setq GetFolderDcl (load_dialog "GetFolder"))" I use the write dcl to lisp by RLX so dcl code can live in the master lisp, then only one file. You may be able to use powershell to dump out the correct drives including network drives to a file and read that with lisp, done via a (startapp c:\path\drives.bat) powershell Get-PSDrive -PSProvider FileSystem | Out-File -FilePath "D:\acadtemp\drives_list.txt" exit Convert dcl 2 lisp rlx.lsp Multi radio buttons.lsp2 points
-
2 points
-
Hi all, I am in the early stages of developing (vibe coding) something I have been thinking about for a minute: a videogame where you CAD. It's called CADcade and I've got a whole vision for it and everything. Right now it's just some beginner lessons, a sandbox mode, and an arcade mode with 36 drafting challenges of varying difficulties. It runs in your computer browser, and one of the goals is to help students and beginners learn the basics of navigating CAD products and spatial thinking for free online. This is kind of a demo of it that I would like to get feedback on (not selling or monetizing anything). I just wanted to share it here and see what you guys think. How does it feel? Ai slop? Not enough commands? Dumb concept? Every reply helps. cadcade.net Thank you!2 points
-
I work with 2D CAD drawings for protective foam packaging and CNC, so overlapping geometry is something I pay attention to. Duplicate lines can create problems downstream, especially when preparing closed profiles for cutting. I think it's worth teaching beginners to check their geometry early instead of waiting until export.2 points
-
Every design revision, I have to circle changes with revision clouds for submission. I kept missing things or marking the wrong spots, so I wrote a LISP to do it automatically. What it does: 1. Select Region A (old version) 2. Select Region B (revised version) 3. Red revision clouds appear around every difference It works inside the same DWG — no need for two separate files like DWG Compare. Uses signature-based object comparison with sorted merge, so it handles 1400+ objects in seconds. Features: - Automatic spatial alignment (consensus voting) - Nearby changes merged into grouped clouds - Giant objects (title blocks, borders) auto-filtered - Manual 2-point alignment fallback if auto fails - Configurable tolerance, arc size, merge distance Supports: LINE, CIRCLE, ARC, LWPOLYLINE, TEXT/MTEXT, INSERT, DIMENSION Skips: HATCH (too many false positives) AutoCAD 2014+ compatible. Free / MIT: https://github.com/beastt1992/DiffCheck Feedback welcome2 points
-
These are ones I use: To record the current zoom: (setq currentzoom (list (getvar 'viewctr) (getvar 'viewsize))) .. zoom as you want And this returns you to where you were. (vla-ZoomCenter (vlax-get-acad-object) (vlax-3d-point (car currentzoom)) (cadr currentzoom)) Never tried with viewports but some ssget types need the entities to be selected to be in view, maybe viewports are the same2 points
-
I have a Zoom Extents in Modelspace and Zooms Extents, then .9x in all layouts, it helps with the offset AutoCAD puts on some drawings when opening them, plus works for finding odd paperspace items, zooms just a little more to show the edges. Still trying to determine what is wrong with Lee Mac VPOUTLINE LISP? Are you looking for a count of true viewports? I have a LISP that gives this report of true viewports in all layouts, as well as places a border in modelspace and creates/checks for my viewport layer. ====================================== AutoVPBrdr REPORT ====================================== True layout viewports: 5 Viewport layer assignments: 5 Layer assignment failures: 0 Modelspace borders created: 5 Viewports skipped: 0 -------------------------------------- Layer: Viewport Color: 45 Plot: OFF ====================================== It only places a border for a viewport referencing Top/Plan view.2 points
-
Like @Danielm103, I was also going to suggest Autodesk Store and/or what @BIGAL stated would be my choices. It really depends on what you are comfortable/familiar with. Personally, unless your LISPs are really making difficult and/or complicated work easy and a lot faster, I wouldn't believe they would be big sellers since they seem targeted at AutoCAD MEP, I haven't looked at any numbers lately, but a lot of those users are slowly rolling over to Revit, I was using AutoCAD MEP occasionally, but haven't had any of that type work to do in a good while, perhaps an occasional user such as myself would be a potential customer, I am not sure what percentage of AutoCAD users "do a little of everything" like I do. That is not meant to deter you, just to give an insight on what $$$ and effort you need to spend getting them secure and keeping them up. What future plans do you have on providing support? I see a lot of for purchase apps that end up having the publisher lose interest or other issues and the support goes away.2 points
-
I have a couple apps on the autodesk store. here's one XLSX field evaluator. https://apps.autodesk.com/ACD/en/Detail/HelpDoc?appId=4867035866745163447&appLang=en&os=Win64 Anyway, I use Autodesk's entitlement API. All you need to do is register your application , they give you an Application id. you can see the ID in the link all you need to do is query the server with the ONLINEUSERID. You need to be able to let the user use your application offline, my app checks at the beginning of each month here's a quick lisp sample (defun c:IsEntitled (/ http response) (setq appId (getstring "Enter AppId ")) (setq userId (getvar "ONLINEUSERID")) (setq url (strcat "https://apps.autodesk.com/webservices/checkentitlement?userid=" userId "&appid=" appId ) ) ;https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms759148(v=vs.85) (if (setq http (vlax-create-object "MSXML2.XMLHTTP")) (progn (vlax-invoke-method http 'open "get" url :vlax-false) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list http 'send))) ) (setq response (vlax-get http 'responseText)) ) (vlax-release-object http) ) ) (cond ((> (vl-string-search "true" response) 0) (princ "\nTrue")) (t (princ "\nFalse")) ) (princ) );def2 points
-
For pure LISP, FAS and VLX are generally OK - commercially these are used. Unless you are selling thousands of copies for thousands each time to make it worth while to break the coding, perhaps selling a few copies to each company doesn't make it worth breaking them. It is possible but the forums (including this one) are very quick to stop any such requests. I'd be happy to sell these in formats. Then of course you have sent your file out into the wild, it can be copied and sent around an office as fast as an email. You could hard code each file with details specific to the computer / user (www.cadtutor.net/forum/topic/34596-computer-name/) - perhaps check (getenv "ComputerName") and (getenv "UserName") and test these against a (unique) hard coded variable in each file that you sell. Down side is you have to trust them when they want an updated file if they update their computer (Limit this to '1 updated computer every 4 years is allowed') - though you could also do a check that the AutoCAD version has also increased when requesting a new LISP file. That does mean extra work for you or your team though, and not a fully automated process. These 2 should be enough to protect yourself from legitimate business stealing your code. After that your protection has to come out of AutoCAD and LISP and into professional file hosting solutions - not my thing there - but one solution was to again hard code their LISP file to link to a cloud based LISP file that will return a code to the first LISP - this, computer name, user name can validate that they are in their license period and LISP can run. Benefit here is you have complete control if they can get access and of course, the date / expiry is hard coded into the remote / your LISP. I'd have one remote LISP file for each licensed File you send out. Downside here is a financial cost to maintain a web presence, with firewall and authentication systems. Since it is just a file most commercial thing should do what you want, and you need internet access for that initial validation in each CAD instance. Taking that a step further, the file you sell could be a simple "appload" command linking to your remote files, once validated apploaded into that CAD instance - offline use will be OK s long as there was internet to connect and download initially for that CAD instance. Noting that any remote file is not copied to their system and to access it / read it needs the user to break the encoding to get the file path, to copy it to break the coding again to copy the programming. Good question - I might be out tomorrow with a systems architect and this is his thing - if I remember I'll see his thoughts, but that is who you want to talk to. It might be possible to host it all yourself. Of the developers on here Tharwat sells his work commercially and is up to speed with protecting his stuff, he might be around to give a few pointers. Final part - reverse engineering - if it is being used, not a lot you can do about that, just got to hope that whoever buys it realises the time and cost to remake it and that yours is a lot better value.2 points
-
SlbMgr is a Slide Library Manager written in AutoLISP that requires VBScript and Word to be installed. 1) Select an AutoCAD Slide Library (like acad.slb but must be in a writable folder) 2) A Slide Manager window appears listing Slides in the selected Slide Library file 3) Select Slides to Subtract or Slides stored locally to Add 4) File Explorer opens in location where Updated Slide Library file is created Feedback welcome. SlbMgr.lsp2 points
-
Attached is code SlbShow.lsp that ChatGpt help me generate which would run on AutoCAD on Windows OS. It'll first open a file window to select an existing slide library file like acad.slb Then run a vbscript to extract the names of the slides inside the selected slide library and place this into a text file. Next, the slides inside the selected slide library will be displayed in a custom dcl made up of a row of 4 x 5 column image buttons. Finally, when an Image button is clicked another window appears showing the slide in a larger image button view. I would like to know when vbscript or wscript is restricted does the code handle this and exit properly. Any other feedback is welcome. SlbShow.lsp2 points
-
I have been pretty busy with the grandkids back and it near Halloween here and the 3D printing, but I did get the CENTERMARK replacement working last week. I created some tough test examples, so there are a few bugs to workout where the native AutoCAD CENTERMARK fails and it uses the crosshairs. I'll try to iron those out next week, the version I have now is working in most situations, the ones not working are blocks that have curve features dimensioned in paperspace through the viewport, and a few odd circles in paperspace, others work in the same layout, I think I know the difference. CENTERMARK command requires an object, so selecting the proper curves by the dimension seems the main issue, though I have that sorted for most situations. This relates back to the samples from my GETLENGTH.lsp and the SOLPROF created viewports and the blocks inside, so normally what I have now should work for most people. If anyone is interested in seeing what I have so far, I might go ahead and post it if there is interest.2 points
-
Update V2: https://drive.google.com/file/d/1tKI38W60KEjrlQ-NF4Rh-gctgxSd8HQf/view?usp=drive_link2 points
-
Tried it in Bricscad V25 worked ok, a side issue it pops open the text file in Notepad which I have to close. I really don't want these TXT files being added to the chosen slb directory. They should be deleted or an option keep or delete.2 points
-
Just putting this up here as something I wanted for a while and had 10 minutes to think last night. I'd been wanting a routine "Select an entity or enter a value". Been doing it with initget which gives discrete values and not every possibility. So made up the following. All good so far, haven't found out where it is broken yet. Just to get your brains working then, trying to figure out how to change the mouse pointer as it hovers over an entity and not select it? Using grread and it's options you either get mouse pointer change and it selects automatically or no mouse pointer change and select with a mouse click as far as I can see. Any ideas? Thanks (defun c:EntOrValue ( / msg MyResult) (setq msg "\nSelect an Entity or enter a value: \n") (setq MyResult (EntorValue msg) ) ; end defun ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun EntorValue ( MSG / EndLoop sel MyEnt MyValue enta entb pt) (setq MyValue "") (setq MyEnt (list)) (setq EndLoop "No") (princ MSG) (while (= EndLoop "No") ; start loop (setq sel (nth 1 (grread nil 0 2))) ; read keyboard / mouse inputs. Ignore mouse position, only if clicked (if (= (type sel) 'LIST) (progn ; if sel is a LIST,... ie. a mouse click, a point returned (setq MyEnt (nentselp sel)) ; select entity from point (if (= nil MyEnt) (Princ "\nMissed! Try again. Select text or enter a value: ") ; entity not selected (setq EndLoop "Yes") ; entity selected, end while loop ) ; end if ) ; end progn (progn ; if sel is not a LIST, i.e. a single keyboard entry (if (or (and (> sel 47)(< sel 57))(= sel 46)) ; numbers only (progn (princ (chr sel)) (setq MyValue (strcat MyValue (chr sel) )) ) ) (if (= sel 45) ; -ve ; make negative number (progn (setq MyValue (strcat (chr sel) MyValue )) (princ " Making -ve\n")(princ MyValue) ) ; end progn ) ; end if (if (= sel 13) ; enter - end number input, end loop (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end progn ) ; end if list ) ; end while (if ( = (length MyEnt) 0) ; if entity not selected (progn MyValue ; return number entered ) ; end progn (progn ;;GetEnt code (setq enta (car MyEnt)) (setq pt (cdr (assoc 10 (entget enta))) ) ;;fix for nenset or entsel requirements (setq entb (last (last (nentselp pt)))) ;; use sel? (if (and (/= entb nil) (/= (type entb) 'real) ) (progn (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq enta entb)) ) ) (setq MyEnt enta) MyEnt ; return entity name, including nested say text from dimensions ) ; end progn ) ; end if )2 points
-
I think that the will to simplify the proccess of controling our environment (Ribbons,Menues,Varaibles,Lisps Etc.) can leed to more complications... and I also feel it loose it's original goal wich is to control our cad environment. It started with how to manage our lisp's, CUI (ribbon and menues) and varaibles setting and ended up with cloud-based app that (in my eyes...) only add complictions and I didn't fully understand its goal... to control the lisps - one autoload lisp file do it, and for organizations it can sit in a shared location. simple documantation file like excel or other formats can use to tell users what each lisp dose . organazations have system administrators for that. about settings: Bricscad have On_Doc_Load & on_start files, Autocad have its equivalents, and that is where varaibles can be set automatically. about the Ribbon and menues: CUI files can be deployed and loaded. there are other ways to progrematically do it like mentioned here through the registry and more, but I feel that some significant overshoot was displayed here. and do it through the cloud also raise some doubts for me.2 points
-
Thanks for the link, I am happy with this code for now: (defun EntorValue ( MSG / EndLoop sel MyEnt MyValue enta entb pt) (princ MSG) ; message (setq MyValue "") (setq MyEnt (list)) (setq EndLoop "No") (while (= EndLoop "No") (setq grsel (grread nil 4 2)) ; Read from mouse or keyboard entry (setq sela (car grsel)) ; type of entry (if (or (= sela 2)(= sela 3) ) ; text entry or mouse click (setq sel (nth 1 grsel)) ; what was entered, a point, or text ) (if (= (type sel) 'LIST) (progn (setq MyEnt (nentselp sel)) ; if mouse entry selected en entity (if (= nil MyEnt) (Princ "\nMissed! Try again: ") (setq EndLoop "Yes") ) ; end if ) ; end progn (progn (if (or (and (> sel 47)(< sel 57))(= sel 46)) ; if keyboard entry is a number (progn (princ (chr sel)) (setq MyValue (strcat MyValue (chr sel) )) ) ) (if (= sel 45) ; -ve ; if keyboead entry is '-' add '-' to beginning of string ;;Future check to be done if using A-Z keyboard entry, not just numbers ;;Future check in case number is allready -ve (progn (setq MyValue (strcat (chr sel) MyValue )) (princ " Making -ve\n")(princ MyValue) ) ; end progn ) ; end if (if (= sel 13) ; enter ; end keyboard entry. Note mouse selection cancels keyboard entry (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end progn ) ; end if list ) ; end while (if ( = (length MyEnt) 0) (progn MyValue ; return MyValue ) ; end progn (progn ; entget for nested entities ; Also see Lee Mac CTX for alternative method ;;GetEnt code (setq enta (car MyEnt)) (setq pt (cdr (assoc 10 (entget enta))) ) ;;fix for nenset or entsel requirements (setq entb (last (last (nentselp pt)))) ;; use sel? (if (and (/= entb nil) (/= (type entb) 'real) ) (progn (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq enta entb)) ) ) (setq MyEnt enta) MyEnt ; return entity name ) ; end progn ) ; end if )2 points
-
2 points
-
@BIGAL I think using powershell method would be similar. User launches AutoCAD then runs lisp that would write the registry key (that designates the current profile) into powershell script along with item to add to Startup. But after running the powershell script, user is prompted to exit AutoCAD (without launching Appload) in order for the added item in the registry to be read on the relaunch of AutoCAD.1 point
-
1 point
-
For CAD manager, Developer, and Users accustomed to communicating via email, feel free to contact me anytime: vico@vedacad.com1 point
-
I continue to monitor the situation and although we're still seeing the error message, the stats for this month indicate that bot activity is going down from a peak in September. Fingers crossed it continues to fall.1 point
-
@LIU very simple. If UCSICON is set to OR (origin) and 0,0,0 of the current UCS is near to the left border of the graphics window boundary, or below the boundary, or not within the viewing window then the UCS ICON will move to be near the bottom left of the window and will not be postioned at 0,0. Note, the little square that you see on the icon indicates that you the WCS is active.1 point
-
1 point
