Author Topic: Rotate UCS into viewport  (Read 4739 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Rotate UCS into viewport
« on: August 27, 2015, 02:38:07 AM »
How can I set the UCS Global viewport, without going into it?

Do you have any suggestions?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Rotate UCS into viewport
« Reply #1 on: August 27, 2015, 10:45:33 AM »
Changing a viewport through (entmod) is problematic. For example changing 'VP Freeze' layers (Xdata) is not possible with (entmod). In the past I have reported this as a BricsCAD bug to the Bricsys team but was told that AutoCAD has the same issue and therefore this behavior was compatible...

To change the 'VP Freeze' layers a Visual Lisp approach will work. But, to my knowledge,  there are no VL properties or methods for the viewport UCS.

The code below does NOT work on BricsCAD.
Code - Auto/Visual Lisp: [Select]
  1. (defun VP_To_WCS (enme / elst)
  2.   (setq elst (entget enme))
  3.   (entmod
  4.     (subst
  5.       '(110 0.0 0.0 0.0) ; UCS origin.
  6.       (assoc 110 elst)
  7.       (subst
  8.         '(111 1.0 0.0 0.0) ; UCS X-axis.
  9.         (assoc 111 elst)
  10.         (subst
  11.           '(112 0.0 1.0 0.0) ; UCS Y-axis.
  12.           (assoc 112 elst)
  13.           elst
  14.         )
  15.       )
  16.     )
  17.   )
  18. )

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Rotate UCS into viewport
« Reply #2 on: August 27, 2015, 10:52:18 AM »
Changing a viewport through (entmod) is problematic.

From the AutoCAD Developer Docs on entmod:
Quote
There are restrictions on the changes the entmod function can make:
  • An entity's type and handle cannot be changed. If you want to do this, use entdel to delete the entity, and then make a new entity with the command or entmake function.
  • The entmod function cannot change internal fields, such as the entity name in the -2 group of a seqend entity. Attempts to change such fields are ignored.
  • You cannot use the entmod function to modify a viewport entity.
« Last Edit: August 27, 2015, 01:30:01 PM by Lee Mac »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Rotate UCS into viewport
« Reply #3 on: August 27, 2015, 01:19:07 PM »
Thank you Lee. Strange restriction though.

pedroantonio

  • Guest
Re: Rotate UCS into viewport
« Reply #4 on: August 27, 2015, 01:36:36 PM »
I use this lisp code is perfect !!

Code - Auto/Visual Lisp: [Select]
  1.  
  2. ; DVA.LSP
  3.  
  4. ; Jim Nakazawa
  5. ; (415) 768-1234
  6.  
  7. ; TO SET DVIEW TWIST ANGLE BY POINTING TO AN EXISTING LINE
  8. ; FIRST DRAW THE LINE FROM LEFT TO RIGHT THAT YOU WANT TO SET THE DVIEW
  9. ; TWIST ANGLE FROM
  10.  
  11. (defun C:DVA (/ rgm a b pt1 pt2 ang1 )
  12.   (setq rgm (getvar "regenmode"))
  13.   (command "setvar" "regenmode" 0)
  14.   (setq a (entsel "Select a line to set the orientation DVIEW TWist: "))
  15.   (setq b (entget (car a)))
  16.   (setq pt1 (cdr (assoc 10 b)))
  17.   (setq pt2 (cdr (assoc 11 b)))
  18.   (setq ang1 (angle pt1 pt2))
  19.   (setq ang1 (/ (* ang1 200.0) pi))
  20.   (setq ang1 (- ang1))
  21.   (command "dview"  "" "tw" ang1 "")
  22.   (command "setvar" "regenmode" rgm)
  23.   (princ "Dview Twist Angle Set to ") (princ (+ 400.0 ang1)) (terpri)
  24. ;this should be modified to show angle in current angular units
  25.   (princ)
  26. ) ;this routine seems to work
  27.  
  28.  

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Rotate UCS into viewport
« Reply #5 on: August 28, 2015, 03:04:55 AM »
I use this lisp code is perfect !!
This code changes the twist angle not the viewport UCS. Changing the twist angle can be done with Visual Lisp (without activating the viewport).
« Last Edit: August 28, 2015, 03:11:39 AM by roy_043 »

pedroantonio

  • Guest
Re: Rotate UCS into viewport
« Reply #6 on: August 28, 2015, 04:39:58 AM »
This code changes the twist angle not the viewport UCS. Changing the twist angle can be done with Visual Lisp (without activating the viewport).

Yes roy_043 but this lisp  twist angle  only in the viewport not in the modelspace and this is important. 

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Rotate UCS into viewport
« Reply #7 on: August 28, 2015, 06:35:30 AM »
@ Topographer: No doubt the code in your post can be useful, but it is not what the OP needs.

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Rotate UCS into viewport
« Reply #8 on: August 28, 2015, 10:45:22 AM »
I use this lisp code is perfect !!

Code - Auto/Visual Lisp: [Select]
  1.  
  2. ; DVA.LSP
  3.  
  4. ; Jim Nakazawa
  5. ; (415) 768-1234
  6.  
  7. ; TO SET DVIEW TWIST ANGLE BY POINTING TO AN EXISTING LINE
  8. ; FIRST DRAW THE LINE FROM LEFT TO RIGHT THAT YOU WANT TO SET THE DVIEW
  9. ; TWIST ANGLE FROM
  10.  
  11. (defun C:DVA (/ rgm a b pt1 pt2 ang1 )
  12.   (setq rgm (getvar "regenmode"))
  13.   (command "setvar" "regenmode" 0)
  14.   (setq a (entsel "Select a line to set the orientation DVIEW TWist: "))
  15.   (setq b (entget (car a)))
  16.   (setq pt1 (cdr (assoc 10 b)))
  17.   (setq pt2 (cdr (assoc 11 b)))
  18.   (setq ang1 (angle pt1 pt2))
  19.   (setq ang1 (/ (* ang1 200.0) pi))
  20.   (setq ang1 (- ang1))
  21.   (command "dview"  "" "tw" ang1 "")
  22.   (command "setvar" "regenmode" rgm)
  23.   (setvar "snapang" (- (getvar "viewtwist")))
  24.   (princ "Dview Twist Angle Set to ") (princ (+ 400.0 ang1)) (terpri)
  25. ;this should be modified to show angle in current angular units
  26.   (princ)
  27. ) ;this routine seems to work
  28.  
  29.  
As a licensed Surveyor doing Civil work like Topographer I avoid changing the coordinate system.  I use a macro to twist views as needed that resets the crosshairs after DVIEW with
Code: [Select]
(setvar "snapang" (- (getvar "viewtwist"))).  Added it to your routine for my purposes.
Not exactly what Lupo76 asked for, but your solution could work for him.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Rotate UCS into viewport
« Reply #9 on: August 28, 2015, 05:09:50 PM »
Reading this topic will help to understand what the OP wants:
http://www.theswamp.org/index.php?topic=29231.0

Lupo76

  • Bull Frog
  • Posts: 343
Re: Rotate UCS into viewport
« Reply #10 on: August 29, 2015, 02:47:51 AM »
Thank you all!
I managed to solve my problem without rotating the UCS in the viewport, but thank you all for your concern

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Rotate UCS into viewport
« Reply #11 on: August 29, 2015, 03:49:27 AM »
Thank you all!
I managed to solve my problem without rotating the UCS in the viewport, but thank you all for your concern


That's great!
How did you do it ??

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Rotate UCS into viewport
« Reply #12 on: August 29, 2015, 11:44:19 AM »
That's great!
How did you do it ??

I just adopted a totally different system to do what I had to do.
Any explanation would be too long, and however OT

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Rotate UCS into viewport
« Reply #13 on: August 29, 2015, 01:25:18 PM »



That is really disappointing.


You come here and ask for help, ask for people to take time and effort to resolve a problem you have.
Then you excuse yourself for your lack of effort to explain how the issue was resolved, completely denying future readers of this thread the benefit of a solution you crafted.


 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.