Visual LISP, AutoLISP and General Customization

Reply
Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 1 of 8 (334 Views)
Accepted Solution

viewports, ucsxdir, ucsydir

334 Views, 7 Replies
03-23-2013 04:10 AM

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 

 

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 2 of 8 (293 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 11:24 AM 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

Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 3 of 8 (289 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 12:05 PM 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

 

 

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 4 of 8 (286 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 12:13 PM 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

Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 5 of 8 (276 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 01:37 PM 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

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 6 of 8 (271 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 01:57 PM 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

Distinguished Mentor
Moshe-A
Posts: 735
Registered: ‎09-14-2003
Message 7 of 8 (266 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 02:44 PM in reply to: hmsilva

Henrique,

 

i will try that later on

 

thank you very much

Moshe

 

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 8 of 8 (263 Views)

Re: viewports, ucsxdir, ucsydir

03-23-2013 02:46 PM in reply to: Moshe-A

You're welcome, Moshe

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community