Author Topic: How to create rotated VIEW ?  (Read 4861 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 637
How to create rotated VIEW ?
« on: May 01, 2011, 06:00:30 PM »
hello

i'm stuck with creating rotated VIEW (include UCS).
using code below:
Code: [Select]
; ============================================================ ;
; Make VIEW                                                    ;
;   Name    [STR] - view name                                  ;
;   Space   [INT] - standard flags:                            ;
;                   0 = model space view                       ;
;                   1 = paper space view                       ;
;   Width  [REAL] - view width                                 ;
;   Height [REAL] - view height                                ;
;   Center [REAL] - view center point                          ;
;   Twist  [REAL] - view twist angle                           ;
;   Ucs     [STR] - current UCS                                ;
; ------------------------------------------------------------ ;
; (kr:ENT_MakeView "New" 0 10 5 '(0 0 0) 0 "Ucs")              ;
; ============================================================ ;
(defun kr:ENT_MakeView (Name Space Width Height Center Twist Ucs / UCS#)
  (or
    (tblsearch "VIEW" Name)
    (entmakex
      (list
        (cons 0 "VIEW")
        (cons 100 "AcDbSymbolTableRecord")
        (cons 100 "AcDbViewTableRecord")
        (cons 2 Name)
        (cons 70 Space)
        (cons 41 Width)
        (cons 40 Height)
        (cons 10 Center)
        (cons 50 Twist)
        (cons 71 0)
        (cons 281 0)
        (cons 72 1)
        (cons 110
          (vlax-SafeArray->List
            (vlax-Variant-Value
              (vlax-Get-Property
                (setq UCS# (kr:UCS_UcsToVLA Ucs))
                'Origin
              )
            )
          )
        )
        (cons 111
          (vlax-SafeArray->List
            (vlax-Variant-Value
              (vlax-Get-Property UCS# 'XVector)
            )
          )
        )
        (cons 112
          (vlax-SafeArray->List
            (vlax-Variant-Value
              (vlax-Get-Property UCS# 'YVector)
            )
          )
        )
        (cons 79 0)
        (cons 146 0)
        (cons 345 (tblobjname "UCS" Ucs))
      )
    )
  )
)
; ============================================================ ;
; Convert existing ucs to VLA object                           ;
;   Ucs [STR] - ucs name                                       ;
; ------------------------------------------------------------ ;
; (kr:UCS_UcsToVLA "North")                                    ;
; ============================================================ ;
(defun kr:UCS_UcsToVLA (Ucs / UCS#)
  (and
    (tblsearch "UCS" Ucs)
    (setq UCS#
      (vla-Item
        (kr:ACX_GetUcss)
        Ucs
      )
    )
  )
  UCS#
)
; ============================================================ ;
; Get user coordinate systems collection                       ;
; ============================================================ ;
(defun kr:ACX_GetUcss ()
  (or
    *kr-Ucss
    (setq *kr-Ucss (vla-Get-UserCoordinateSystems (kr:ACX_ADoc)))
  )
  *kr-Ucss
)
; ============================================================ ;
; Retrieves pointers to the active document                    ;
; ============================================================ ;
(defun kr:ACX_ADoc ()
  (or
    *kr-ADoc
    (setq *kr-ADoc (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
  )
  *kr-ADoc
)
problem is that VIEW rotates (Twist) around '(0 0 0) point not my Center point. so view is create in wrong place.
i was thinking that maybe it is possible to make view in '(0 0 0) and then move (update) it to my Center point.

thanks,
regards
kruuger



« Last Edit: May 01, 2011, 06:04:04 PM by kruuger »

BlackBox

  • King Gator
  • Posts: 3770
Re: How to create rotated VIEW ?
« Reply #1 on: May 02, 2011, 10:00:33 AM »
Have you tried incorporating the dview command?
"How we think determines what we do, and what we do determines what we get."

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to create rotated VIEW ?
« Reply #2 on: May 02, 2011, 03:15:29 PM »
Have you tried incorporating the dview command?
Hi RenderMan,

I'm trying to make model VIEW's (from block border) and then automatically create viewport with proper scale, description. view's will be linked with viewport.
any change to model: stretch, move, rotate will update my viewport (after adjusting border).
i do some test with entmod, maybe it can be done  :-)

kruuger


BlackBox

  • King Gator
  • Posts: 3770
Re: How to create rotated VIEW ?
« Reply #3 on: May 02, 2011, 04:55:11 PM »
Have you tried incorporating the dview command?
Hi RenderMan,

I'm trying to make model VIEW's (from block border) and then automatically create viewport with proper scale, description. view's will be linked with viewport.
any change to model: stretch, move, rotate will update my viewport (after adjusting border).
i do some test with entmod, maybe it can be done  :-)

Perhaps I misunderstood your earlier request... are you wanting to work with a View object, or a Viewport object?

If the latter, then (to the best of my knowledge) you will have to work with Vla-* code instead of entmod.
"How we think determines what we do, and what we do determines what we get."

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to create rotated VIEW ?
« Reply #4 on: May 02, 2011, 05:55:14 PM »
Have you tried incorporating the dview command?
Hi RenderMan,

I'm trying to make model VIEW's (from block border) and then automatically create viewport with proper scale, description. view's will be linked with viewport.
any change to model: stretch, move, rotate will update my viewport (after adjusting border).
i do some test with entmod, maybe it can be done  :-)

Perhaps I misunderstood your earlier request... are you wanting to work with a View object, or a Viewport object?

If the latter, then (to the best of my knowledge) you will have to work with Vla-* code instead of entmod.
i work with VIEW in model space, create VIEWPORT in paper space and set model view in viewport using (setview).
In this case i need to work with entmod because vla not support some VIEW method.
you can see attached file what i got (works only on border at WCS)

kruuger

BlackBox

  • King Gator
  • Posts: 3770
Re: How to create rotated VIEW ?
« Reply #5 on: May 03, 2011, 09:12:47 AM »
Have you looked into the Target, TwistAngle, and CustomScale Properties of the PViewport Object?
"How we think determines what we do, and what we do determines what we get."

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to create rotated VIEW ?
« Reply #6 on: May 03, 2011, 10:20:56 AM »
Have you looked into the Target, TwistAngle, and CustomScale Properties of the PViewport Object?
with this i can create viewport but there will be no link (hyperlink) to object in model.
with view we can do CTRL+click on viewport and autocad skip to model and zoom to my view.
(setview) also allow us to set desired view without unlocking viewport, changing scale etc.
kruuger


BlackBox

  • King Gator
  • Posts: 3770
Re: How to create rotated VIEW ?
« Reply #7 on: May 03, 2011, 10:22:33 AM »
Sounds neat... can't wait to see the final version.
"How we think determines what we do, and what we do determines what we get."

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to create rotated VIEW ?
« Reply #8 on: May 03, 2011, 02:04:19 PM »
Sounds neat... can't wait to see the final version.
hehe, me to :)
it is done already but only for WCS :(

thanks for interesting
kruuger

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to create rotated VIEW ?
« Reply #9 on: May 04, 2011, 05:45:42 PM »
uff, finally it seams to work  :-) i found a way do calculate center point for my rotated view.
i attached file with 3 (where is center.dwg) view's and some description. maybe someone find it usufull to understand how to get correct center point for view.
so far program creates viewport from selected border in model view. there is also a link between view and viewport (both ways)
kruuger