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

Setting Target/Direction on Pviewport

1 REPLY 1
Reply
Message 1 of 2
dario_bellinazzi
535 Views, 1 Reply

Setting Target/Direction on Pviewport

Hello,

i'm not getting the expected result with following test code regarding Viewport's Target/Direction:

(defun C:PVPTEST ( / acadObj docObj pSpaceObj ps_centerPt vp_targetPt vp_cameraPt vpObj)
  (setq acadObj     (vlax-get-acad-object))
  (setq docObj      (vla-get-ActiveDocument acadObj))
  (setq pSpaceObj   (vla-get-paperspace docObj))
  (setq ps_centerPt (vlax-3d-point (trans (getvar "VIEWCTR") 0 1)))
  (setq vp_targetPt (vlax-3d-point '(0.0 0.0 0.0)))
  (setq vp_cameraPt (vlax-3d-Point '(0.0 0.0 500.0)))
  (setq vpObj       (vla-AddPViewport pSpaceObj ps_centerPt 5.0 5.0))
  (vla-Display vpObj :vlax-true)
  (vla-put-CustomScale vpObj 0.02)
  (vla-put-Target vpObj vp_targetPt)
  (vla-put-Direction vpObj vp_cameraPt)
)

Resulting viewport should be targeting WCS origin, but I get this instead (Crosshair is on mspace WCS origin):

pierini_0-1623052442464.png

Same code works fine on other CADs, is there something I'm missing?

Attached you can find test drawing/function.

 

Thank you for your help.

Labels (4)
1 REPLY 1
Message 2 of 2

This mod. worked for me...

But I guess you are right, I think this is a bug if original code worked in other CAD platforms...

(defun C:PVPTEST ( / acadObj docObj pSpaceObj ps_centerPt vp_targetPt vp_directionPt vpObj )
  (vl-load-com)
  (setq acadObj     (vlax-get-acad-object))
  (setq docObj      (vla-get-ActiveDocument acadObj))
  (setq pSpaceObj   (vla-get-paperspace docObj))
  (setq ps_centerPt (vlax-3d-point (getvar "VIEWCTR")))
  (setq vp_targetPt (vlax-3d-point (mapcar '- (trans '(0.0 0.0 0.0) 0 2) (getvar "VIEWCTR"))))
  (setq vp_directionPt (vlax-3d-Point '(0.0 0.0 500.0)))
  (setq vpObj       (vla-AddPViewport pSpaceObj ps_centerPt 5.0 5.0))
  (vla-Display vpObj :vlax-true)
  (vla-put-CustomScale vpObj 0.02)
  (vla-put-Target vpObj vp_targetPt)
  (vla-put-Direction vpObj vp_directionPt)
  (princ)
)

 

 

Marko Ribar, d.i.a. (graduated engineer of architecture)

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report