Jump to content

Leaderboard

  1. Steven P

    Steven P

    Trusted Member


    • Points

      2

    • Posts

      2,816


  2. barristann

    barristann

    Community Member


    • Points

      1

    • Posts

      108


  3. Lee Mac

    Lee Mac

    Trusted Member


    • Points

      1

    • Posts

      21,014


  4. CyberAngel

    CyberAngel

    Trusted Member


    • Points

      1

    • Posts

      1,965


Popular Content

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

  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
×
×
  • Create New...