Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/19/2023 in all areas

  1. Have you tried putting the layer name in quotes? Use "pdf_solid fills" in the script instead of the literal name. If that doesn't work, check back with us.
    1 point
  2. When comparing reals (aka doubles) in AutoLISP, you should use the equal function with a small tolerance (e.g. 1e-8 = 0.00000001) in order to account for infinitesimal inaccuracies that are inevitably introduced at the limits of the precision of this format - two doubles are rarely ever exactly equal on a bitwise level. As such, I would suggest changing: (= height 594.0) To: (equal height 594.0 1e-8)
    1 point
  3. That's 100% incredible, Steven! I used your codes so many times at work today. I was speechless when I first tested them this morning. I'm still amazed something like this can be coded. Thank you Steven P for being so awesome!
    1 point
  4. (sorry Tharwat - 20 minutes copy, paste and check isn't going to pay enough to cover your time to even make an invoice in this case)
    1 point
  5. So you could look into this page here: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-8543549B-F0D7-43CD-87A3-F6B827FF0B88 which gives the string functions. Perhaps use: (strlen [string ...]) to find the length of the text string (vl-string-search pattern string [ start-pos]) to find the position of the first '-' and from calculate the variable 'len' in the code above and go from there. As an alternative I use Lee Macs String to List (http://lee-mac.com/stringtolist.html#:~:text=%3B%3B String to List - Lee Mac %3B%3B,str (%2B pos len)))) (reverse (cons str lst)))) to split the text strings into parts, then remake the string using the parts and changing them as required. I quite like this way since you can change any part of the text between any deliminators - even multiple changes easily. Something like this: Should be quite versatile to do all the above, variable lengths, suffix and prefix, (defun c:Testthis ( / Prefix Suffix presuf ss acount MyNewString MyEnt MyString MyList MyCount MyNewString) (setq Prefix "Prefix TExt") ; change these texts as required or ;;(setq Prefix (getstring T "\nEnter Prefix Text:")) (setq Suffix "Suffix Text") ;;(setq Suffix (getstring T "\nEnter Suffix Text:")) ;;Sub Functions (defun LM:str->lst ( str del / pos ) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) (initget "pre suf both") (setq presuf (strcase (getkword "\nEnter an option (Pre/Suf/both): ") )) ; Select change to make (setq ss (ssget '((0 . "*TEXT"))) ) ; Select text, mtext, rtext (setq acount 0) (while (< acount (sslength ss)) ; loop through selection (setq MyNewString "") ; empty text string (setq MyEnt (entget (ssname ss acount)) ) (setq MyString (cdr (assoc 1 MyEnt))) ; Gets text strinbg (up to 1st ~500 characters) (setq MyList (LM:str->lst MyString "-")) ; text to list ;;Modify list items, could use cond here (if (= presuf "PRE") (setq MyList (subst Prefix (nth 0 MyList) MyList ) ) ) (if (= presuf "SUF") (setq MyList (subst Suffix (nth 0 (reverse MyList)) MyList ) ) ) (if (= presuf "BOTH") (progn (setq MyList (subst Prefix (nth 0 MyList) MyList ) ) ; Change Prefix text as you want (setq MyList (subst Suffix (nth 0 (reverse MyList)) MyList ) ) ; change Suffix text as you want ) ) ;;Remake text from list (setq MyNewString (nth 0 MyList)) (setq MyCount 1) (while (< MyCount (length MyList)) (setq MyNewString (strcat MyNewString "-" (nth MyCount MyList))) (setq MyCount (+ MyCount 1)) ) ; end while (entmod (subst (cons 1 MyNewString) (assoc 1 MyEnt) MyEnt )) ; update text (setq acount (+ acount 1)) ) ; end while (princ) )
    1 point
  6. Version 1.3

    3,011 downloads

    Here I give you guys a program that will either delete duplicate blocks or move them to a user-input layer that could be accidentally placed on top of another. The determination to do such program in place of the OVERKILL command is to remove unwanted dynamic blocks with different visibility parameters, leading to blocks having an "undefined name". This leads to the original OVERKILL command to fail. As such, I introduce you this program that catches all types of blocks (excluding xrefs). Be careful that it delete blocks matching all the criteria below: The blocks in comparison share the same insertion point through a given tolerance. The blocks in comparison share the same effective name. The blocks in comparison share the same effective scale. So if the three criteria above match while the rotation of the blocks differ, it will still be deleted. I've had many occasion on using block counting routines that reports excessive values for this very reason. This routine has helped me fix those nasty errors that would otherwise be almost, if not entirely, impossible to detect with the human eye. As thanks for helping me solve many problems that I've posted in the LISP forum, this is the least I can offer, so I hope it's of some use. More details on this forum. Type BOVERKILL to start command. I welcome all suggestion, feedbacks, comments, and criticisms you have. Feel free to add your ideas, and I will try to improve them. Enjoy.
    1 point
×
×
  • Create New...