TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: framednlv on June 16, 2022, 04:19:57 PM

Title: Trying to fix %%C or Ø symbol.
Post by: framednlv on June 16, 2022, 04:19:57 PM
I'm trying to replace the %%C with a Ø symbol.  The symbol came from mtext with the %%C exploded.  The exploded version is working when brought into Revit, but the %%C does not.  I have a routine that works when I copy it from within notepad and paste it into the command line. When I load it from the lsp file and run it, I get Ø insted.  Here is what I'm using to change the %%C to Ø:

Code: [Select]
(defun PH_FIX2 (old new / regex)
  (setq regex (vlax-get-or-create-object "VBScript.RegExp"))
  (vlax-put-property regex 'global actrue)
  (vlax-put-property regex 'ignorecase actrue)
  (vlax-put-property regex 'multiline actrue)
  (vlax-put-property regex 'pattern old)
  ;;process every block
  (vlax-for n  (vla-get-blocks
    (vla-get-activedocument
      (vlax-get-acad-object)
    )
  )
    (vlax-for m n
    (if (member (vla-get-objectname m) '("AcDbMtext" "AcDbText" "AcDbMLeader" ))
      (vla-put-textstring
m
(vlax-invoke
  regex
  'replace
  (vla-get-textstring m)
  new
))))))
(PH_FIX2 "%%C" "Ø")
Title: Re: Trying to fix %%C or Ø symbol.
Post by: tombu on June 16, 2022, 06:14:30 PM
Unicode U+2205 but I've always used Alt+0216 which don't work on all fonts but do on all the ones I use include the Ø symbol.
If the font you're using doesn't support it %%c substitutes Ø from another font in AutoCAD.

Don't know anything about Revit but hope that helps.
Title: Re: Trying to fix %%C or Ø symbol.
Post by: Lee Mac on June 16, 2022, 06:35:10 PM
Perhaps try something along the lines of the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / s )
  2.         (if (= :vlax-false (vla-get-isxref b))
  3.             (vlax-for o b
  4.                 (if (and (wcmatch (strcase (vla-get-objectname o) t) "*text,*mleader")
  5.                          (wcmatch (setq s (vla-get-textstring o)) "*%%C*")
  6.                     )
  7.                     (progn
  8.                         (while (wcmatch s "*%%C*")
  9.                             (setq s (vl-string-subst "\\U+00D8" "%%C" s))
  10.                         )
  11.                         (vla-put-textstring o s)
  12.                     )
  13.                 )
  14.             )
  15.         )
  16.     )
  17.     (princ)
  18. )
Title: Re: Trying to fix %%C or Ø symbol.
Post by: framednlv on June 16, 2022, 06:43:56 PM
Thanks,
(chr 0216) seems to be working.

I do need to replace the same thing in a table cell, any chance I could get some help with that part?

PS, LM: thanks for everything throughout the years.