Author Topic: Stripping controle characters from MTEXT  (Read 2056 times)

0 Members and 1 Guest are viewing this topic.

S.Langhammer

  • Guest
Stripping controle characters from MTEXT
« on: July 10, 2013, 10:59:56 AM »
Hello again,
I'm still struggleing on the interface.

The current obstacle is: MText.
Since the Delphi side of the interface doesn't know how to handle multilinetexts I'm supposed to give it out as simple text.
So far so good. MTexts and Texts have a lot in common. so the toughest point is to get rid of the whole controle information.
I should admit, I'm using a function of someone else, which i don't quite understand to do that.

My problem now is, that I don't get the texts out the way they appear on screen.
example:
In the drawing appears: -2,95
The text line in BricsCADs object inspector says: \A1;{\fSwis721 BT|b0|i0|c0|p34;\C7;-2,95}
What I get is: 1;{\fSwis721 BT|b0|i0|c0|p34;\C7;-295}
what i'd Need would be: -295 (since I have to strip the commas off all text)

now the functions I use are:

Code - Auto/Visual Lisp: [Select]
  1. (defun mtx(mtxtVal / mcnt mstpt msrf mtstStr mtxtVal mtxtLines)
  2.         (while(=(substr mtxtVal(strlen mtxtVal)1)" ")
  3.                 (setq mtxtVal(vl-string-right-trim " " mtxtVal)1)
  4.         )
  5.         (if(=(substr mtxtVal 1 2)"{\\")(progn
  6.                         (setq mtxtVal(substr mtxtVal 1(-(strlen mtxtVal)1))
  7.                                   mcnt 1
  8.                         )
  9.                         (while(/=(substr mtxtVal mcnt 1)";")
  10.                                 (setq mcnt(+ mcnt 1))
  11.                         )
  12.                         (setq mtxtVal(substr mtxtVal(+ mcnt 1)))
  13.         ))    
  14.         (setq mtxtLines(list)
  15.                   mstpt 1 mcnt 1
  16.                   msrf "\\P"
  17.         )
  18.         (while(< mcnt(+(-(strlen mtxtVal)(strlen msrf))1))
  19.                 (setq mtstStr(substr mtxtVal mcnt(strlen msrf)))
  20.                 (if(= mtstStr msrf)
  21.                         (setq mtxtLines(append mtxtLines(list(substr mtxtVal mstpt(- mcnt mstpt))))
  22.                                   mstpt(+ mcnt 2)
  23.                                   mcnt(+ mcnt 1)
  24.                         )
  25.                 )
  26.                 (setq mcnt(+ mcnt 1))
  27.         )
  28.         (if(< mstpt (strlen mtxtVal))
  29.                 (setq mtxtLines(append mtxtLines(list(substr mtxtVal mstpt))))
  30.         )
  31.         (vl-string-trim " " mtxtLines)
  32. )
  33. ; -
  34. (defun stripIt(sTxt / sa sCntr sChk)
  35.         (foreach sa (list "\\O" "\\o" "\\L" "\\l" "\\~" "\\A")
  36.                 (setq sCntr 1)  
  37.                 (while(< sCntr(strlen sTxt))
  38.                         (setq sChk(substr sTxt sCntr 2))
  39.                         (if(= sChk sa)
  40.                                 (setq sTxt (if(= sCntr 1)
  41.                                                                 (substr sTxt 3)
  42.                                                                 (strcat(substr sTxt 1(- sCntr 1))(substr sTxt(+ sCntr 2)))
  43.                                                         )
  44.                                 )
  45.                         )
  46.                         (setq sCntr(+ sCntr 1))
  47.                 )
  48.         )
  49.         (vl-string-trim " " sTxt)
  50. )
  51. ;;; -
  52.  
  53. (defun getMtxData(/ bigStr bigLst entPt entVal a entNorm)
  54.         (setq entNorm   (cdr(assoc 210 entity))
  55.                   entPt         (cdr(assoc  10 entity))
  56.                   bigStr        (if (assoc   3 entity)(progn
  57.                                                 ;THEN
  58.                                                 (setq bigStr "")
  59.                                                 (foreach a entity
  60.                                                         (if(=(car a) 3)
  61.                                                                 (setq bigStr(strcat bigStr(cdr a)))
  62.                                                         )
  63.                                                 )
  64.                                                 (strcat bigStr(cdr(assoc  1 entity))))
  65.                                                 ;ELSE
  66.                                                 (cdr(assoc  1 entity))
  67.                                         )
  68.         )
  69.         ;--- Get rid of the font control data inside brackets {} ?!?!?!?
  70.         ;;; this doesn't seem to work properly
  71.         (setq bigLst(mtx(stripSigns(stripIt bigStr)))
  72.                   entVal ""
  73.         )
  74.         (foreach a bigLst
  75.                 (setq entVal(strcat entVal " " a))
  76.         )
  77.         (fileWrite(strcat "TEXT,"(cdr(assoc 8 entity))","(rtos(car entPt)2 4)","(rtos(cadr entPt)2 4)","(rtos(caddr entPt)2 4)"," entVal ","(rtos(cdr(assoc 40 entity))2 4)","(vl-string-trim "r"(angtos(cdr(assoc 50 entity))3 4))",1,"(rtos(car entNorm)2 4)","(rtos(cadr entNorm)2 4)","(rtos(caddr entNorm)2 4)))
  78.         ;;; 0 . entity type
  79.         ;;; 1 . Layer
  80.         ;;; 2;3;4 . insertion point
  81.         ;;; 5 . Text
  82.         ;;; 6 . text hight
  83.         ;;; 7 . Rotation
  84.         ;;; 8 . scaling
  85.         ;;; 9;10;11 . normal/extrusion vector
  86.         (princ)
  87. )
  88. (defun getTxtData(/ entPt entNorm)
  89.         (setq entNorm   (cdr(assoc 210 entity))
  90.                   entPt         (trans(cdr(assoc 10 entity))entNorm 0)
  91.         )
  92.         (fileWrite (strcat "TEXT,"(cdr(assoc 8 entity))","(rtos(car entPt)2 4)","(rtos(cadr entPt)2 4)","(rtos(caddr entPt)2 4)","(stripSigns(cdr(assoc 1 entity)))","(rtos(cdr(assoc 40 entity))2 4)","(vl-string-right-trim "r"(angtos(cdr(assoc 50 entity))3 4))","(rtos(cdr(assoc 41 entity))2 4)","(rtos(car entNorm)2 4)","(rtos(cadr entNorm)2 4)","(rtos(caddr entNorm)2 4)));;; Ausgabeliste an die Datei anhängen
  93.         ;;; 0 . entity type
  94.         ;;; 1 . Layer
  95.         ;;; 2;3;4 . insertion point
  96.         ;;; 5 . Text
  97.         ;;; 6 . text hight
  98.         ;;; 7 . Rotation
  99.         ;;; 8 . scaling
  100.         ;;; 9;10;11 . normal/extrusion vector
  101.         (princ)
  102. )       ;;; ende getTxtData
  103.  

Now the way I see it is, that mtx is supposed to remove the control information , which it doesn't do. Can anyone explain to me, what's going wrong? Or maybe even Show me a working unction?
As always thanks in advance!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

S.Langhammer

  • Guest
Re: Stripping controle characters from MTEXT
« Reply #2 on: July 11, 2013, 02:40:07 AM »
Thanks for the help CAB!

BlackBox

  • King Gator
  • Posts: 3770
Re: Stripping controle characters from MTEXT
« Reply #3 on: July 11, 2013, 01:17:23 PM »
Wouldn't Lee's Batch Find & Replace Text do the trick?



I HAVE NO TIME TO SPARE, oops caps

Separately, this might help with that. :thumbsup:

Cheers
"How we think determines what we do, and what we do determines what we get."