Author Topic: Mtext Alignment  (Read 2140 times)

0 Members and 1 Guest are viewing this topic.

walton10

  • Guest
Mtext Alignment
« on: October 11, 2010, 02:33:15 PM »
on similar subject,  can anyone tell me why I am getting the following error?

Error: ActiveX Server returned the error: unknown name: ALIGNMENT
Error: Resetting User Environment

Code: [Select]
(setq mySS (ssget))
(setq len (sslength mySS))
(setq cnt 0)
(while (> len cnt)
(setq ename (ssname mySS cnt))
(setq elist (entget ename))
(cond
((=  "TEXT" (cdr (assoc 0 elist)))
(setq my72 (cdr (assoc 72 elist)))
(setq my73 (cdr (assoc 73 elist)))
(setq tmp (vla-get-TextAlignmentPoint (vlax-ename->vla-object ename)))
;(setq tmp2 (vlax-safearray->list tmp))
(command "_txt2mtxt" ename "")
(setq ename (entlast))
(setq elist (entget ename))
(entmod (append elist (list '(90 . 3) '(63 . 256) '(45 . 1.25))))
(vlax-put (vlax-ename->vla-object ename) 'width 0)
(cond
((= my73 3) ;top
(cond
((= my72 0) ;left
(setq my71 (cons 71 1)) ;mtext top left
(setq myMTextJustify acAlignmentLeft))
((= my72 1) ;center
(setq my71 (cons 71 2)) ;mtext top center
(setq myMTextJustify acAlignmentCenter))
((= my72 2) ;right
(setq my71 (cons 71 3)) ;mtext top right
(setq myMTextJustify acAlignmentRight))
)
)
((= my73 2) ;middle
(cond
((= my72 0)
(setq my71 (cons 71 4))
(setq myMTextJustify acAlignmentMiddleLeft))
((= my72 1)
(setq my71 (cons 71 5))
(setq myMTextJustify acAlignmentMiddleCenter))
((= my72 2)
(setq my71 (cons 71 6))
(setq myMTextJustify acAlignmentMiddleRight))
)
)
((= my73 1) ;bottom
(cond
((= my72 0)
(setq my71 (cons 71 7))
(setq myMTextJustify acAlignmentBottomLeft))
((= my72 1)
(setq my71 (cons 71 8))
(setq myMTextJustify acAlignmentBottomCenter))
((= my72 2)
(setq my71 (cons 71 9))
(setq myMTextJustify acAlignmentBottomRight))
)
)
);cond my73
(vl-load-com)
(vlax-put (vlax-ename->vla-object ename) 'alignment myMTextJustify)
;(if my71 (entmod (subst my71 (assoc 71 elist) elist)))
)
((= "MTEXT" (cdr (assoc 0 elist)))
(entmod (append elist (list '(90 . 3) '(63 . 256) '(45 . 1.25))))
(vlax-put (vlax-ename->vla-object ename) 'width 0)
)
);cond
(setq cnt (1+ cnt))
)

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Mtext Alignment
« Reply #1 on: October 11, 2010, 02:36:39 PM »
It looks like 'ename' points to MText, which doesn't have an alignment property.

walton10

  • Guest
Mtext Alignment
« Reply #2 on: October 11, 2010, 02:40:50 PM »
Yes, it should point to mText.  what property am I looking for?  I tried manipulating the 72 and 73 dxf codes but was unsuccesful.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Mtext Alignment
« Reply #3 on: October 11, 2010, 02:44:33 PM »
AttachmentPoint, or DXF group 71  :-)

walton10

  • Guest
Mtext Alignment
« Reply #4 on: October 12, 2010, 07:07:35 AM »
I spent a ridiculous amount of time working on these 2 ways of getting the job done, but clearly I'm getting something wrong here....

Code: [Select]
((= my73 2) ;middle
(cond
((= my72 0)
(princ "\n Setting to Middle Left...")
(setq my71 (cons 71 4))
(setq myMTextJustify acAlignmentMiddleLeft)))
Code: [Select]
(vlax-put (vlax-ename->vla-object ename) 'AttachmentPoint myMTextJustify)
Code: [Select]
(if my71 (if (assoc 71 elist) (entmod (subst my71 (assoc 71 elist) elist)) (append elist (list my71))))

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Mtext Alignment
« Reply #5 on: October 12, 2010, 07:32:12 AM »
Walton,
I split the topic into it's own thread so it gets targeted attention.
< was here : Tell me why I did it like this. :)   :- http://www.theswamp.org/index.php?topic=35014.0 >


///----
Just a thought ..
Is your knowledge of ActiveX (VL, VLA, VLAX ) sufficient to forgo the DXF code ??
« Last Edit: October 12, 2010, 07:35:14 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

walton10

  • Guest
Re: Mtext Alignment
« Reply #6 on: October 12, 2010, 08:45:49 AM »
Thank You.  I have only used the activeX commands on a few occasions when I was able to borrow a minimum number of lines from others' examples.  I borrowed the activeX methodology this time because I was having no success using entmod+subst with the 71 DXF, and was unable to figure out what I was doing wrong.  In my last post above, I showed my examples of both methods, I'm hoping someone can point out my error, probably some syntax I keep overlooking.
« Last Edit: October 12, 2010, 09:21:33 AM by walton10 »