วันอาทิตย์ที่ 13 มีนาคม พ.ศ. 2565

Polyline Dimensions

(defun c:pdim(/ plSet pLlst vLst vLst0 vLst1 oldOsn cAng cDis cPt index)

(princ "\n<<< Select LwPolyline for dimensioning >>> ")

(if(setq plSet(ssget '((0 . "LWPOLYLINE"))))

      (progn

            (setq index -1

                    oldOsn(getvar "OSMODE")

            )

            (setq pLlst(vl-remove-if 'listp (mapcar 'cadr(ssnamex plSet))))

            (setvar "OSMODE" 0)

            (setvar "CMDECHO" 0)

            (foreach pl pLlst

                  (setq vLst(mapcar 'cdr (vl-remove-if-not '(lambda(x)(= 10(car x)))(entget pl))) 

                          reg (ssname plSet (setq index (1+ index)))

                  ); end setq

                  ;(print vLst) ;original points list

                  (if (and(= (car (nth 0 vLst))(car (nth (1- (length vLst)) vLst)))

                              (= (cadr (nth 0 vLst))(cadr (nth (1- (length vLst)) vLst)))

                        )

                        (setq vLst1 vLst)

                        ;(progn

                              (if (= (cdr (assoc 70 (entget reg))) 1)

                                    (progn                                   

                                          (setq vLst1 vLst)

                                          (setq vLst0 (list (car(nth 0 vLst))(cadr(nth 0 vLst))))

                                          (setq vLst1 (reverse (cons vLst0 (reverse vLst1))))

                                    )

                                    (setq vLst1 vLst)

                              )

                        ;)

                  )

                  ;(print vLst1) ;after check points list

                  (while(< 1(length vLst1))

                        (setq cAng(angle(car vLst1)(cadr vLst1))

                                cDis(/(distance(car vLst1)(cadr vLst1))2)

                                cPt(polar (polar(car vLst1)cAng cDis) (+ cAng(/ pi 2)) (* 2 (getvar "DIMTXT")))

                        ); end setq

                        (command "_.dimaligned"(car vLst1)(cadr vLst1) cPt)

                        (setq vLst1(cdr vLst1))

                  ); end while

            ); end foreach

            (setvar "OSMODE" oldOsn)

            (setvar "CMDECHO" 1)

    ); end progn

); end if

(princ)

); end of c:pdim


ไม่มีความคิดเห็น:

แสดงความคิดเห็น