Author Topic: Text doesnt rotate with rest of block  (Read 164 times)

0 Members and 1 Guest are viewing this topic.

strebor71

  • Mosquito
  • Posts: 12
Text doesnt rotate with rest of block
« on: October 03, 2016, 08:11:52 am »
Hi, all

I have a lisp that rotates a north arrow to whatever the twist rotation is at in a viewport. It has been working for years. I have started at a new company and the north arrow block has some dynamic text in it. The routine still works, but 2 things happen. 1 the objects in the block rotate, however, they get shifted about 16 inches off to the left and 2 the text in the block doesn't rotate, but stays in position. the routine uses entsel, and entmod to get this done. any suggestions?

(defun c:rn()
(setq tw(entget(car(entsel"\nSelect a Viewport:"))))
(setq new (cdr (assoc 0 tw)))
(cond
((= new "VIEWPORT")(setq rt(cdr(assoc 51 tw))))
((= new "LWPOLYLINE")(setq temp (entget(cdr (assoc 330 tw))))(setq rt(cdr(assoc 51 temp))))
)
(setq en(car(entsel"\nSelect North Arrow: ")))
(setq elist(entget en))
(setq elist(subst (cons 50 rt)(assoc 50 elist) elist))
(entmod elist)
(princ)
)

quick updtae, figured out why it gets shifted, the base point of the block was not at the center of the arrow, but the text still wont rotate with the block.
« Last Edit: October 03, 2016, 08:45:03 am by strebor71 »

Lee Mac

  • Seagull
  • Posts: 11462
  • AutoCAD 2015 Windows 7 London, England
Re: Text doesnt rotate with rest of block
« Reply #1 on: October 03, 2016, 08:19:02 am »
Here is an alternative, using the ActiveX rotation property:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:rn ( / blk sel )
  2.    (and (princ "\nSelect viewport: ")
  3.         (setq sel (ssget "_+.:E:S" '((0 . "VIEWPORT"))))
  4.         (setq blk (car (entsel "\nSelect north arrow: ")))
  5.         (= "INSERT" (cdr (assoc 0 (entget blk))))
  6.         (vla-put-rotation (vlax-ename->vla-object blk) (cdr (assoc 51 (entget (ssname sel 0)))))
  7.    )
  8.    (princ)
  9. )

Daniel J. Ellis

  • Swamp Rat
  • Posts: 770
Re: Text doesnt rotate with rest of block
« Reply #2 on: October 03, 2016, 08:22:56 am »
When blocks move in unexpected ways it's usually because the insertion point is not where it "should" be, which means the north point is rotating around its insertion point - presumable 16" away - rather than around its centre.

There's a feature of annotative text that allows it to always be vertical compared to the page, obviously that would give the appearance of any rotation applied to it not working.  It might be worth checking that that isn't the case here (I think it can be set by text-style).


dJE
===
dJE

strebor71

  • Mosquito
  • Posts: 12
Re: Text doesnt rotate with rest of block
« Reply #3 on: October 03, 2016, 09:06:27 am »
Awesome Lee, thank you.  Now if I wanted to have the text automatically flip 180 so that it read correct, what would that intail?