Replacing Dimension Text in a Function with Variables

Replacing Dimension Text in a Function with Variables

Anonymous
Not applicable
683 Views
2 Replies
Message 1 of 3

Replacing Dimension Text in a Function with Variables

Anonymous
Not applicable

I need to replace the actual dimension text so that it would look like this ----4 spa @ 5'-0 = 20'-0.

Where the "4" is replaced by the variable "qty", the "spa @" is always there, the "5'-0" is replaced with the variable "off", and the "20'-0" is given as the default  "<> "

 

Any ideas would be appreciated.

 

;;;---------------------------------------------------------------------------------------------------------------------;
;;; Function C:EB ;
;;; Description: Draws equally spaced Beams in a bay ;
;;; 3/11/19 Dale Poston ;
;;; 3/12/19 changed to "EB" and replaced joists references with beams ;
;;; 3/14/19 added saving and restoring layer, OSnap, and Dimstyle ;
;;; added Dimension ;
;;;---------------------------------------------------------------------------------------------------------------------;

(defun c:EB (/ p1 p2 p3 d qty off olddim)

;; Save Current Layer
;; Set Current Layer and Object Snap settings
(setq oldlayer (getvar "clayer"))
(ai_sysvar '(("clayer" . "Beam") ("osmode" . 233)))
(setq olddim (getvar "dimstyle"))
(command "_dimstyle" "_r" "kdspacing")
(vl-catch-all-apply
'(lambda ()

;;; get points and number of Beams
(setq p1 (getpoint "\nPick top span point: ")
p2 (getpoint "\nPick bottom span point: ")
p3 (getpoint "n\Pick bottom bay far point: ")
d (distance p2 p3)
qty (getreal "\nHow many Spaces: ")
)
)
)

;;; do the math
(setq off (/ d qty)) ; Offset amount for Beams (equally spaced)


;;; draw line from p1 to p2
(command "line" p1 p2 "")

;;; offset for Beams and erase p1 p2
(if (> d off)(command "offset" off p1 p2 ""))
(if (> d (* 2 off))(command "offset" (* 2 off) p1 p2 ""))
(if (> d (* 3 off))(command "offset" (* 3 off) p1 p2 ""))
(if (> d (* 4 off))(command "offset" (* 4 off) p1 p2 ""))
(if (> d (* 5 off))(command "offset" (* 5 off) p1 p2 ""))
(if (> d (* 6 off))(command "offset" (* 6 off) p1 p2 ""))
(if (> d (* 7 off))(command "offset" (* 7 off) p1 p2 ""))
(if (> d (* 8 off))(command "offset" (* 8 off) p1 p2 ""))
(if (> d (* 9 off))(command "offset" (* 9 off) p1 p2 ""))
(if (> d (* 10 off))(command "offset" (* 10 off) p1 p2 ""))
(if (> d (* 11 off))(command "offset" (* 11 off) p1 p2 ""))
(if (> d (* 12 off))(command "offset" (* 12 off) p1 p2 ""))
(if (> d (* 13 off))(command "offset" (* 13 off) p1 p2 ""))
(if (> d (* 14 off))(command "offset" (* 14 off) p1 p2 ""))
(if (> d (* 15 off))(command "offset" (* 15 off) p1 p2 ""))
(if (> d (* 16 off))(command "offset" (* 16 off) p1 p2 ""))
(if (> d (* 17 off))(command "offset" (* 16 off) p1 p2 ""))
(if (> d (* 18 off))(command "offset" (* 17 off) p1 p2 ""))
(if (> d (* 19 off))(command "offset" (* 18 off) p1 p2 ""))
(if (> d (* 19 off))(command "offset" (* 19 off) p1 p2 ""))
(if (> d (* 20 off))(command "offset" (* 20 off) p1 p2 ""))
(if (> d (* 21 off))(command "offset" (* 21 off) p1 p2 ""))
(if (> d (* 22 off))(command "offset" (* 22 off) p1 p2 ""))
(if (> d (* 23 off))(command "offset" (* 23 off) p1 p2 ""))
(if (> d (* 24 off))(command "offset" (* 24 off) p1 p2 ""))
(if (> d (* 25 off))(command "offset" (* 25 off) p1 p2 ""))
(if (> d (* 26 off))(command "offset" (* 26 off) p1 p2 ""))
(if (> d (* 27 off))(command "offset" (* 27 off) p1 p2 ""))
(if (> d (* 28 off))(command "offset" (* 28 off) p1 p2 ""))
(if (> d (* 29 off))(command "offset" (* 29 off) p1 p2 ""))
(if (> d (* 30 off))(command "offset" (* 30 off) p1 p2 ""))
(command "erase" p1 p2 "")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; "Dimension" the Beams ;;;
;; Set layer ;;;
(Setvar "clayer" "Dimensions")

(command "dimaligned" p2 p3 "@-36,36" "")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; need to replace the actual dimension text that would look like this ----4 spa @ 5'-0 = 20'-0 ;;;
; where the "4" is replaced by the variable "qty", the "spa @" is always there, the "5'-0" is replaced ;;;
; with the variable "off", and the "20'-0" is given as the default - <> ;;;

;; Reset Layer, OS, and Dimstyle
;(ai_sysvar nil)
(setvar "clayer" oldlayer)
(command "_dimstyle" "_r" olddim)
(princ)
)

;;; End function

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

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

hope this is still actual...

 

replace this line:

(command "dimaligned" p2 p3 "@-36,36" "")

with this line:

(command "._dimaligned" p2 p3 "_text" (strcat (rtos qty 2 0) " spa @ " (rtos off 4) " = <>") "@-36,36")

enjoy

moshe

 

Message 3 of 3

Anonymous
Not applicable

Thank you.

I had received a solution on another forum which is very close to yours.

I'll try them both and see which is best.

 

0 Likes