TheSwamp

CAD Forums => CAD General => Dynamic Blocks => Topic started by: strebor71 on October 03, 2016, 08:11:52 AM

Title: Text doesnt rotate with rest of block
Post by: strebor71 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.
Title: Re: Text doesnt rotate with rest of block
Post by: Lee Mac 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. )
Title: Re: Text doesnt rotate with rest of block
Post by: Daniel J. Ellis 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
Title: Re: Text doesnt rotate with rest of block
Post by: strebor71 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?