Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Ivan N

    Block insert LISP

    I made the block again, changed rotations to Angle_1 and Angle_2. Changed in .lsp file too. The script inserts blocks but the angels are not changed. Am am attaching the file, with polyline and inserted block.
  3. Ivan N

    Block insert LISP

    I made the block again, changed rotations to Angle_1 and Angle_2. Changed in .lsp file too. The script inserts blocks but the angels are not changed. Am am attaching the file, with polyline and inserted block. Test.dwg
  4. Today
  5. leonucadomi

    help with routines some don't work...

    I already found the solution, at least temporarily. what I have to do is the original routine (ansi code), modify it if required, but also add an ansi character, example ;ñ only then it lets me save as in ANSI mode and the characters are no longer deleted or changed.
  6. GLAVCVS

    help with routines some don't work...

    I don't think it has anything to do with it. And if it does, it can probably be fixed by configuring the OS.
  7. leonucadomi

    help with routines some don't work...

    I don't know if it has to do with the fact that the autocad I use is the 2013 version.
  8. GLAVCVS

    help with routines some don't work...

    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.
  9. Steven P

    help with routines some don't work...

    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?
  10. leonucadomi

    help with routines some don't work...

    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.
  11. leonucadomi

    help with routines some don't work...

    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 "Ñ"
  12. 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.
  13. You could potentially use myo Import Block application, which is specifically targeting blocks.
  14. Just Perfect! Many thanks!
  15. 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?
  16. 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) )
  17. 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?
  18. 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?
  19. Steven P

    Block insert LISP

    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 )
  20. 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!
  21. Do you want to edit the content of a text and apply the same modification to the rest of the selected texts?
  22. maahee

    tables

    Thanks to all
  23. Steven P

    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.
  24. 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.
  25. Yesterday
  26. @thekiki what did you have in mind to do with the selected text ?
  27. BIGAL

    Block insert LISP

    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.
  28. Hi all, Is there a possibility to select multiple text at once. Thanks for your answer.
  1. Load more activity
×
×
  • Create New...