Jump to content

Recommended Posts

Posted (edited)

I realise this topic has been covered by numerous examples in the past, but this is a slightly different approach to the previous examples that I have seen.

 

Experiment with it and let me know what you think :D

 

THE LATEST VERSION OF THIS PROGRAM CAN BE FOUND

HERE

Edited by Lee Mac
  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    32

  • JeepMaster

    6

  • fabcad

    3

  • notview

    3

Posted

Have you seen the one from ASMI? :D

http://www.asmitools.com/Files/Lisps/Talon.html

 

I don't know about you, but they look almost identical of what it does, except ASMI has a more options. I like yours because I can see the preview of exactly where and what the text looks like. The + and - is pretty cool. If you can do do the same thing for a curve in an xref, that would make it SUPER COOL. :)

 

 

AsmiTools_Talon.gif

Posted
Have you seen the one from ASMI? :D

http://www.asmitools.com/Files/Lisps/Talon.html

 

I don't know about you, but they look almost identical of what it does, except ASMI has a more options. I like yours because I can see the preview of exactly where and what the text looks like. The + and - is pretty cool. If you can do do the same thing for a curve in an xref, that would make it SUPER COOL. :)

 

 

 

Yes I have seen that from ASMI - but I wanted to approach it in a different way - without just using a Bounding Box.

 

My LISP is in early stages to be honest - I can add many more options if need be :)

Posted

I have updated the above code to include a perpendicularity toggle (P), and allowances for locked layers etc.

 

I have tried to make it compatible with XREF's but with mixed results...

Posted
I have updated the above code to include a perpendicularity toggle (P), and allowances for locked layers etc.

 

I have tried to make it compatible with XREF's but with mixed results...

 

 

Lee,

 

That work great. Another tool for my drop down. What will you think of next.

 

First it was the Big Mac, then came MacNuggets, Now MacAlign. You are full of ideas.

Posted
Lee,

 

That work great. Another tool for my drop down. What will you think of next.

 

First it was the Big Mac, then came MacNuggets, Now MacAlign. You are full of ideas.

 

Thanks Buzzard :) - this topic has been covered by loads of routines that I know of, but I thought I'd add something different, by allowing the user to have a complete preview of the text they are about to place :wink:

Posted

This would be almost perfect if it had an option to do an ( above a default elevation option). That would allow for a floor by floor finish floor dimension. Just throwing that out there.

 

Thanks Lee.

 

Damn you do good work.

Posted

Thanks NH3Man, I try my best :)

 

But could you please explain a bit more about your idea.. :wink:

Posted

