Is it a bug of VisualLisp?
Getting questuion mark from Proprty line symbol
(setq text(vla-get-textString(setq obj(vlax-ename->vla-object(car(entsel))))))
"78m N OF N ? GRANDVIEW HWY."
(vla-put-textString obj text)
(setq text(vla-get-textString(setq obj(vlax-ename->vla-object(car(entsel))))))
"78m N OF N \U+214A GRANDVIEW HWY."
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
@Anonymous wrote:Is it a bug of VisualLisp?
Yes, this is a known bug.
To avoid the issue, retrieve the text content from the relevant DXF groups.
Here is my function for this purpose:
;; Get Textstring - Lee Mac ;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes (defun LM:gettextstring ( ent / enx itm str typ ) (setq enx (entget ent) typ (cdr (assoc 0 enx)) ) (cond ( (wcmatch typ "TEXT,*DIMENSION") (cdr (assoc 1 (reverse enx))) ) ( (= "MULTILEADER" typ) (cdr (assoc 304 enx)) ) ( (wcmatch typ "ATTRIB,MTEXT") (setq str (cdr (assoc 1 (reverse enx)))) (while (setq itm (assoc 3 enx)) (setq str (strcat (cdr itm) str) enx (cdr (member itm enx)) ) ) str ) ) )
Example of usage:
(if (setq ent (car (entsel)))
(LM:gettextstring ent)
)
@Anonymous wrote:thanks
You're welcome!
@3wood wrote:If you set your computer to other Asian language other than Engilish, you may read and write properly.
Personally, changing system-wide settings as you suggest in several threads isn't preferable and rarely suitable for company environments where access to such settings is prohibited.
We dont use any non-enlgish environment and why would we do it in Cnada? We do use center line and property line symbols.
To me, it is a bug and vla-get-textString cannot be used at all!
@Lee_Mac wrote:
@Anonymous wrote:Is it a bug of VisualLisp?
Yes, this is a known bug.
To avoid the issue, retrieve the text content from the relevant DXF groups.
Here is my function for this purpose:
;; Get Textstring - Lee Mac ;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes (defun LM:gettextstring ( ent / enx itm str typ ) (setq enx (entget ent) typ (cdr (assoc 0 enx)) ) (cond ( (wcmatch typ "TEXT,*DIMENSION") (cdr (assoc 1 (reverse enx))) ) ( (= "MULTILEADER" typ) (cdr (assoc 304 enx)) ) ( (wcmatch typ "ATTRIB,MTEXT") (setq str (cdr (assoc 1 (reverse enx)))) (while (setq itm (assoc 3 enx)) (setq str (strcat (cdr itm) str) enx (cdr (member itm enx)) ) ) str ) ) )Example of usage:
(if (setq ent (car (entsel)))
(LM:gettextstring ent)
)
Sharing from a little lesson I learned when working on this and this... When an MLeader Object's ContentType != 5 (MText), this is returned when using your example above:
Select object: "LEADER_LINE{"
... So a slight mod to acount for this (if I may), could be:
(defun LM:gettextstring ( ent / enx itm str typ ) (setq enx (entget ent) typ (cdr (assoc 0 enx)) ) (cond ( (wcmatch typ "TEXT,*DIMENSION") (cdr (assoc 1 (reverse enx))) ) ( (and (= "MULTILEADER" typ) (= 5 (cdr (assoc 172 enx))) ) (cdr (assoc 304 enx)) ) ( (wcmatch typ "ATTRIB,MTEXT") (setq str (cdr (assoc 1 (reverse enx)))) (while (setq itm (assoc 3 enx)) (setq str (strcat (cdr itm) str) enx (cdr (member itm enx)) ) ) str ) ) )
... Otherwise, one would need to account for each AcMLeaderContentType enum (DXF 172; not sure of a documented ActiveX listing?), so pulling from Visual Studio's Object Browser:
BlockContent, MTextContent, NoneContent, and TolleranceContent.
Cheers
"How we think determines what we do, and what we do determines what we get."
Good catch BlackBox, though I am inclined to use:
;; Get Textstring - Lee Mac ;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes (defun LM:gettextstring ( ent / enx itm str typ ) (setq enx (entget ent) typ (cdr (assoc 0 enx)) ) (cond ( (wcmatch typ "TEXT,*DIMENSION") (cdr (assoc 1 (reverse enx))) ) ( (and (= "MULTILEADER" typ) (= acmtextcontent (cdr (assoc 172 (reverse enx)))) ) (cdr (assoc 304 enx)) ) ( (wcmatch typ "ATTRIB,MTEXT") (setq str (cdr (assoc 1 (reverse enx)))) (while (setq itm (assoc 3 enx)) (setq str (strcat (cdr itm) str) enx (cdr (member itm enx)) ) ) str ) ) )
Since this adheres to the values of the acmleadercontenttype enums.
@Lee_Mac wrote:Good catch BlackBox, though I am inclined to use:
;; Get Textstring - Lee Mac ;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes (defun LM:gettextstring ( ent / enx itm str typ ) (setq enx (entget ent) typ (cdr (assoc 0 enx)) ) (cond ( (wcmatch typ "TEXT,*DIMENSION") (cdr (assoc 1 (reverse enx))) ) ( (and (= "MULTILEADER" typ) (= acmtextcontent (cdr (assoc 172 (reverse enx)))) ) (cdr (assoc 304 enx)) ) ( (wcmatch typ "ATTRIB,MTEXT") (setq str (cdr (assoc 1 (reverse enx)))) (while (setq itm (assoc 3 enx)) (setq str (strcat (cdr itm) str) enx (cdr (member itm enx)) ) ) str ) ) )
Since this adheres to the values of the acmleadercontenttype enums.
That is kind of you to say, Lee; I am fortunate to have suffered some great mentorship along the way. *tips hat*
While I do like the readability of the spelled out enum value (one of the reasons I prefer Visual LISP when not exponentially slower)... I guess I found myself in the habbit of using int, and double values with DXF code queries, etc., and spelled out with vl Property calls. *shrug*... I like the spelled out better myself as well.
Cheers
"How we think determines what we do, and what we do determines what we get."
@BlackBox_ wrote:
That is kind of you to say, Lee; I am fortunate to have suffered some great mentorship along the way. *tips hat*
Anytime; Cheers
@BlackBox_ wrote:I like the spelled out better myself as well.
I think the intent is clearer, especially when revisiting the code months later, it saves looking up the DXF values; though of course, the code no longer becomes compatible on Mac and R14 where such enums aren't defined...
Aside: this forum handles quotes terribly! - Where did the HTML editor pane disappear to...?
@Lee_Mac wrote:I think the intent is clearer, especially when revisiting the code months later, it saves looking up the DXF values; though of course, the code no longer becomes compatible on Mac and R14 where such enums aren't defined...
That's a good point, as well.
@Lee_Mac wrote:
Aside: this forum handles quotes terribly! - Where did the HTML editor pane disappear to...?
Right... Here *points with finger*
"How we think determines what we do, and what we do determines what we get."
@BlackBox_ wrote:Right... Here *points with finger*
That's where I thought it should be, but its not there for me:
Using FF23, but also not present in IE10
I also had a quick browse of the 'My Settings' section and didn't see anything relating to it being disabled.
... A thing like that....
/Pete Campbell Voice
... I am using Chrome; didn't think it really made that much of a difference. Strange in deed.
"How we think determines what we do, and what we do determines what we get."
So as not to further contaminate this thread, I have reported the issue in the appropriate board here - hopefully it will be resolved.
Thanks for your time BlackBox.
LM:GetTextString, has a bug. Text is stored in sequence of grp 1 and grp(s) 3. Grp 1 can be as first or last and maybe middle of the object
;;; --------------------------------------------------------------------------------------------------------------
(defun GetTextString ( entN / entL item str entT )
;; Returns the text content of Text, MText, Multileaders, Dimensions & Attributes
;; vla-get-textString has bug in ac2020/ac2022 it returns unicode char incorrect as "?"
;; LM:GetTextString, but fixed as text is in sequence of grp 1 and grp(s) 3.
;; Grp 1 can be as first or last and maybe middle
(setq entL (entget entN)
entT (cdr (assoc 0 entL))
)
(cond
((wcmatch entT "TEXT,*DIMENSION")
(cdr (assoc 1 entL))
)
((and (= "MULTILEADER" entT)(= acmtextcontent (cdr (assoc 172 (reverse entL)))))
(cdr (assoc 304 entL))
)
((wcmatch entT "ATTRIB,MTEXT")
(setq str "")
(foreach item entL
(if (or (= 1 (car item))(= 3 (car item)))
(setq str (strcat str (cdr item)))
)
)
str
)
)
)
Can't find what you're looking for? Ask the community or share your knowledge.