Rectangle sizing, Text & Dimension

Rectangle sizing, Text & Dimension

Anonymous
Not applicable
950 Views
2 Replies
Message 1 of 3

Rectangle sizing, Text & Dimension

Anonymous
Not applicable

Dear All Autodesk lisp creators i need your urgent help.

My exact need is as given below:

My requirement is for floor plans i have to create:

1. Rectangle in specific current layer where i should get pop-up to give L & W after making any specific rectangle layer as current layer.

2. Text in the center of that rectangle "with pop up to enter only number after concatenated Specific text" after making any specific Text layer as current layer.

3. After creation of all rectangles i want to give dimension to all rectangles in on go by selecting them after making any specific Dimension layer as current layer.

 

;For Point 1 i used below code:
(defun _SetCLayer (layerName)
(if (tblsearch "layer" layerName)
(setvar 'clayer layerName)
(prompt
(strcat "\n** Layer \"" layerName "\" not found ** ")
)
)
(princ)
)
(defun c:ACDB () (_SetCLayer "AC_DB") (command "RECTANG" "")) - in this autocad is also giving some violations.
(defun c:ACON () (_SetCLayer "AIR_CON") (command "RECTANG"))
(defun c:FBAT () (_SetCLayer "BATTERY") (command "RECTANG"))
(defun c:FBEN () (_SetCLayer "BUILDING_ENVELOPE") (command "RECTANG"))
(defun c:FCAB () (_SetCLayer "CABINET") (command "RECTANG"))
(defun c:DCDB () (_SetCLayer "DC_DB") (command "RECTANG"))
(defun c:FDEF () (_SetCLayer "Defpoints") (command "RECTANG"))
(defun c:FPDI () (_SetCLayer "DIMENSIONS") (command "RECTANG"))
(defun c:FPDR () (_SetCLayer "DOORS") (command "RECTANG"))
(defun C:FFED () (_SetCLayer "FEEDER") (command "RECTANG"))
(defun c:FPLD () (_SetCLayer "FLOOR_LEGEND") (command "RECTANG"))
(defun c:IMGI () (_SetCLayer "Image") (command "RECTANG"))
(defun c:FOTR () (_SetCLayer "OTHER") (command "RECTANG"))
(defun c:FRAK () (_SetCLayer "RACK") (command "RECTANG"))
(defun c:FREF () (_SetCLayer "RECTIFIER") (command "RECTANG"))
(defun c:FTEX () (_SetCLayer "TEXT") (command "RECTANG"))
)
 
;For Point 2 In past i used below command to give text, which is now not working as per my current need
(defun polbldgno ()
;(security)
(setvar "cmdecho" 0)
(setq fspt (getpoint "\n Pick start point of text: "))
(prompt "\n Pick fit (last) point for fitting text inside polygon: ")
(command "line" fspt pause "")
(setq entt (entlast))
(setq secpt (cdr (assoc 11 (entget entt))))
(command "erase" entt "")
;(setq secpt (getpoint "\n Pick fit (last) point for fitting text inside polygon: "))
(setq dst (distance fspt secpt))
(setq angpts (* (angle fspt secpt) 57.xxx-xxxxxxxx))
(setq chr_nos (strlen bldgno))
(setq cc 1)
(setq no_ii 0)
(setq no_11 0)
(setq no_// 0)
(repeat chr_nos
(setq char (substr bldgno CC 1))
(cond ((= char "I")(setq no_ii (+ no_ii 1))))
(cond ((= char "1")(setq no_11 (+ no_11 1))))
(cond ((= char "/")(setq no_// (+ no_// 1))))
(setq cc (+ cc 1))
)
(setq no_oth (- chr_nos (+ no_ii no_11 no_//)))
(setq chr_len (+ (* 1 no_oth) (* no_ii 0.3)(* no_11 0.55)(* no_// 0.7)))
(setq factr (/ dst chr_len ))
(cond ((and (> factr 2.5)(< factr 10.0))(setq txtht 30.0)))
(cond ((and (> factr 2.0)(< factr 2.5))(setq txtht 2.0)))
(cond ((and (> factr 1.5)(< factr 2.0))(setq txtht 1.5)))
(cond ((and (> factr 1.25)(< factr 1.5))(setq txtht 1.25)))
(cond ((and (> factr 1.0)(< factr 1.25))(setq txtht 1.0)))
(cond ((and (> factr 0.75)(< factr 1.0))(setq txtht 0.75)))
(cond ((and (> factr 0.6)(< factr 0.75))(setq txtht 0.6)))
(cond ((and (> factr 0.5)(< factr 0.6))(setq txtht 0.5)))
(cond ((and (> factr 0.4)(< factr 0.5))(setq txtht 0.4)))
(cond ((and (> factr 0.3)(< factr 0.4))(setq txtht 0.3)))
(cond ((and (> factr 0.25)(< factr 0.3))(setq txtht 0.25)))
(cond ((and (> factr 0.2)(< factr 0.25))(setq txtht 0.2)))
(cond ((< factr 0.2)(setq txtht 0.15)))
);defun polbldgno
(defun C:ACDBT ()
(setq bldg_no (strcase (getstring "/n Type the ACDB NO: ")))
(setq bldgno (strcat "ACDB" bldg_no))
(polbldgno)
(command "clayer" "AC_DB" "" "text" fspt txtht angpts bldgno "")
)

;I got help from other forum and found below solution which is solving need of my first point
I would try something along these lines [untested]:
 
(vl-load-com)
(defun recttxt (layname prefix)
  (command
    "_.layer" "_make" layname ""
    "_.rectang" pause "_dimensions" pause pause pause
    "_.text" "_mc" "_none"
      (mapcar '/ ; calculate midpoint of rectangle [in place of fspt, I assume]
        (mapcar '+
          (vlax-curve-getStartPoint (entlast))
          (vlax-curve-getPointAtParam (entlast) 2)
        ); mapcar +
        '(2 2 2)
      ); mapcar /
      txtht angpts [or should the rotation always be 0?]
      (lisped prefix); text content with prefix built in
  ); command
  (princ)
); defun

;And then for each Layer, call that function and feed in the Layer name and associated Text prefix, for example:
(defun C:ACDB () (recttxt "AC_DB" "ACDB"))

I would also like to include a setting of the Style in the Text command, rather than just using whatever Style happens to be current.

If some other Style is current and has a non-zero fixed height, it will throw this off, because there will be no prompt for the height,

so i want to set & define a text Style, Colour, Layer with a fixed height, and leave out the height response in the command.

 

 

My point 3 requirement is still open: I found some routines around to automatically dimension Polylines by Searching but they are working for individual entity instead of all selected entity.

0 Likes
951 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

[This is probably the better Forum for this issue, but for more background if you're interested, see the other thread where it started.]

Kent Cooper, AIA
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

My point 3 requirement is still open: I found some routines around to automatically dimension Polylines by Searching but they are working for individual entity instead of all selected entity.


Here is one that does more than one at once.  [It didn't come to mind when I suggested a Search on your other thread, and even after I remembered about it, I had forgotten that I made a multi-Polyline version of it.]  It has two commands, for Dimensioning inside or outside -- appropriate parts could be put into your eventual routine, without having to use all of it.

Kent Cooper, AIA
0 Likes