Well right now I am working on a multi story building. Most of the installers do not want to deal with say (769.9' above see level). So we convert it all from finish floor. So it would be nice if you could pick a point that is at finish floor elevation and then you dimension would reflect how much above finish floor. If that makes sense.

Posted
Well right now I am working on a multi story building. Most of the installers do not want to deal with say (769.9' above see level). So we convert it all from finish floor. So it would be nice if you could pick a point that is at finish floor elevation and then you dimension would reflect how much above finish floor. If that makes sense.

 

This sounds like a whole new LISP entirely - I might create this separately from the MacAlign.lsp - as this is more specialist, and I wanted to keep the above as general as possible.

 

I would still incorporate all the features of the above LISP, but just in a new LISP with elevation marking aspects.

Posted
Well right now I am working on a multi story building. Most of the installers do not want to deal with say (769.9' above see level). So we convert it all from finish floor. So it would be nice if you could pick a point that is at finish floor elevation and then you dimension would reflect how much above finish floor. If that makes sense.

 

Check this, let me know if its what you're after:

http://www.cadtutor.net/forum/showthread.php?t=37271

Posted

LeeMac,

First of all, thanks for the great lisp. You're awsome.

Okay, is there a way to make the offset spacing adjustable? If my drawing is 1:1 scale, it fine. The offset is in small increments. But when I have dwgs that's 1:100 scale, the offset goes way larger. Default offset spacing from the curve is like +400mm, then the first offset (+) is +4000mm, then +8000mm, etc.

 

I've added a line of code to let the user know about the options. I know I will forget them.:D

;;;==========================[ MacAlign.lsp ]========================== 
;;; Author: Copyright© 2009 Lee McDonnell (Lee Mac)                     
;;;         (Contact @ CADTutor.net, The Swamp.org)                     
;;; Version:  1.0 June 13, 2009                                         
;;;           2.0 June 14, 2009                                         
;;;           3.0 June 16, 2009                                         
;;; Purpose: To Align Text to a Curve                                   
;;; Sub_Routines: getpoint_or_text.lsp by Charles Alan Butler (CAB)     
;;;                                                                     
;;; Additional Features:                                                
;;; Use +/- to Alter Text Offset                                        
;;; Use "P" to toggle perpendicularity                                  
;;;==================================================================== 

(defun c:MacAlign (/ *error* doc spc tmp tStr ent cObj
                    tObj gr cPt pt cAng lAng
                  
                   ; *Mac$Str*  }
                   ; *Mac$tOff* } Global Variables
                   ; *Mac$Per*  }

                  )
 (vl-load-com)

 ;; Error Handler

 (defun *error* (msg)
   (and tObj (not (vlax-erased-p tObj))
        (vla-delete tObj))
   (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\n<< Error: " msg " >>")))
   (princ))

 ;; Check for Locked Current Layer

 (if (eq 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar "CLAYER"))))))
   (progn
     (princ "\n<< Current Layer Locked >>") (exit)))

 ;; Get Space & Doc

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true) ; Vport
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 ;; Set First-time Defaults
 
 (or *Mac$Str*  (setq *Mac$Str* "text"))
 (or *Mac$tOff* (setq *Mac$tOff* 1.))
 (or *Mac$Per*  (setq *Mac$Per* (/ pi 2.)))

 ;; Get Text String
 
 (if (setq tmp
       (getpoint_or_text 2
         (strcat "\nSelect or Type Text <" *Mac$Str* ">: ")))
   (progn
     (cond ((eq "" tmp))
           ((eq 'STR (type tmp))
            (setq *Mac$Str* tmp))
           ((eq 'ENAME (type tmp))
            (setq *Mac$Str* (cdr (assoc 1 (entget tmp)))
                  tSze (cdr (assoc 40 (entget tmp))))))
     (setq tStr *Mac$Str*)
     (or tSze (setq tSze (getvar "TEXTSIZE")))

     ;; Get Curve to Align
     
     (while
       (progn
         (setq ent (nentsel "\nSelect Curve: "))
         (cond ((and (vl-consp ent)
                     (vl-position
                       (cdr (assoc 0 (entget (car ent))))
                         '("LINE" "LWPOLYLINE" "POLYLINE" "ARC"
                           "SPLINE" "CIRCLE" "ELLIPSE" "XLINE")))
                (setq cObj (vlax-ename->vla-object (car ent)))
                nil) ; Exit Loop
               (t (princ "\nMissed, Try Again..."))))) ; Keep in Loop

     ;; Create Text Object
       [color=Red](princ "\n<<Type [+] or [-] for offset, and [P]erpendicular.>>")[/color]
       (vla-put-alignment
         (setq tObj
           (vla-addText spc tStr
             (vlax-3D-point '(0 0 0)) tSze)) acAlignmentMiddleCenter)

     ;; Place Text
           
     (while
       (or
         (and
           (setq gr (grread t 15 0))
             (eq (car gr) 5))
         (and
           (eq 2 (car gr)) ; Keyboard
           (vl-position (cadr gr)
             '(43 ; +
               45 ; -
               61 ; + (as =)
               80 112)))) ; P/p
       
       (cond ((and (eq 5 (car gr)) (listp (setq cPt (cadr gr))))
              (setq pt (vlax-curve-getClosestPointto cObj cPt)
                    cAng (angle pt cPt)
                    lAng (+ cAng *Mac$Per*))

              ;; Correct Angle
              
              (cond ((and (> lAng (/ pi 2)) (<= lAng pi))
                     (setq lAng (- lAng pi)))
                    ((and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
                     (setq lAng (+ lAng pi))))
              
              (vla-move tObj
                (vla-get-TextAlignmentPoint tObj)
                  (vlax-3D-point
                    (polar pt cAng (* tSze *Mac$tOff*))))
              (vla-put-Rotation tObj lAng))

             ((eq 2 (car gr))
              (cond ((vl-position (cadr gr) '(43 61))
                     (setq *Mac$tOff*
                       (+ (/ tSze 10.) *Mac$tOff*)))
                    ((eq (cadr gr) 45)
                     (setq *Mac$tOff*
                       (-  *Mac$tOff* (/ tSze 10.))))
                    ((vl-position (cadr gr) '(80 112))
                     (setq *Mac$Per* (- (/ pi 2.) *Mac$Per*))))))))

   (princ "\n<< No Text Specified >>"))
 (princ))

                      
;;;=======================[ getpoint_or_text.lsp ]======================= 
;;; Author: Copyright© 2005 Charles Alan Butler                           
;;;         (Slight Modification by Lee McDonnell)                        
;;; Version:  1.0 Dec. 12, 2005                                           
;;; Purpose: To get user entered text or picked point                     
;;; Sub_Routines: -None                                                   
;;; Requirements: -ctype is the cursor type                               
;;;                      0  Display the normal crosshairs.                
;;;                      1  Do not display a cursor (no crosshairs).      
;;;                      2  Display the object-selection "target" cursor  
;;;               -prmpt is the user prompt, start it with \n             
;;; Returns: - picked point or                                            
;;;            the user entered text or                                   
;;;            ""  for Enter Key                                          
;;;            nil for Escape Key                                         
;;;====================================================================== 
                      
(defun getpoint_or_text (ctype prmpt / char code data result flag p str)
 (vl-load-com)
 (vl-catch-all-apply
   '(lambda ()
      (setq flag t str "")
      (princ prmpt)
      (while flag
        (setq p    (grread t 15 ctype)
              code (car p)
              data (cadr p))
        (cond ((= code 3) ; clicked point

               ; {Modification}
               
               (if (and (setq result (car (nentselp data)))
                        (wcmatch (cdr (assoc 0 (entget result))) "*TEXT"))
                 (setq flag nil)
                 (princ "\nMissed, Try Again...")))

              ; {End of Modification}
              
              ((= code 2) ; keyboard
               (setq char data)
               (cond ((<= 32 char 126)
                      (princ (chr char))
                      (setq str (strcat str (chr char))))
                     ((= char  ;; backspace was hit .. go chop off a character
                      (and (> (strlen str) 0)
                      (princ (strcat (chr  " " (chr ))
                      (setq str (substr str 1 (1- (strlen str))))))
                     ((= char 13)
                      (setq result str flag nil))))))))
 result)

;|
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;

                         End of Program Code

;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;
|;

Posted

Hi JeepMaster,

 

Firstly, many thanks for your compliments - its great to know that the LISP is appreciated :)

 

Thanks for adding the prompt, makes thins much clearer.

 

As for the offset factor, currently, it is based on the TEXTSIZE sys var: the initial setting is 1.

 

And the offset is calculated:

 

TEXTSIZE x OFFSET VARIABLE

 

Hence the initial default is just the TEXTSIZE.

 

Then, when the user presses +/-, a tenth of the TEXTSIZE is added to the OFFSET VARIABLE. Hence with larger TEXTSIZE, the inital offset is larger, but also, the increments are larger.

 

Should I base this on DIMSCALE also?

Posted

What about based on 1/5 of the dimscale?

Posted

I was thinking just:

 

TEXTSIZE x DIMSCALE x OFFSET VARIABLE

 

Hence, smaller dimscale, smaller offsets.

Posted

I have updated post #1 to include the DIMSCALE factor.

Posted

The larger the drawing scale is, the worst the offset gets(way too far from the curve). I tested it on a 1:400 scale site plan drawing and the offset is almost halfway off my drawing.

ie: on a 1:400 scale dwg, my text is 800mm. The closest text I can place is right on the center of the line, then the first offset is around 32000mm from the curve.:( Maybe we need an extra variable with some funky formula.

Posted
The larger the drawing scale is, the worst the offset gets(way too far from the curve). I tested it on a 1:400 scale site plan drawing and the offset is almost halfway off my drawing.

ie: on a 1:400 scale dwg, my text is 800mm. The closest text I can place is right on the center of the line, then the first offset is around 32000mm from the curve.:( Maybe we need an extra variable with some funky formula.

 

Ah, of course - I am multiplying by the huge textsize on large scale drawings... something needs to be done about that... :P

Posted

I have updated it further - it should be correct now.

 

I have tested it, and it offsets text that is 2.5 in height with the same ratio as text that is 800 in height.

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