Author Topic: vla-AddMText . Problem with rotation  (Read 4091 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 637
vla-AddMText . Problem with rotation
« on: February 22, 2013, 03:19:10 AM »
hello

is there any way to fix this function so mtext can be placed at any ucs ?
similar code for vla-AddText works very well

vla-AddMText . Problem with rotation;
Code: [Select]
=========================================================================================== ;
; Tworzy obiekt typu MTEXT / Creates a MTEXT object                                           ;
;  Space  [VLA-Object] - kolekcja / collection | Model/Paper + Block Object                   ;
;  Str    [STR]  - lancuch tekstowy / string                                                  ;
;  Pb     [LIST] - punkt bazowy / base point                                                  ;
;  Width  [REAL] - szerokosc tekstu / width text                                              ;
;  Rot    [REAL] - kat obrotu w radianach / rotation angle in radians                         ;
; ------------------------------------------------------------------------------------------- ;
; (kr:ACX_AddMText (cd:ACX_ASpace) "NEW_MTEXT" (getpoint) 1.5 (/ pi 4))                       ;
; =========================================================================================== ;
(defun kr:ACX_AddMText (Space Str Pb Width Rot / zdir xang obj)
  (setq zdir (trans '(0 0 1) 1 0 T)
        xang (angle '(0 0 0) (trans (getvar "UCSXDIR") 0 zdir))
  )
  (vla-put-rotation
    (setq obj
      (vla-AddMText (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
      (vlax-3d-point (trans Pb 1 0))
        Width
        Str     
      )
    )
    (+ Rot xang)
  )
  obj
)

thanks
kruuger

fixo

  • Guest
Re: vla-AddMText . Problem with rotation
« Reply #1 on: February 22, 2013, 04:21:53 AM »
Try this
Code: [Select]
(defun kr:ACX_AddMText (Space Str Pb Width Rot / zdir xang obj)
  (setq zdir (trans '(0 0 1) 1 0 T)
        xang (angle '(0 0 0) (trans (getvar "UCSXDIR") 0 zdir))
  )
  (vla-put-rotation
    (setq obj
      (vla-AddMText Space
      (vlax-3d-point (trans Pb 1 0))
        Width
        Str     
      )
    )
    (+ (vla-get-rotation obj) Rot xang)
  )
  obj
)

(kr:ACX_AddMText
  (vla-get-modelspace
    (vla-get-activedocument
      (vlax-get-acad-object))) "NEW_MTEXT" (getpoint) 1.5 (/ pi 4))

kruuger

  • Swamp Rat
  • Posts: 637
Re: vla-AddMText . Problem with rotation
« Reply #2 on: February 22, 2013, 04:40:52 AM »
Try this
Code: [Select]
(defun kr:ACX_AddMText (Space Str Pb Width Rot / zdir xang obj)
  (setq zdir (trans '(0 0 1) 1 0 T)
        xang (angle '(0 0 0) (trans (getvar "UCSXDIR") 0 zdir))
  )
  (vla-put-rotation
    (setq obj
      (vla-AddMText Space
      (vlax-3d-point (trans Pb 1 0))
        Width
        Str     
      )
    )
    (+ (vla-get-rotation obj) Rot xang)
  )
  obj
)

(kr:ACX_AddMText
  (vla-get-modelspace
    (vla-get-activedocument
      (vlax-get-acad-object))) "NEW_MTEXT" (getpoint) 1.5 (/ pi 4))

thanks fixo but still wrong. mtext should be always rotated 45deg at any ucs when inserted.
k.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: vla-AddMText . Problem with rotation
« Reply #3 on: February 22, 2013, 05:29:35 AM »
mtext should be always rotated 45deg at any ucs when inserted.
I don't understand the problem. Your code seems to do just that: the rotation is 45 degrees relative to the current UCS.

kruuger

  • Swamp Rat
  • Posts: 637
Re: vla-AddMText . Problem with rotation
« Reply #4 on: February 22, 2013, 05:44:59 AM »
mtext should be always rotated 45deg at any ucs when inserted.
I don't understand the problem. Your code seems to do just that: the rotation is 45 degrees relative to the current UCS.
set the world ucs then
Code: [Select]
(command "_ucs" "_z" 90)
(command "_plan" "_c")
try again my routine. mtext is not rotated correctly.
k.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: vla-AddMText . Problem with rotation
« Reply #5 on: February 22, 2013, 06:05:03 AM »
Maybe:
Code: [Select]
(defun _addmtext ( spc str ins wid rot / obj )
    (setq obj (vla-addmtext spc (vlax-3D-point (trans ins 1 0)) wid str))
    (vla-put-rotation obj rot)
    obj
)

kruuger

  • Swamp Rat
  • Posts: 637
Re: vla-AddMText . Problem with rotation
« Reply #6 on: February 22, 2013, 06:23:02 AM »
Maybe:
Code: [Select]
(defun _addmtext ( spc str ins wid rot / obj )
    (setq obj (vla-addmtext spc (vlax-3D-point (trans ins 1 0)) wid str))
    (vla-put-rotation obj rot)
    obj
)
what. i didn't try this  :-[

i will make more test but it seams to work  :)
so MText doesn't care about "UCSXDIR" ?

thanks Lee
« Last Edit: February 22, 2013, 07:50:46 AM by kruuger »

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: vla-AddMText . Problem with rotation
« Reply #7 on: February 22, 2013, 06:36:30 AM »
Maybe:
Code: [Select]
(defun _addmtext ( spc str ins wid rot / obj )
    (setq obj (vla-addmtext spc (vlax-3D-point (trans ins 1 0)) wid str))
    (vla-put-rotation obj rot)
    obj
)
what. i didn't try this  :-[

i will make more test but it seams to work  :)
so MText doesn't case about "UCSXDIR" ?

thanks Lee

As far as I know, MText rotation is relative to the UCS X-Axis.
You're welcome  :-)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: vla-AddMText . Problem with rotation
« Reply #8 on: February 22, 2013, 07:49:32 AM »
As far as I know, MText rotation is relative to the UCS X-Axis.
BricCAD is not compatible here.