Lisp for automating a text column height and gutter thickness to fit a bounding box.

Lisp for automating a text column height and gutter thickness to fit a bounding box.

paoloWE2Z9
Explorer Explorer
481 Views
4 Replies
Message 1 of 5

Lisp for automating a text column height and gutter thickness to fit a bounding box.

paoloWE2Z9
Explorer
Explorer

ideally it would promp the user for the amount of column wanted, and then automatically fit the text into that box. i have done a bit of research and have compiled a couple routines that do similar tasks but have not managed to get it to do what i want. 

 

this would mainly be used for out companies specifications sheets.

0 Likes
482 Views
4 Replies
Replies (4)
Message 2 of 5

pendean
Community Legend
Community Legend
Share a sample plan/note+bounding box in a DWG file here please (fudge/fake it as needed), and elaborate on the "prompt" you want the user to see as well.

Message 3 of 5

paoloWE2Z9
Explorer
Explorer

Thanks for the quick reply , sure ill share a CAD file. in the CAD, the specifications are split into 8 coloumns, i would like to be able to quikly see how it would look with 7 or 6 without doing the calculations. the promp doesnt have to be anything special, something in the command line asking "how many coloumns ___" 

 

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

Missing xrefs maybe not sure what you want post a image also.

0 Likes
Message 5 of 5

ВeekeeCZ
Consultant
Consultant

First of all, despite the topic subject, this does not modify column height nor gutter width. As you set it, you have it.

 

You can set the page size ONLY if you run the routine with nothing preselected. Then you can optionally pre-select the mtext and run the routine without that prompt - so you just specify the number of columns.

 

The best results you get when the UL adj point of MTEXT is placed in the half gutter dist from the left frame edge.

 

(vl-load-com)
(defun c:MtextColFit ( / s e h g c n)

  (or *mtcf-page*
      (setq *mtcf-page* 30.25))

  (and (ssget "_I")
	   (setq s (ssget "_P" '((0 . "MTEXT"))))
	   (setq e (ssname s 0)))  
  
  (while (not e)
    (princ (strcat "\nPage width: " (rtos *mtcf-page*)))
    (initget "Page")
    (setq e (car (entsel "\nSelect mtext or change [Page]: ")))
    (if (= e "Page")
      (progn
	(initget 6)
	(setq *mtcf-page* (getdist "\nSpecify Page width: ")
	      e nil))))
    
  (if (and (setq h (cdr (assoc 40 (entget e))))
	   (setq g (getpropertyvalue e "ColumnGutterWidth"))
	   (setq c (getpropertyvalue e "ColumnWidth"))
	   (setq n (fix (/ *mtcf-page* (+ c g))))
	   (setq n (cond ((getint (strcat "\nSpecify number of columns <" (itoa n) ">: "))) (n)))
	   (setq c (- (/ *mtcf-page* (float n)) g))
	   )
   (vl-catch-all-apply 'setpropertyvalue (list e "ColumnWidth" c)))

  (princ)
  )

 

0 Likes