Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vla-get-textString \U+ symbols

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
MetroVancouverDrafting
8319 Views, 16 Replies

vla-get-textString \U+ symbols

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."

 

 

16 REPLIES 16
Message 2 of 17


@MetroVancouverDrafting 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)
)

 

 

 

Message 3 of 17

thanks

Message 4 of 17
3wood
in reply to: Lee_Mac

If you set your computer to other Asian language other than Engilish, you may read and write properly.

Message 5 of 17


@MetroVancouverDrafting 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.

 

Message 6 of 17
3wood
in reply to: Lee_Mac

Agree with you, it is a bit annoying. But I reckon it is not a bug.

Message 7 of 17

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!

Message 8 of 17
BlackBox_
in reply to: Lee_Mac


@Lee_Mac wrote:

@MetroVancouverDrafting 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."

Message 9 of 17
Lee_Mac
in reply to: BlackBox_

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.

Message 10 of 17
BlackBox_
in reply to: Lee_Mac


@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."

Message 11 of 17
Lee_Mac
in reply to: BlackBox_


@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 Smiley Happy


@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...?

Message 12 of 17
BlackBox_
in reply to: Lee_Mac


@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*

 

acad.html.editor.png



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

Message 13 of 17
Lee_Mac
in reply to: BlackBox_


@BlackBox_ wrote:

Right... Here *points with finger*


That's where I thought it should be, but its not there for me:

 

nohtml.png

 

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. Smiley Sad

Message 14 of 17
BlackBox_
in reply to: Lee_Mac

... 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."

Message 15 of 17
Lee_Mac
in reply to: BlackBox_

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.

Message 16 of 17
BlackBox_
in reply to: Lee_Mac


@Lee_Mac wrote:

 

Thanks for your time BlackBox.


Cheers, mate. :beer:



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

Message 17 of 17

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.

Post to forums  

Autodesk Design & Make Report

”Boost