Jump to content

Lisp for rotating text to current view


lownote1980

Recommended Posts

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)))

Link to comment
Share on other sites

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

Link to comment
Share on other sites

'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.

Link to comment
Share on other sites

Hi LeeMac

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

 

Regards

Lownote

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

  • 3 years later...
  • 3 years later...

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

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...