Placing MText based on Arraypath with alignment

Placing MText based on Arraypath with alignment

manyamjyotsna
Participant Participant
510 Views
2 Replies
Message 1 of 3

Placing MText based on Arraypath with alignment

manyamjyotsna
Participant
Participant

Hello,

I have polylines consisting of both curves and straight paths. My requirement is to place MText along the polyline at a specified spacing and offset. To achieve this, I used the ARRAYPATH command to distribute objects along the polyline with the desired spacing. This also allows me to adjust the spacing between the objects as needed.

 

Now, I need to place MText at each object generated by the ARRAYPATH, displaying incremental numbers in the format: 0+00, 1+00, 2+00, etc., as shown in the sample DWG.

 

Thanks in advance!




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

parkr4st
Advisor
Advisor

What are the units of the drawing?  intervals are 30.49 +/- units apart? but labeled in 100 units distances?  meters vs feet?  

Does this represent a centerline of a road or a pipe for examples?

0 Likes
Message 3 of 3

manyamjyotsna
Participant
Participant
  1. The drawing units are in meters.

  2. Objects in the array are spaced 30.49m (100 ft) apart. At every 30.49m, stationing labels will be generated, starting from 0+00, 1+00, 2+00, increasing in increments of 100.

  3. The polyline/array represents the centerline of a road.

I have created a LISP routine that works fine, but currently, it places TEXT instead of MText.

(defun c:STATIONING ( / cl obj1 obj2 pt1 pt2 dirx diry i station count spacing len param pt)
(setq spacing 30.49) ;; Fixed spacing in meters (each step = 100 station units)

;; Select the centerline polyline
(setq cl (car (entsel "\nSelect centerline polyline: ")))

(if (not (and cl (= (cdr (assoc 0 (entget cl))) "LWPOLYLINE")))
(progn
(princ "\nInvalid selection. Please select a polyline.")
(exit)
)
)

;; Select first object in the array
(setq obj1 (car (entsel "\nSelect first object in the array: ")))

;; Select second object to determine array direction
(setq obj2 (car (entsel "\nSelect second object in the array: ")))

(if (and obj1 obj2)
(progn
;; Get object positions
(setq pt1 (cdr (assoc 10 (entget obj1))))
(setq pt2 (cdr (assoc 10 (entget obj2))))

;; Compute array direction (unit vector)
(setq dirx (/ (- (car pt2) (car pt1)) spacing))
(setq diry (/ (- (cadr pt2) (cadr pt1)) spacing))

;; Get centerline length
(setq len (vlax-curve-getDistAtParam cl (vlax-curve-getEndParam cl)))

;; Calculate number of objects based on centerline length
(setq count (fix (/ len spacing)))

;; Start placing stationing labels
(setq i 0
station 0
param 0)

(while (< i count)
(setq pt (vlax-curve-getPointAtDist cl (* i spacing))) ;; Get exact point on centerline

(if pt
(command "_TEXT" pt 1 0 (strcat (itoa station) "+00")) ;; Place station label
)

(setq i (1+ i)
station (1+ station)) ;; Increment station (100 units per step)
)

(princ "\nStationing added successfully!")
)
(princ "\nError: Could not determine array direction.")
)
(princ)
)




0 Likes