Jump to content

Programmatically create viewport with orientation.


Recommended Posts

Posted

I'm working on a lisp routine that requires creating a viewport in paperspace with an orientation. If I was doing it manually I would normally create the viewport and then from inside the viewport I would set "ucsfollow" to 1 and then change ucs, this will snap the viewport to the correct orrientation. See the snapshot if you find my explanation confusing :)

 

Model space showing outline of viewport:

Model space.JPG

 

Paper space showing actual viewport:

Paperspace.JPG

 

I've been spending ages trying to work out how to create a view port with an orientation using lisp but got somewhat stuck. There seem to be a few options using vl/vlax but these only seem to specify the height, width, centre etc. and not the actually orientation. I would like to do most of the programming myself as a learning experience but any pointers in the right direction would be much appreciated.

Posted

Here is a quick example to get you started:

 

(defun c:test ( / sel )
   (if (setq sel (ssget "_+.:E:S:L" '((0 . "VIEWPORT"))))
       (vla-put-twistangle
           (vlax-ename->vla-object (ssname sel 0))
           (/ pi 3.0) ;; Angle in radians
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted

Thanks Lee,

 

Previously I had been looking through the dxf codes trying to work out which one to use. Somehow 51 had managed to escape my attention :facepalm:

I'm going to try coding this a few ways using both your method and entmod and see how I go

Posted
I'm going to try coding this a few ways using both your method and entmod and see how I go

 

FYI, you cannot entmod a viewport ;)

Posted

Do you know you can just rotate the viewport from paperspace to get the results you are looking for? No need for lisp unless you just want to.

Posted
Ha ha thanks Lee, that explains why I was having trouble :facepalm:

I was trying to avoid to using vlax/vla coding :) as I seem to have trouble understanding how to use it. However this thread seems to be very helpful http://www.cadtutor.net/forum/showthread.php?81195

 

You're welcome - I'm glad that my tutorial post on ActiveX is clear! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...