Thursday, March 27, 2025

FREELISP : Dimension align segment of polyline

             If user want to create dimension on each segment of polyline, try this LISP program

    Here is Video



@ptcaduser

PTCAD-DIM Align polyline #lisp #dimalign #polyline #cad

♬ original sound - ptcaduser


Here is source code

(defun c:DimAll ( / ent entData vlist i pt1 pt2)  ; COMMAND is DIMALL
  (prompt "\nSelect Polyline to create dimension for each segment:")
  (setq ent (car (entsel)))
  (if (and ent
           (= (cdr (assoc 0 (setq entData (entget ent)))) "LWPOLYLINE"))
    (progn
      ;; create list of  Polyline vertex
      (setq vlist '())
      (foreach x entData
        (if (= (car x) 10)
          (setq vlist (append vlist (list (cdr x))))
        )
      )
      ;;  Polyline check
      (if (= (logand (cdr (assoc 70 entData)) 1) 1)
        (setq vlist (append vlist (list (car vlist)))) ; if closed, add last point
      )
      ;; Loop create DIMALIGNED each segment
      (setq i 0)
      (while (< (1+ i) (length vlist))
        (setq pt1 (nth i vlist))
        (setq pt2 (nth (1+ i) vlist))
        (command "_.DIMALIGNED" pt1 pt2 pause) ; pause = wait user place dim line
        (setq i (1+ i))
      )
    )
    (prompt "\nselected not  Polyline")
  )
  (princ)

No comments:

Post a Comment

Draw mechanical details with PTCAD Plus - MEC

     Draw mechanical details with PTCAD Plus - MEC               PTCAD Plus edition contains many plug-ins  AECplus, MEC, Assetlink which ca...