Author Topic: viewdir vs Direction property  (Read 2983 times)

0 Members and 2 Guests are viewing this topic.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
viewdir vs Direction property
« on: June 30, 2007, 05:35:38 AM »
Is this a bug or am I doing something wrong ?

The two following expressions should return the same result, but when changing the view (using 3dorbit or a predefined view), it looks like the direction property doesn't update.

 
Code: [Select]
(mapcar '-
(trans (getvar "viewdir") 1 0)
(trans '(0 0 0) 1 0)
)


 
Code: [Select]
(vlax-get (vla-get-ActiveViewport
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  )
  'Direction
)
« Last Edit: June 30, 2007, 05:53:52 AM by gile »
Speaking English as a French Frog

LE

  • Guest
Re: viewdir vs Direction property
« Reply #1 on: June 30, 2007, 11:20:50 AM »
No idea if it is a bug or not, and you are right the call with vlisp function, won't provide the current viewdir as it does with the viewdir sysvar.

You can do a save and call your vlisp code and will see that it will return the same value or

Code: [Select]
(defun array-vbDouble  (vla-lst)
  (vlax-safeArray-fill
    (vlax-make-safeArray
      vlax-vbDouble
      (cons 0 (1- (length vla-lst))))
    vla-lst))

(vla-put-direction (vla-get-ActiveViewport
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  ) (array-vbDouble (getvar "viewdir")))

Using the above will give you the same results next time you use:

Code: [Select]
(vlax-get (vla-get-ActiveViewport
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  )
  'Direction
)


HTH

Bryco

  • Water Moccasin
  • Posts: 1883
Re: viewdir vs Direction property
« Reply #2 on: June 30, 2007, 12:39:43 PM »
I found in vba I could also delete the ActiveViewport
then get an updated viewpot, although it sounds wierd it is quicker than forcing a save on a large drawing.
Perhaps it will work in vla to.
ThisDrawing.ActiveViewport.Delete
Set vp = ThisDrawing.ActiveViewport

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: viewdir vs Direction property
« Reply #3 on: June 30, 2007, 02:30:13 PM »
Thanks for your replies.

The way given by Bryco seems to work fine. Doing :

Code: [Select]
(setq doc (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  )
  (vla-delete (vla-get-ActiveViewport doc))
  (vlax-get (vla-get-ActiveViewport doc) 'Direction)

returns the right result.

However, I think it's quite obvious to have to delete the active viewport to update its Direction.
Speaking English as a French Frog

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: viewdir vs Direction property
« Reply #4 on: July 01, 2007, 04:43:39 AM »
In addition, look my work with "viewdir" using entmod...

http://www.theswamp.org/index.php?topic=12382.msg153796#msg153796

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: viewdir vs Direction property
« Reply #5 on: August 18, 2007, 01:58:14 PM »
I found a more simple and faster way to get the 'viewdir' vector in WCS, using the trans function :

Code: [Select]
(trans '(0 0 1) 2 0 T)
Speaking English as a French Frog