Community
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):
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.
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) )
Can't find what you're looking for? Ask the community or share your knowledge.