Hi Guys,
here is the situation i am in...
have a layout with 2 viewports the first viewport is in WCS and the second is rotate about Z axis at 45 degrees.
i am trying to get the UCS direction of each viewport and it return wrong values and i found
that autocad actaully returns the values of the last current viewport. meaning if i manually
enters the WCS viewport with MSPACE than back to PSPACE than activate my program
on the WCS viewport works fine but if i select the rotated viewport it returns the ucsxdir, ucsydir of the WCS viewport. it seems that MSPACE command (or double click) does more than:-
(vla-put-MSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)) :vlax-true)
(setvar 'cvport (cdr (assoc '69 elist)))
would like to know what else i should do in order to make this work?
(setq elist (entget (car (entsel)))) ; switch to model space (vla-put-MSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)) :vlax-true) ; set current viewport (setvar 'cvport (cdr (assoc '69 elist))) (princ (getvar 'ucsxdir)) (princ (getvar 'ucsydir))
can not call MSPACE command cause my program is coming from callback function (reactor)
also (cdr (assoc '16 elist)) does not reflect the right value.
thanks in advance
Moshe
Solved! Go to Solution.
Solved by Moshe-A. Go to Solution.
Moshe, when I try to replicate the situation I get the correct ucsxdir and ucsydir, but as you say
"my program is coming from callback function (reactor)"
perhaps the behavior is different from what I get. Maybe the "twistangle" may be sufficient for what you try to achieve, with something like
(vla-get-twistangle (vlax-ename->vla-object (car (entsel "\nPick a Viewport"))))
Henrique
Henrique,
yes it's true when you run this manually it works but i do not use (entsel) to get the viewport
i select it with (ssget "I") which get's fired by reactor due to a change in the annotation scale
tell what i think is going as i watch my program running it look like autocad does not fully
switch to model space as i call :-
(vla-put-MSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)) :vlax-true)
(setvar "cvport" (cdr (assoc '69 elist)))
cause i do not see (maybe it is to fast) the viewport thickening. maybe autocad saving
memory and waits until my command will finish but after reading the ucsxdir & ucsydir
i'm going back to pspace so actually the ucsxdir that i'm getting is from the layout .
on the other hand i did tried to draw something on mspace after setting the mspace
and i did successed on this so i do not really know what is going on.
what's twistangle it returns unknown property, what does it do?
_$ (vla-get-twistangle (vlax-ename->vla-object (car (entsel "\nPick a Viewport"))))
; error: ActiveX Server returned the error: unknown name: TwistAngle
Moshe
Moshe,
try
(vl-load-com)
and then the
(vla-get-twistangle (vlax-ename->vla-object (car (entsel "\nPick a Viewport"))))
returns trhe ucs rotation angle
Henrique
Henrique,
first, thank you very much for your help
$ (setq a (vla-get-twistangle (vlax-ename->vla-object (car (entsel)))))
5.49779
(the other time it did not work is because i select a polygonal viewport and it
actually were selecting the lwpolyline)
it's 315 degrees (the mirrored angle)
i am expecting to get 0.785398 (which is 45 degress)
Are you suggesting i should subtract 270 degrees to have what i want?
Moshe
Moshe,
you are getting the angle in radians, and clockwise, with 0 on the right, try
(setq ang (vla-get-twistangle (vlax-ename->vla-object (car (entsel "\nPick Viewport")))))
(- (* 2 pi) ang)
Henrique