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

viewports, ucsxdir, ucsydir

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Moshe-A
922 Views, 7 Replies

viewports, ucsxdir, ucsydir

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 

 

7 REPLIES 7
Message 2 of 8
hmsilva
in reply to: Moshe-A

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

EESignature

Message 3 of 8
Moshe-A
in reply to: hmsilva

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

 

 

Message 4 of 8
hmsilva
in reply to: Moshe-A

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

EESignature

Message 5 of 8
Moshe-A
in reply to: hmsilva

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

Message 6 of 8
hmsilva
in reply to: Moshe-A

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

EESignature

Message 7 of 8
Moshe-A
in reply to: hmsilva

Henrique,

 

i will try that later on

 

thank you very much

Moshe

 

Message 8 of 8
hmsilva
in reply to: Moshe-A

You're welcome, Moshe

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost