Jump to content
lownote1980

Lisp for rotating text to current view

Recommended Posts

lownote1980

Hello all,

I would like to know if anybody has any bright ideas about a problem I face when drawing building elevations in 3D.

 

I use 3D polylines to survey a facade on site. When back in the office I get an output of a 3D polyline with a point and node at each surveyed point. The point is aligned to 3d *top* view. I then rotate the current view aligned to the required building facade.

 

My question is twofold:

1) Is there a way of rotating the point to see the point style in the current view?

2) As my point information plots in 3D as point, point number, and elevation is there a lisp routine to rotate the point number text and level text about the centre of the point to present as 'correct' in the current view?

 

I don't expect miracles or written LISP routines but a couple of pointers would be really appreciated.

 

Lownote

Share this post


Link to post
Share on other sites
gile

Hi,

 

(trans '(0. 0. 1.) 2 0 T) returns the normal vector of the current view plane.

You can use this vector to modify the 210 DXF code (or the 'Normal' vla property) and to transform TEXTs insertion point with the trans function.

 

Here's a little sample to align selected points and texts to the current view plane (you may have to deal with 11 DXF code according to the texts justification)

 

(defun c:RotateToView (/ n ss ent elst)
 (if (setq norm (trans '(0. 0. 1.) 2 0 T)
       n     -1
       ss     (ssget '((0 . "POINT,TEXT")))
     )
   (while (setq ent (ssname ss (setq n (1+ n))))
     (setq elst (entget ent)
       ins     (assoc 10 elst)
     )
     (if (= (cdr (assoc 0 elst)) "TEXT")
   (entmod    (subst (cons 10 (trans (cdr ins) ent norm))
              ins
              (subst (cons 210 norm) (assoc 210 elst) elst)
       )
   )
   (entmod (subst (cons 210 norm) (assoc 210 elst) elst))
     )
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
lownote1980

Hi Gile,

Thanks for that LISP. It works great and allows me to get just what I needed.

 

How does the text element of the LISP work? I can rotate the point to view but the level text (which sits next to the point) flys off screen. Currently I am selecting all the elements to be rotated (points and text) and when I hit enter the points rotate and the text dissappears. Am I making a simple mistake?

 

Thanks again for the LISP!:D

 

Lownote

Share this post


Link to post
Share on other sites
lownote1980

After further fiddling I see what mean about the insertion point of the text. The text correctly aligns itself to the current view but uses an odd base point to 'reinsert' the text away from the point.

 

How do you reassign the text basepoint to swivel around the point?

 

Kind regards

lownote

Share this post


Link to post
Share on other sites
Lee Mac

Try this slight modification:

 

(defun c:RotateToView ( / n ss ent elst )
 ;; Gile, mod by Lee Mac
 
 (if (setq norm (trans '(0. 0. 1.) 2 0 T) n -1
             ss (ssget '((0 . "POINT,TEXT"))))
   
   (while (setq ent (ssname ss (setq n (1+ n))))
     (setq elst (entget ent))

     (setq ins
       (assoc
         (if (eq '(0 0) (mapcar 'dxf '(72 73) (list elst elst)))
           10 11
         )
         elst
       )
     )
     
     (if (eq (dxf 0 elst) "TEXT")
       (entmod
         (subst
           (cons (car ins) (trans (cdr ins) ent norm))
           ins
           (subst (cons 210 norm) (assoc 210 elst) elst)
         )
       )        
       (entmod (subst (cons 210 norm) (assoc 210 elst) elst))
     )
   )
 )
 (princ)
)

(defun dxf ( code lst ) (cdr (assoc code lst)))

Share this post


Link to post
Share on other sites
lownote1980

Thanks for the modification LeeMac. I am in the process of deceiphering how the code works. Some parts may be a few chapters on in the LISP book I am reading. I'll post a reply on the success on Monday.

 

Thanks again

Lownote

Share this post


Link to post
Share on other sites
Lee Mac

'trans' and the Coordinate Systems sometimes take a little while to understand and master, but you are in good hands with Gile - I have learn a great deal from him also.

Share this post


Link to post
Share on other sites
lownote1980

Hi LeeMac

I tried the LISP with great success today. Thanks very much - it will make elevations an awful lot easier!

 

Regards

Lownote

Share this post


Link to post
Share on other sites
Lee Mac
Hi LeeMac

I tried the LISP with great success today. Thanks very much - it will make elevations an awful lot easier!

 

Regards

Lownote

 

You're very welcome Lownote - although Gile should take the credit :)

Share this post


Link to post
Share on other sites
KevinMcDonagh

Thanks works like a charm

Share this post


Link to post
Share on other sites
zyborgmonkey

See attached.

 

So it works great with the text "2.62" which I've set to 0 Rot in properties and as you can see doesn't match up with the WCS because I was working in a UCS aligned to the building on insertion.

 

However when you use the routine on the txt "Col" it shoots off elsewhere 0.o

 

new block.dwg

Share this post


Link to post
Share on other sites
Roy_043

Change the first occurance of 'eq' to 'equal' (line 12 of the code in post #5).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...