All Activity
- Past hour
-
help with routines some don't work...
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
I don't know if it has to do with the fact that the autocad I use is the 2013 version. -
help with routines some don't work...
GLAVCVS replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Hi Start by checking which ANSI setting you have on your new OS. Control Panel → Region → Administrative tab → Change system locale button. The system locale should appear in Spanish and the option 'Version beta: Use UTF-8...' should be unchecked. -
Steven P started following help with routines some don't work...
-
help with routines some don't work...
Steven P replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
perhaps not the fix you want, but avoid "ñ", do a find and replace, maybe to 'n' ? I would copy the original file to a temporary or archive folder and make the change to the original - so the LISPs will still work until you can work out how to get the correct characters working. Just checking my default text editor is UTF-8 also What do other text editors do and what encoding do they use? - Today
-
help with routines some don't work...
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
If I just open and close nothing happens but if I modify my file and save it, even though I use save as ANSI, it still saves it to UTF-8 and deletes characters, and then the routine doesn't work. -
help with routines some don't work...
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
My old routines are in ANSI configuration, the problem is that they updated me to Windows 11, if I open and close an lsp it is not modified, the problem happens when I make some modification to the routine, Even though I save the routines as ANSI, Windows automatically saves them as UTF-8 and there are symbols that disappear, for example the letter "Ñ" -
help with routines some don't work...
SLW210 replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Not an AutoCAD issue. What encoding are the files saved with? Font? You are not providing very much to go on. The squared symbol issue would lead me to believe a font issue. -
Lee Mac started following Modifying Lee Mac's Steal Command To insert Specific Blocks
-
Modifying Lee Mac's Steal Command To insert Specific Blocks
Lee Mac replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
You could potentially use myo Import Block application, which is specifically targeting blocks. -
Exit the command with the right mouse button in one click
thekiki replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Just Perfect! Many thanks! -
leonucadomi started following help with routines some don't work...
-
hello all: I recently changed windows on my computer and some of my routines don't work I have reviewed the notepads and I realize that my routines that had the letter "ñ" have disappeared that symbol and some give me a syntax error. Also in some routines the answer was square meters and the number 2 indicated as a subindex and it also disappeared. I don't know if when I save my routines they are saved in some other format and I know the reason. can someone help me?
-
Exit the command with the right mouse button in one click
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Some Like This (defun c:TEcolor136_230 (/ error oldcmdecho sel e typo obj res currentColor n ch? tx) (vl-load-com) (defun error (msg) (if oldcmdecho (setvar "CMDECHO" oldcmdecho) ) (if (and msg (not (wcmatch (strcase msg) "BREAK,CANCEL,EXIT"))) (princ (strcat "Error: " msg)) ) (princ) ) (setq oldcmdecho (getvar "CMDECHO")) (setvar "CMDECHO" 0) (setvar "NOMUTT" 1) ;;; (while (setq sel (entsel "\nSelect TEXT/MTEXT to edit (Enter — exit): ")) (princ "\nSelect TEXTs/MTEXTs to edit (Enter — exit): ") (setq sel (ssget '((0 . "*TEXT"))) e (ssname sel 0) ;;; typo (strcase (cdr (assoc 0 (entget e)))) ) (if sel (progn (setq obj (vlax-ename->vla-object e) tx (cdr (assoc 1 (entget e)));(vla-getTextString obj) ) ;; get the current color (setq currentColor (vl-catch-all-apply 'vlax-get-property (list obj 'Color))) ;; Error handling on receipt (if (vl-catch-all-error-p currentColor) (setq currentColor 0) ) (princ "\rEdit text and left click on empty screen for continue") ;; Opening the text editor (getstring) (setq n -1 res (vl-catch-all-apply 'vl-cmdf (list "_.textedit" e "")) ch? (/= tx (setq tx (cdr (assoc 1 (entget e))))) ) (if (vl-catch-all-error-p res) (princ "\nEditing canceled.") (while (setq e (ssname sel (setq n (1+ n)))) (setq obj (vlax-ename->vla-object e)) (if (and ch? (> n 0)) (entmod (subst (cons 1 tx) (assoc 1 (entget e)) (entget e))) ) ;; After editing, we change the color (if (= currentColor 136) ;; If it's 136, change it to 230. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 230) ) ) (princ "\nCouldn't change color to 230.") (princ "\nThe color has been changed to 230.") ) ) (if (/= currentColor 136) ;; If it's not 136, change it to 136. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 136) ) ) (princ "\nCouldn't change the color to 136.") (princ "\nThe color has been changed to 136.") ) ) ) ) (if obj (princ "\nEditing completed.")) ) (princ "\nIt's not an object TEXT/MTEXT.") ) (setvar "CMDECHO" oldcmdecho) (setvar "NOMUTT" 0) (princ) ) -
Performance helps for Large-Scale Z-Flattening (Z0) AutoLISP Routine?
Steven P replied to p7q's topic in AutoLISP, Visual LISP & DCL
Coming back to this one, I was thinking first off a simple task to write something faster - things like the arcs to ellipses slowing things down a bit. Maybe a different approach, are you able to share the LISP you have now, the one that works, and we can look to see if we can make it work faster? -
Modifying Lee Mac's Steal Command To insert Specific Blocks
CivilTechSource posted a topic in AutoLISP, Visual LISP & DCL
Hi everyone, Firstly I would like to thank all the help I have received the past few months in my journey in learning Lisps and Macros. So, I am creating a CUI that has buttons each button represent a block (e.g. Manhole, Street Lighting Column, Tactile Paving). All these blocks are saved individually in a folder (e.g. Manhole.dwg, Street Lighting.dwg etc). The CUI has a Macro *^C^C-insert;"LE-D-RWP";\;;;explode;last;-purge;Blocks;"LE-D-RWP";N; The above above macro uses combination of insert command and purge to keep the drawing clean from the dwg block that it will bring in. Now while this method is good to bring the block in the drawing it is not very optimal when the block already exists in the drawing. Also, this can be a maintenance nightmare if you have 20+ Blocks (that means 20 dwgs that you will have to access and update something e.g. Layer color, name etc). Last week I found out that you can Setq within a CUI, so I had a lightbulb moment! The idea is this: I have one master dwg that will have all my blocks (easier to maintain and update) and will update the CUI to set the insertion block name global variable and then call a lisp that will import the block from the master dwg (Maybe something similar to Lee Mac Steal?). So my question is the following, is there a simpler version of Lee Mac's Steal command that can access the blocks from the dwg? Lee Mac's steal lisp is over 1400 lines of code which will take a while to review and update. ;;CUI Macro (setq Global_InsBlockName "Block1");(LOAD "STEALUPDATE");STEALUPDATE; ;;Modified Lee Mac Steal Lisp ;;From Drawing X ;;Import Global_InsBlockName I believe this way I can have as many buttons for inserting blocks as I need by having only 1 dwg to insert from. Also it will make maintaining the CUI and Lisp code more manageable. What are your thoughts? -
Try this: No error checking, or checking you have selected the correct polyline. Works only of LWPolylines - comment again if you want this to do 3d polylines as well. I haven't put many notes in this as to how it works, but look through and see if it makes sense. One thing I noticed is your sample block - to me - was an anonymous block name - which might have been the error you noticed (some technical stuff made it so) - as a fix I copied the block entities and created a new block, calling it "Arrow". You'll need to set your block name in the LISP below to the block you want to use (see (Setq MyBlockName "Arrow") line for what to change). (defun c:blockinsert ( / ent MyEnt acount EntCoords MyBlock MyBlockName Ang1 Ang2) ;; Initial Values (setq MyBlockName "Arrow") ;; Change this to your block name ;;Sub functions (defun mAssoc ( key lst / result ) ;; Lee Mac: CadTutor forum (foreach x lst (if (= key (car x)) (setq result (cons (cdr x) result)) ) ) (reverse result) ) (defun LM:getvisibilitystate ( blk / vis ) ;; Lee Mac (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) (defun LM:setdynprops ( blk lst / itm ) ;; Lee Mac (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst)) (foreach x (vlax-invoke blk 'getdynamicblockproperties) (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst)) (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))) ) ) ) (defun SetAng ( Ang1 Ang2 MyEnt / ) ;; From Lee Macs LISPs. Change 'cons' "Angle", "Angle1" to suit dynamic block (lm:setdynprops (vlax-ename->vla-object MyEnt) (list (cons "Angle" Ang1) (cons "Angle1" Ang2))) ; Ang in radians ) (defun AddBlock ( BName Pt XScale YScale ZScale / ) ;; Adds block to the drawing (setq NewBlock (entmakex (list '(0 . "INSERT") (cons 2 BName) (cons 10 Pt) (cons 41 XScale) (cons 42 YScale) (cons 43 ZScale) (cons 50 0); ))) ; end setq entmakex, list NewBlock ) ;; End sub functions (setq Ent (car(entsel "Select LW Polyline"))) (setq MyEnt (entget Ent)) (if (or (equal (cdr (assoc 0 MyEnt)) "LWPOLYLINE") ) ; end or (progn (setq EntCoords (massoc 10 MyEnt)) (setq acount 0) (while (< acount (length EntCoords)) ;;Insert (setq MyBlock (AddBlock MyBlockName (nth acount EntCoords) 1 1 1) ) ;;Ang1 (if (= acount 0) ; First point (progn (setq ang1 (angle (nth acount EntCoords) (nth (+ acount 1) EntCoords) )) ; = ang2 ) ; end progn (progn (setq ang1 (angle (nth acount EntCoords) (nth (- acount 1) EntCoords) )) ) ; end progn ) ; end if ;;Ang2 (if (= acount (- (length EntCoords) 1)) ; last point (progn (setq ang2 (angle (nth acount EntCoords) (nth (- acount 1) EntCoords) )) ; = ang1 (setq ang2 (angle (nth (- acount 1) EntCoords) (nth acount EntCoords) )) ) (progn (setq ang2 (angle (nth (+ acount 1) EntCoords) (nth acount EntCoords) )) ) ) ; end if (SetAng Ang1 Ang2 (entlast)) ;; Sets dynamic block angle (setq acount (+ acount 1)) ) ; end while ) (progn (princ "Polyline not selected") ) ; end progn ) ; end if polyline (princ) ; exit quietly )
-
Exit the command with the right mouse button in one click
thekiki replied to Nikon's topic in AutoLISP, Visual LISP & DCL
This is the first possibilitie. The second possibilitie that i only want to select multiple texts (not edited) and if: -the current color is not equal to 136, then change it to 136. -the current color is 136, then change it to 230. thanks for your help! -
Exit the command with the right mouse button in one click
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Do you want to edit the content of a text and apply the same modification to the rest of the selected texts? -
Steven P started following Block insert LISP
-
I'd be forgetting AI for now, handy for snippets but still not quiet there. Lee Mac has some great resources: https://lee-mac.com/dynamicblockfunctions.html might be what you are looking for. Also search this forum for Massoc Implementations which can be used to return a list of vertices. (defun mAssoc ( key lst / result ) (foreach x lst (if (= key (car x)) (setq result (cons (cdr x) result)) ) ) (reverse result) ) Will give a list of points along a polyline where key in this case is 10, and list is the polyline entity description from maybe (entget (car (entsel))) Dynamic blocks: (defun LM:getvisibilitystate ( blk / vis ) (if (setq vis (LM:getvisibilityparametername blk)) (LM:getdynpropvalue blk vis) ) ) (lm:getdynprops (vlax-ename->vla-object (car(entsel))) ) returns the format and names of dynamic block variables and setting them with: (defun LM:setdynprops ( blk lst / itm ) (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst)) (foreach x (vlax-invoke blk 'getdynamicblockproperties) (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst)) (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))) ) ) ) (lm:setdynprops (vlax-ename->vla-object (car(entsel))) (list (cons "Angle" 0) (cons "Angle2" pi))) Inserting the blocks can be as simple as (command "insert" "Stylb_NN_nov" -Point- "" "" "") where point is the points along the massoc returned list (ignore the 1st and last point) and then use (entlast) in the setdynprops line instead of (car(entsel)) Might be a pointer to get you making something up.
-
Liviu Petreus started following rlx
-
Exit the command with the right mouse button in one click
thekiki replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Hi Bigal, With the GLAVCVS's lisp (TEcolor136_230), i can only select text one by one. I would like to select several text at the same time in the selection. Thanks for your help. - Yesterday
-
Exit the command with the right mouse button in one click
BIGAL replied to Nikon's topic in AutoLISP, Visual LISP & DCL
@thekiki what did you have in mind to do with the selected text ? -
Ok thats is very similar to what I was talking about, its easy to draw an arrow at a point along a pline, you can do this in a number of ways one of the easiest is to just use "V" rotated + - to to the angle between the points. Which of these is correct ? You should post a dwg not an image, can then see sizes and offsets from vertices.
-
thekiki started following Exit the command with the right mouse button in one click
-
Exit the command with the right mouse button in one click
thekiki replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Hi all, Is there a possibility to select multiple text at once. Thanks for your answer. -
Hello thank you for your reply. May be I did not explain properly what I want to do. I will post some pictures may be they will help. On the Block_1.jpg is how the drawing has to look like. On the Block_2.jpg is the block it self when is edited. So the script has to change "Angle" and "Angle1" so the so called arrows point to the previous and next block - Block_3.jpg
-
Exit the command with the right mouse button in one click
Nikon replied to Nikon's topic in AutoLISP, Visual LISP & DCL
@GLAVCVS thank you very much for the 2 options, I like both options, but the first option suits me better. -
Exit the command with the right mouse button in one click
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
If you don't want the command to end after editing the text, you can keep the "while" loop, as shown in this other code. The operation will be the same except that to exit the command, you'll need an additional "right click." (defun c:TEcolor136_230 (/ error oldcmdecho sel e typo obj res currentColor para) (vl-load-com) (defun error (msg) (if oldcmdecho (setvar "CMDECHO" oldcmdecho) ) (if (and msg (not (wcmatch (strcase msg) "BREAK,CANCEL,EXIT"))) (princ (strcat "Error: " msg)) ) (princ) ) (setq oldcmdecho (getvar "CMDECHO")) (setvar "CMDECHO" 0) (while (setq sel (entsel "\nSelect TEXT/MTEXT to edit (Enter — exit): ")) (setq ;sel (entsel "\nSelect TEXT/MTEXT to edit (Enter — exit): ") e (car sel) typo (strcase (cdr (assoc 0 (entget e)))) ) (if (wcmatch typo "TEXT,MTEXT") (progn (setq obj (vlax-ename->vla-object e)) ;; get the current color (setq currentColor (vl-catch-all-apply 'vlax-get-property (list obj 'Color)) ) ;; Error handling on receipt (if (vl-catch-all-error-p currentColor) (setq currentColor 0) ) ;; Opening the text editor (getstring) (setq res (vl-catch-all-apply 'vl-cmdf (list "_.textedit" e "")) ) ;;; (if (/= (setq res (getstring (strcat "\nEdit text <" (cdr (assoc 1 (entget e))) ">: "))) "") ;;; (entmod (subst (cons 1 res) (assoc 1 (entget e)) (entget e))) ;;; ) (if (vl-catch-all-error-p res) (princ "Editing canceled.") ;; After editing, we change the color (progn (if (= currentColor 136) ;; If it's 136, change it to 230. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 230) ) ) (princ "Couldn't change color to 230.") (princ "The color has been changed to 230.") ) ) (if (/= currentColor 136) ;; If it's not 136, change it to 136. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 136) ) ) (princ "Couldn't change the color to 136.") (princ "The color has been changed to 136.") ) ) (princ "Editing completed.") ) ) ) (princ "It's not an object TEXT/MTEXT.") ) ) (setvar "CMDECHO" oldcmdecho) (princ) ) -
Exit the command with the right mouse button in one click
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
I hope the 'textedit' options in your version of AutoCAD aren't a problem.