Jump to content

Text Spacing Lisp Routine


DAVIDA

Recommended Posts

I've searched the internet for a LISP routine that will grab lines of individual text and re-list them correctly aligned and equally spaced apart.

 

Anyone know of a LISP that does this or something similar that I can edit?

Link to comment
Share on other sites

LOL, David

 

the custom lisp routine you mentioned will be prety hard to find unless, as you suggested someone has created one and they send you it on here, is there nothing on the web for like a lisp archive where people can contribute? sorry im not really a lisp man, but couldnt refuse the doctor pun. :)

 

I have trawled the internet for a suitable LISP or something similar to no avail. There are literally thousands of LISP routines avilable on the web (many that do the same thing and even many that are already AutoCAD commands). I have probably missed the ideal one somewhere as there are so many.

 

Thanks for your interest.

Link to comment
Share on other sites

Found something:

 

(defun c:daly (/ tHeight insPoint dtSet oldDisMode errFlag 
                sStr tAlignPt tAlignment disDelta dtList 
                oldStrDis hitStr alignList oldMinPt maxPt
         minPt oldAlign oldDirect)
 
 (vl-load-com) 

 (defun texAlign (item /)
   (if(= daly:Direct "Y")
     (progn
         (setq disDelta(- disDelta daly:strDis)); end setq 
     (vla-put-Alignment (car str) tAlignment) 
     (cond 
  ((= tAlignment 0) 
     (vla-put-InsertionPoint (car str) 
       (vlax-3D-Point(car insPoint) 
         (+ disDelta(cadr insPoint))(nth 2 insPoint))) 
   ) 
  ((member tAlignment '(1 2 4 6 7 8 9 10 11 12 13 14)) 
     (vla-put-TextAlignmentPoint (car str) 
       (vlax-3D-Point(car tAlignPt) 
         (+ disDelta(cadr tAlignPt))(nth 2 tAlignPt))) 
   ) 
  ((member tAlignment '(3 5)) 
   (princ "\nCan't align string with Aligned or Fit alignment ") 
   ) 
  ); end cond
); end progn
     (progn
     (setq disDelta(- disDelta daly:strDis)); end setq 
     (vla-put-Alignment (car str) tAlignment) 
     (cond 
  ((= tAlignment 0) 
     (vla-put-InsertionPoint (car str) 
       (vlax-3D-Point(-(car insPoint)disDelta)
         (cadr insPoint)(nth 2 insPoint))) 
   ) 
  ((member tAlignment '(1 2 4 6 7 8 9 10 11 12 13 14)) 
     (vla-put-TextAlignmentPoint (car str) 
       (vlax-3D-Point(-(car tAlignPt)disDelta)
         (cadr tAlignPt)(nth 2 tAlignPt))) 
   ) 
  ((member tAlignment '(3 5)) 
   (princ "\nCan't align string with Aligned or Fit alignment ") 
   ) 
  ); end cond
     ); end progn
   ); end if
   ); end of texAlign

 (if(not daly:Direct)(setq daly:Direct "Y"))
 (setq oldDirect daly:Direct)
 (if(not daly:Align)(setq daly:Align "H"))
 (setq oldAlign daly:Align)
 (if(not daly:disMode)(setq daly:disMode "S")) 
 (setq oldDisMode daly:disMode) 
 (if(not daly:strDis)(setq daly:strDis 4.167)) 
 (setq oldStrDis daly:strDis)
 (initget "Y X")
 (setq daly:Direct 
   (getkword 
     (strcat "\nSpecify alignment direction [X-axis/Y-axis] <"daly:Direct">: ")))
 (if(null daly:Direct)(setq daly:Direct oldDirect))
 (initget "H L C M R TL TC TR ML MC MR BL BC BR")
 (setq daly:Align 
   (getkword 
     (strcat "\nSpecify justification [Hitest string/Left/Center/Middle/Right/TL/TC/TR/ML/MC/MR/BL/BC/BR] <"daly:Align">: "))
alignList '(("L" 0)("C" 1)("R" 2)("M" 4)("TL" 6)("TC" 7)("TR" ("ML" 9)("MC" 10)("MR" 11)("BL" 12)("BC" 13)("BR" 14))
	    ); end setq 
 (if(null daly:Align)(setq daly:Align oldAlign))
 (initget "S C") 
 (setq daly:disMode 
   (getkword 
     (strcat "\nSpecify distance between strings [standard/Custom] <"daly:disMode">: "))) 
 (if(null daly:disMode)(setq daly:disMode oldDisMode)) 
 (if(= daly:disMode "C") 
   (progn 
   (setq daly:strDis(getdist(strcat "\nSpecify Custom distance <"(rtos daly:strDis)">: "))) 
   (if(null daly:strDis)(setq daly:strDis oldStrDis)) 
   (princ(strcat "\nCustom distance is "(rtos daly:strDis))) 
    ); end progn 
   ); end if
 (while T
 (princ "\n<<< Select DText and press Enter or Esc to Quit >>> ") 
  (if 
    (setq dtSet(ssget '((0 . "TEXT")))) 
   (progn
     (if(= "Y" daly:Direct)
     (setq dtList(vl-sort(mapcar 
          '(lambda (x)(list x 
        (+(cadr(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-InsertionPoint x)))) 
                (cadr(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-TextAlignmentPoint x))))))) 
      (mapcar 'vlax-ename->vla-object 
                 (vl-remove-if 'listp 
                    (mapcar 'cadr(ssnamex dtSet)))))
          (function(lambda(a b)(>(cadr a)(cadr b))))))

(setq dtList(vl-sort(mapcar 
          '(lambda (x)(list x 
        (+(car(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-InsertionPoint x)))) 
                (car(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-TextAlignmentPoint x))))))) 
      (mapcar 'vlax-ename->vla-object 
                 (vl-remove-if 'listp 
                    (mapcar 'cadr(ssnamex dtSet)))))
          (function(lambda(a b)(<(cadr a)(cadr b))))))
      ); end if
  
    (setq hitStr(caar dtList))
     
     (if(/= "H" daly:Align)
(progn
  (vla-getBoundingBox hitStr 'oldMinPt 'MaxPt)
  (foreach lst alignList
	     (if(=(car lst)daly:Align)
	       (progn
		 (if 
                         (not 
                          (vl-catch-all-error-p 
                           (vl-catch-all-apply 'vla-put-Alignment(list hitStr(cadr lst)))))
		  (progn
		    (vla-getBoundingBox hitStr 'minPt 'maxPt)
		    (vla-move hitStr minPt oldMinPt)
		    ); end progn
		  ); end if
		 ); end progn
	       ); end if
    ); end foreach
  ); end progn
); end if
		 
    (setq tHeight(vla-get-Height hitStr) 
          insPoint(vlax-safearray->list 
                    (vlax-variant-value 
                      (vla-get-InsertionPoint hitStr))) 
          tAlignPt(vlax-safearray->list 
                    (vlax-variant-value 
                      (vla-get-TextAlignmentPoint hitStr))) 
          tAlignment(vla-get-Alignment hitStr) 
          dtList(cdr dtList) 
          disDelta 0.0 
    ); end setq 
   (if(= daly:disMode "S")(setq daly:strDis(* 1.6668 tHeight))) 
     (foreach str dtList 
    (if 
  (not 
      (vl-catch-all-error-p 
           (vl-catch-all-apply 'texAlign (list str)))) 
      (princ) 
      (setq errFlag T) 
      ); end if 
  ); end foreach 
     (if errFlag(princ "\n<!> Some Entities on Locked Layer <!>")) 
 ); end progn 
   (princ "\nStrings isn't selected. ") 
   ); end if
   ); end while
   (princ) 
   ); end of dali

(princ "\nType DALY to Run ")

Link to comment
Share on other sites

Thanks ASMI but I cut and paste the code into a notepad file with result of .....

 

Command: _appload

"no function definition at [EVAL]"

 

.. when I tried to load application. Any ideas?

Link to comment
Share on other sites

I have now found out from one of our IT guys how to make it load by downloading the acad simulation from LT Extender.

 

If anyone wants to know more details then I can get more details how he sorted it.

 

Thanks all

Link to comment
Share on other sites

Hi. It's possible, but I havn't more time today. This code calculates angle in point of curve. May be you can to find and modify it and add an option? 'curDer' is First Derive in point specified.

 

(if(=(cadr curDer) 0.0)
                   (setq curAng (/ pi 2))
                          (setq curAng
			(- pi
			 (atan
			  (/(car curDer)
			    (cadr curDer)))))
                  ); end if

 

I can't to answer when I will to have free time at this week. Maybe at holydays only :(

Link to comment
Share on other sites

  • 8 months later...

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