Author Topic: Trying to fix %%C or symbol.  (Read 213 times)

0 Members and 1 Guest are viewing this topic.

framednlv

  • Newt
  • Posts: 55
Trying to fix %%C or symbol.
« 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" "")

tombu

  • Bull Frog
  • Posts: 274
  • ByLayer=>Not0
Re: Trying to fix %%C or symbol.
« Reply #1 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.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Lee Mac

  • Seagull
  • Posts: 12696
  • London, England
Re: Trying to fix %%C or symbol.
« Reply #2 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. )

framednlv

  • Newt
  • Posts: 55
Re: Trying to fix %%C or symbol.
« Reply #3 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.