Author Topic: vla-UpdateMTextAttribute Does not "un-wrap" Attribute text  (Read 1400 times)

0 Members and 1 Guest are viewing this topic.

kerrcad

  • Mosquito
  • Posts: 3
vla-UpdateMTextAttribute Does not "un-wrap" Attribute text
« on: October 13, 2022, 01:43:53 PM »
I have created a multiline attribute, with a mask, that will contain a street address.  Regardless of the text length, I want the text to remain single line as opposed to word wrapping.

When I update the attribute property via "vla-put-MTextBoundaryWidth" to a number greater than the required single line attribute length, the string does not "word un-wrap".  Below is my awkward code.  Aside from the awkwardness, what am I doing wrong?

(defun AttribSetMTextWidthSingleLine (ename Tag /)
(setq elist (entget ename))
(while (/= (cdr (assoc 0 elist)) "SEQEND")
(setq elist (entget (entnext (cdr (assoc -1 elist)))))
(if (= (cdr (assoc 2 elist)) Tag)
(progn
(setq enAtt (cdr (assoc -1 elist))
    objAtt (vlax-ename->vla-object enAtt)
)
(vla-put-MTextBoundaryWidth objAtt 60.0)
(vla-UpdateMTextAttribute objAtt)
) ;progn
) ;if Tag
) ;while
)

PKENEWELL

  • Bull Frog
  • Posts: 309
Re: vla-UpdateMTextAttribute Does not "un-wrap" Attribute text
« Reply #1 on: October 13, 2022, 02:55:25 PM »
I have created a multiline attribute, with a mask, that will contain a street address.  Regardless of the text length, I want the text to remain single line as opposed to word wrapping.

When I update the attribute property via "vla-put-MTextBoundaryWidth" to a number greater than the required single line attribute length, the string does not "word un-wrap".  Below is my awkward code.  Aside from the awkwardness, what am I doing wrong?

(defun AttribSetMTextWidthSingleLine (ename Tag /)
(setq elist (entget ename))
(while (/= (cdr (assoc 0 elist)) "SEQEND")
(setq elist (entget (entnext (cdr (assoc -1 elist)))))
(if (= (cdr (assoc 2 elist)) Tag)
(progn
(setq enAtt (cdr (assoc -1 elist))
    objAtt (vlax-ename->vla-object enAtt)
)
(vla-put-MTextBoundaryWidth objAtt 60.0)
(vla-UpdateMTextAttribute objAtt)
) ;progn
) ;if Tag
) ;while
)

Try setting the (vla-put-MtextBoundaryWidth) value to 0.0; this should eliminate wrapping of the text I think.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

kerrcad

  • Mosquito
  • Posts: 3
Re: vla-UpdateMTextAttribute Does not "un-wrap" Attribute text
« Reply #2 on: October 13, 2022, 04:58:10 PM »
Setting the (vla-put-MtextBoundaryWidth) value to 0.0 does work, after I rebuilt the block from scratch.

My concern is that I cannot recreate the problem that this resolves.  The block that caused the original error must have been corrupted somehow in it's creation.  And of course, AutoCAD crashed shortly after my original submission so I cannot examine the "corrupted" block.

-OR-  (and more likely)

I did something idiotic over and over again that sent me in search of a solution to a problem that did not exist. 

Sometimes finding that stupid thing I did, but cannot recognize, is the very hardest part of coding.  And with everything working, and not knowing the REAL problem, it's bound to come around and vex me again!

Regardless, Thanks PKENEWELL!

mhupp

  • Bull Frog
  • Posts: 250
Re: vla-UpdateMTextAttribute Does not "un-wrap" Attribute text
« Reply #3 on: October 13, 2022, 08:01:07 PM »
it is updating you prob just need to regen to update the "visual" block

add this to your code
Code - Auto/Visual Lisp: [Select]

kerrcad

  • Mosquito
  • Posts: 3
Re: vla-UpdateMTextAttribute Does not "un-wrap" Attribute text
« Reply #4 on: October 14, 2022, 10:41:30 AM »
I have placed this line in my code, commented with a note should the problem reoccur.

Thanks, mhupp