TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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 Ø:
(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" "Ø")
-
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.
-
Perhaps try something along the lines of the following:
)
(setq s
(vl
-string
-subst "\\U+00D8" "%%C" s
)) )
)
)
)
)
)
)
-
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.