TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pedroantonio on April 05, 2019, 11:07:13 AM

Title: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on April 05, 2019, 11:07:13 AM
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
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: kdub 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.




Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio 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
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: kdub on April 06, 2019, 09:09:31 PM
Are you sure you want to rotate ALL the AnnotPoint ( the Grid Markers ) ??
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on April 07, 2019, 06:13:15 AM
only AnnotPoint and Annotstation
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: kdub 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.

Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on April 08, 2019, 05:16:34 AM
ALL Annotstation and the AnnotPoint on the same insertionPoint
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on April 10, 2019, 10:50:19 AM
any ideas ?
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: danglar on May 22, 2019, 07:52:42 AM
..probably this approach can be helpful:

https://lispbox.wordpress.com/2019/05/22/create-viewport-in-paper-space-from-specified-2d-orthogonal-view-in-model-space-and-rotate-created-view-parallel-to-rotated-ms-object-with-selecting-rotation-angle-by-2-points-on-object-within-viewpo/
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on May 22, 2019, 10:59:49 AM
i try it but is not workng
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pbelon 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)
)
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: pedroantonio on June 27, 2019, 11:41:44 AM
Thanks  pbelon. This is working
Title: Re: Rotate Multiple Objects TO CURRENT VIEWPORT REDABLE ORIENTATION
Post by: tombu 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.