Author Topic: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION  (Read 954 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Hi. I am using  layouts  in my drawings and a have a little  problem . When i  change the dview in my viewport then my blocks is not in redable orientation in the model space and in the paper space. I am looking for a lisp  to do this

1) first select the viewport and understand the orientation angle
2) rotate specific blocks (for example in the test drawing i have AnnotPoint and Annotstation)

thanks

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1365
  • class keyThumper<T>:ILazy<T>
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #1 on: April 05, 2019, 06:49:48 PM »
Correct me if I'm wrong.

You know the DVIEW TWIST angle.
or can read it : and copy the angle to clipboard

Without programming.

In Modelspace:
SELECT the text inserts and Grid Markers you want to rotate.
In Properties Palette change ALL rotations at once by pasting the rotation angle
View the Paperspace Viewport.

This takes a couple of minutes, and all the time is in the selection.
I have assumed you DON'T want all the grid markers rotated, only the ones with text.
.. otherwise use SELECTALL .. easier

This is faster than you can write multiple posts asking for someone to spend more ( of their ) time writing code for you.




« Last Edit: April 05, 2019, 06:57:22 PM by kdub »
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #2 on: April 06, 2019, 06:36:24 PM »
I find this code.Works perfect for text but is not working for blocks. Can any oneupdate this code to identify the blocks with names AnnotPoint and Annotstation

Code - Auto/Visual Lisp: [Select]
  1. (defun c:TextHoriz (/ ss1 num cnt viewtwist etype obj dimr)
  2.   (setq ss1 (ssget '((0 . "mtext,text,dimension")))
  3.         num (sslength ss1)
  4.         cnt 0
  5.         viewtwist (getvar "viewtwist")
  6.   )
  7.   (if(/= viewtwist 0.0)
  8.         (repeat num
  9.           (setq ent (ssname ss1 cnt)etype (cdr(assoc 0 (entget ent))))
  10.           (setq obj (vlax-ename->vla-object ent))
  11.           (if(= etype "DIMENSION")
  12.                 (progn
  13.                   (setq dimr (- (vla-get-Rotation obj)viewtwist))
  14.                   (vla-put-TextRotation obj dimr)
  15.                 )
  16.                 (vla-put-Rotation obj (- viewtwist))
  17.           )
  18.           (setq cnt (1+ cnt))
  19.         ) ; repeat
  20.         (princ "\nNo TWist in Viewport.")
  21.   ) ; if
  22.   (princ)
  23. )
  24.  


Thanks

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1365
  • class keyThumper<T>:ILazy<T>
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #3 on: April 06, 2019, 09:09:31 PM »
Are you sure you want to rotate ALL the AnnotPoint ( the Grid Markers ) ??
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #4 on: April 07, 2019, 06:13:15 AM »
only AnnotPoint and Annotstation

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1365
  • class keyThumper<T>:ILazy<T>
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #5 on: April 08, 2019, 01:39:35 AM »

'll keep at this untill I understand ...

Quote
only AnnotPoint and Annotstation

Do you mean ALL AnnotPoint and Annotstation ??

or

ALL Annotstation and the AnnotPoint on the same insertionPoint ??
.... the same way I did it manually.


Just a note:
Your blocks are actually called
Block Name: "grtick" and
Block Name: "ARI_KAN"

but that's just another detail.

called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #6 on: April 08, 2019, 05:16:34 AM »
ALL Annotstation and the AnnotPoint on the same insertionPoint

pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #7 on: April 10, 2019, 10:50:19 AM »
any ideas ?


pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #9 on: May 22, 2019, 10:59:49 AM »
i try it but is not workng

pbelon

  • Mosquito
  • Posts: 5
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #10 on: June 27, 2019, 04:55:17 AM »
Try this...

http://www.cadtutor.net/forum/archive/index.php/t-54913.html?s=91bcb52a5e390c45ed23402bb92164a8

Code: [Select]

;; ROTATE BLOCK TO VIEW

(defun c:RTB2V ( / ss ang ) (vl-load-com)

(if (and (setq ss (ssget "_:L" '((0 . "INSERT"))))
 (setq ang (- 0 (getvar "viewtwist")))
)
(
(lambda ( i / e o )
(while (setq e (ssname ss (setq i (1+ i))))
(vla-put-rotation (setq o (vlax-ename->vla-object e)) ang)
)
)
-1
)
)

(princ)
)

pedroantonio

  • Guest
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #11 on: June 27, 2019, 11:41:44 AM »
Thanks  pbelon. This is working

tombu

  • Newt
  • Posts: 158
  • ByLayer=>Not0
Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
« Reply #12 on: June 27, 2019, 12:31:45 PM »
I find this code.Works perfect for text but is not working for blocks. Can anyone update this code to identify the blocks with names AnnotPoint and Annotstation
Code - Auto/Visual Lisp: [Select]
  1. ;| https://forums.augi.com/showthread.php?171018-rotate-text-to-horizontal-in-viewport&p=1332928&viewfull=1#post1332928
  2. http://www.theswamp.org/index.php?topic=55060.msg595136#msg595136
  3. Set blocks grtick & ARI_KAN angle Horizontal by Tom Beauford
  4.  (load "TextHorizTic.lsp") TextHorizTic
  5.    Macro: ^P(or C:TextHorizTic (load "TextHorizTic.lsp"));TextHorizTic
  6.    Command line: (load "TextHorizTic.lsp") TextHorizTic |;
  7. (defun c:TextHorizTic (/ ss1 num cnt viewtwist etype obj dimr)
  8.   (setq ss1 (ssget '((0 . "insert")(2 . "grtick,ARI_KAN")))
  9.         num (sslength ss1)
  10.         cnt 0
  11.         viewtwist (getvar "viewtwist")
  12.   )
  13.   (if(/= viewtwist 0.0)
  14.         (repeat num
  15.           (setq ent (ssname ss1 cnt)etype (cdr(assoc 0 (entget ent))))
  16.           (setq obj (vlax-ename->vla-object ent))
  17.           (vla-put-Rotation obj (- viewtwist))
  18.           (setq cnt (1+ cnt))
  19.         ) ; repeat
  20.         (princ "\nNo TWist in Viewport.")
  21.   ) ; if
  22.   (princ)
  23. )
  24.  
  25.  
This should set only blocks grtick & ARI_KAN angle to Horizontal.
First link in the code is for the original code, I modified it to work for block inserts as it sounded useful.  Second link is for this post.
« Last Edit: June 27, 2019, 12:36:46 PM by tombu »
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D